Provide a console API object in experiments API sandbox

RESOLVED FIXED in Firefox 55

Status

()

Toolkit
WebExtensions: Experiments
RESOLVED FIXED
9 months ago
9 months ago

People

(Reporter: rpl, Assigned: rpl)

Tracking

unspecified
mozilla55
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(firefox55 fixed)

Details

MozReview Requests

()

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(1 attachment)

(Assignee)

Description

9 months ago
While working on experiments API addons (https://webextensions-experiments.readthedocs.io/) is useful to be able to use the console API to log debug messages to the Browser Console instead of using dump (e.g. to be able to inspect an object that cannot be serialized into a string, filter the log messages easily as the Browser Console already support, etc.)

The goal of this bugzilla issue is providing the ConsoleAPI object instance in the experiments sandbox by default without the need to do it manually for every experiments.
Comment hidden (mozreview-request)
(Assignee)

Updated

9 months ago
Attachment #8852074 - Flags: review?(kmaglione+bmo)
Comment on attachment 8852074 [details]
Bug 1351381 - Provide a console API object in experiments API sandbox.

https://reviewboard.mozilla.org/r/124314/#review126932

r=me with comments addressed.

::: toolkit/components/extensions/ExtensionAPI.jsm:23
(Diff revision 1)
> +XPCOMUtils.defineLazyModuleGetter(this, "ConsoleAPI",
> +                                  "resource://gre/modules/Console.jsm");

Please keep imports sorted.

::: toolkit/components/extensions/ExtensionAPI.jsm:63
(Diff revision 1)
> +    // Create a console getter which lazily provide a ConsoleAPI instance.
> +    let experimentConsole;
> +    Object.defineProperty(api.sandbox, "console", {
> +      enumerable: true,
> +      get() {
> +        if (experimentConsole) {
> +          return experimentConsole;
> +        }
> +
> +        experimentConsole = new ConsoleAPI({
> +          prefix: addonId,
> +        });
> +
> +        return experimentConsole;
> +      },
> +    });

XPCOMUtils.defineLazyGetter(sandbox, console, () => new ConsoleAPI(...));
Attachment #8852074 - Flags: review?(kmaglione+bmo) → review+
Comment hidden (mozreview-request)
(Assignee)

Comment 4

9 months ago
mozreview-review-reply
Comment on attachment 8852074 [details]
Bug 1351381 - Provide a console API object in experiments API sandbox.

https://reviewboard.mozilla.org/r/124314/#review126932

> XPCOMUtils.defineLazyGetter(sandbox, console, () => new ConsoleAPI(...));

oh, yeah, that is even nicer! thanks!
(Assignee)

Updated

9 months ago
Assignee: nobody → lgreco
Status: NEW → ASSIGNED
(Assignee)

Updated

9 months ago
Keywords: checkin-needed

Comment 5

9 months ago
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/913d350950fa
Provide a console API object in experiments API sandbox. r=kmag
Keywords: checkin-needed

Comment 6

9 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/913d350950fa
Status: ASSIGNED → RESOLVED
Last Resolved: 9 months ago
status-firefox55: --- → fixed
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.