Closed Bug 1268399 Opened 8 years ago Closed 7 years ago

Add runtime.getBrowserInfo() method with AppInfo data


(WebExtensions :: Untriaged, defect)

Not set


(firefox49 wontfix, firefox50 wontfix, firefox51 fixed)

Tracking Status
firefox49 --- wontfix
firefox50 --- wontfix
firefox51 --- fixed


(Reporter: yuki, Assigned: zombie, Mentored)


(Depends on 1 open bug)


(Keywords: dev-doc-complete, Whiteboard: [design-decision-approved]triaged)


(1 file)

When I tried to migrate my addon "Only Minor Update" to WebExtensions, I realized that there are too few information under "chrome.PlatformInfo".

The addon downloads Firefox's update information internally and blocks it if it includes a major update (like Firefox 38 to 45), to allow Firefox to apply only security fixes. The addon tries to complete the URL from "app.update.url" like "".
In XUL-based addons we can use nsIURLFormatter ( ) but currently there is no alternative in WebExtensions.

Otherwise, I simply need a new option of Firefox itself to ignore major update and apply only security fixes.
Whiteboard: [design-decision-needed]triaged
Adding more information to chrome.PlatformInfo seemed ok to most people in the meeting, this also seems like a reasonably good first bug.
Whiteboard: [design-decision-needed]triaged → [design-decision-approved]triaged[good-first-bug]
Whiteboard: [design-decision-approved]triaged[good-first-bug] → [design-decision-approved]triaged[good first bug]
Mentor: aswan
Keywords: good-first-bug
Whiteboard: [design-decision-approved]triaged[good first bug] → [design-decision-approved]triaged
Assignee: nobody → tomica
It's probably worth noting that WebExtensions don't have the ability to block app updates, regardless of whether they have access to this information.
I was unsure about exactly what fields to include, and about the naming, so I played it safe, and went with what Jetpack exposed from AppInfo service, and with the "app" prefix for the properties (since it's exported through *Platform*Info).
Attachment #8788000 - Flags: review?(aswan)
Comment on attachment 8788000 [details]
bug 1268399 - add runtime.getBrowserInfo() method with AppInfo data

The code itself looks good here, but I think it would make more sense to add a new runtime.getAppInfo() method rather than putting this into PlatformInfo.
That means modifying the api schema for runtime, the actual code should be straightforward.
Attachment #8788000 - Flags: review?(aswan)
I thought about that, but remembered that Chrome extension docs are intertwined with mentions of "Chrome web apps" (which use the same manifest and a lot of the same APIs), so a method named getAppInfo() might be even more confusing.

I understand "Web Extensions" != "Chrome Extensions", but that's still rather unfortunate..

Perhaps an AppInfo key under PlatformInfo makes it clearer what "app" it is referring to? Or something else?
Comment on attachment 8788000 [details]
bug 1268399 - add runtime.getBrowserInfo() method with AppInfo data

Looks good, but it would be nice if the test were more explicit.

::: toolkit/components/extensions/ext-runtime.js:82
(Diff revision 4)
>        },
> +      getBrowserInfo: function() {
> +        const {name, vendor, version, appBuildID} = Services.appinfo;
> +        const info = {name, vendor, version, buildID: appBuildID};
> +        return Promise.resolve(Object.freeze(info));

No need to `Object.freeze` this.

::: toolkit/components/extensions/schemas/runtime.json:95
(Diff revision 4)
>          }
>        },
>        {
> +        "id": "BrowserInfo",
> +        "type": "object",
> +        "restrictions": ["content"],

This shouldn't be necessary.

::: toolkit/components/extensions/test/xpcshell/test_ext_runtime_getBrowserInfo.js:5
(Diff revision 4)
> +add_task(function* mock() {
> +  const {updateAppInfo} = Cu.import("resource://testing-common/AppInfo.jsm", {});
> +  updateAppInfo();
> +});

We should set these to specific values, and check those actual values in the test. It might be best to move the AppInfo setup in `ExtensionXPCShellUtils.jsm` from `startAddonManager` to its own method, and then just test against those values.

::: toolkit/components/extensions/test/xpcshell/test_ext_runtime_getBrowserInfo.js:10
(Diff revision 4)
> +add_task(function* mock() {
> +  const {updateAppInfo} = Cu.import("resource://testing-common/AppInfo.jsm", {});
> +  updateAppInfo();
> +});
> +
> +function background() {

Please move this to the task.

::: toolkit/components/extensions/test/xpcshell/test_ext_runtime_getBrowserInfo.js:24
(Diff revision 4)
> +
> +    browser.test.notifyPass("runtime.getBrowserInfo");
> +  });
> +}
> +
> +add_task(function* test_contentscript() {

The test function name doesn't seem very relevant.
Summary: Add more information for "chrome.PlatformInfo" to fill placeholders of "app.update.url" → Add runtime.getBrowserInfo() method with AppInfo data
Comment on attachment 8788000 [details]
bug 1268399 - add runtime.getBrowserInfo() method with AppInfo data

Looks good. Thanks!
Attachment #8788000 - Flags: review+
No longer blocks: fx-enterprise
Keywords: dev-doc-needed
Attachment #8788000 - Flags: review?(aswan)
has problems to apply:

applying 6a4a3bd26229
patching file toolkit/components/extensions/test/xpcshell/xpcshell.ini
Hunk #1 FAILED at 37
1 out of 1 hunks FAILED -- saving rejects to file toolkit/components/extensions/test/xpcshell/xpcshell.ini.rej
patch failed to apply
abort: fix up the working directory and run hg transplant --continue
Flags: needinfo?(tomica)
Pushed by
add runtime.getBrowserInfo() method with AppInfo data r=kmag
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
it looks like it got landed after all.
Flags: needinfo?(tomica)
Wontfix for 49, could still take this in 50 if it is necessary. But if it can ride with 51, great.
I don't think this needs to be in 50.
New page for getBrowserInfo:

Does this cover it, :zombie?
Flags: needinfo?(tomica)
Yes, thanks Will.
Flags: needinfo?(tomica)
Depends on: 1389751
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.