Closed Bug 1209912 Opened 9 years ago Closed 9 years ago

Use JSON.parse instead of nsIJSON.decode in Telemetry tests

Categories

(Toolkit :: Telemetry, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla44
Tracking Status
firefox44 --- fixed

People

(Reporter: Dexter, Assigned: henrik, Mentored)

References

(Blocks 1 open bug)

Details

(Whiteboard: [unifiedTelemetry][measurement:client][lang=js][good first bug])

Attachments

(1 file)

Telemetry tests log is raising the following warning locally: 0:01.65 LOG: Thread-1 INFO "CONSOLE_MESSAGE: (warn) [JavaScript Warning: "nsIJSON.decode is deprecated. Please use JSON.parse instead." {file: "c:/mozilla-central/obj-i686-pc-mingw32/_tests/xpcshell/toolkit/components/telemetry/tests/unit/head.js" line: 137}]" This should be easily fixed by changing [1] to |JSON.parse|. [1] - https://dxr.mozilla.org/mozilla-central/rev/891ee0d0ba3ec42b6484cf0205b3c95e21c58f74/toolkit/components/telemetry/tests/unit/head.js#137
Blocks: 1201022
Whiteboard: [measurement:client]
To fix the problem, this line [1] in head.js should be changed from: payload = decoder.decode(utf8string); to payload = JSON.parse(utf8string); We cannot get rid of the |decoder| itself, as it would still be used for |decodeFromStream|. To make sure that the problem is fixed, run an xpcshell test as follows: ./mach xpcshell-test toolkit/components/telemetry/tests/unit/test_TelemetryController.js | grep Warning and check that the warning message in the previous comment is not there anymore. [1] - https://dxr.mozilla.org/mozilla-central/rev/891ee0d0ba3ec42b6484cf0205b3c95e21c58f74/toolkit/components/telemetry/tests/unit/head.js#137
Mentor: alessio.placitelli
Whiteboard: [measurement:client] → [unifiedTelemetry][measurement:client][lang=js][good first bug]
Implemented changes as proposed by Alessio, the test passes: no further warning about using "decode".
(In reply to Henrik Tjäder from comment #2) > Created attachment 8671290 [details] [diff] [review] > bug_1209912_-_Use_JSON.parse_instead_of_nsIJSON.decode_in_Telemetry_tests. > patch > > Implemented changes as proposed by Alessio, the test passes: no further > warning about using "decode". Thank you Henrik, and welcome! Once you attach the patch, you should also request a review: this is done by selecting the "?" value when attaching the patch, in the "Review" entry. A new field will appear, and you should type in the email of the desired reviewer. In this case, that's me, so I've done that for you :) You could also type the name of the reviewer in that field, Bugzilla will spawn a dropdown with some suggestions for you! I've also pushed it to try servers for you.
Assignee: nobody → henrik
Status: NEW → ASSIGNED
Attachment #8671290 - Flags: review+
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: