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

RESOLVED FIXED in Firefox 44

Status

()

Toolkit
Telemetry
RESOLVED FIXED
2 years ago
2 years ago

People

(Reporter: Dexter, Assigned: Henrik Tjäder, Mentored)

Tracking

(Blocks: 1 bug)

Trunk
mozilla44
Points:
---

Firefox Tracking Flags

(firefox44 fixed)

Details

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

Attachments

(1 attachment)

(Reporter)

Description

2 years ago
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
(Reporter)

Updated

2 years ago
Blocks: 1201022
(Reporter)

Updated

2 years ago
Whiteboard: [measurement:client]
(Reporter)

Comment 1

2 years ago
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@gmail.com
Whiteboard: [measurement:client] → [unifiedTelemetry][measurement:client][lang=js][good first bug]
(Assignee)

Comment 2

2 years ago
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".
(Reporter)

Comment 3

2 years ago
https://treeherder.mozilla.org/#/jobs?repo=try&revision=be5f60dd535d
(Reporter)

Comment 4

2 years ago
(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.
(Reporter)

Updated

2 years ago
Assignee: nobody → henrik
Status: NEW → ASSIGNED
(Reporter)

Updated

2 years ago
Attachment #8671290 - Flags: review+
(Reporter)

Updated

2 years ago
Keywords: checkin-needed

Comment 5

2 years ago
https://hg.mozilla.org/integration/fx-team/rev/4a7e85280dd4
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/4a7e85280dd4
Status: ASSIGNED → RESOLVED
Last Resolved: 2 years ago
status-firefox44: affected → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla44
You need to log in before you can comment on or make changes to this bug.