Closed
Bug 1276338
Opened 8 years ago
Closed 8 years ago
chrome.runtime.id is undefined in content scripts
Categories
(WebExtensions :: Untriaged, defect)
Tracking
(firefox49 fixed)
Tracking | Status | |
---|---|---|
firefox49 | --- | fixed |
People
(Reporter: serge.zarembsky, Assigned: bsilverberg)
Details
(Whiteboard: [runtime]triaged)
Attachments
(1 file)
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36 Steps to reproduce: While porting our (Ghostery) code written for Chrome to Nightly build 49 with Web Extesions API support we noticed that in context script chrome.runtime.id is undefined. It is properly defined when accessed in background.js or extension popup scripts. Actual results: chrome.runtime.id is undefined Expected results: chrome.runtime.id should be equal to our extension id specified in the manifest under this key: "applications": { "gecko": { "id": "ghostery@ghostery.com" }
Assignee | ||
Comment 1•8 years ago
|
||
The code in `ExtensionContent.jsm` confirms that we do not provide this value to content scripts, and the Chrome docs do state that it is available to content scripts [2], so it sounds like something we should support. Do others agree? [1] https://dxr.mozilla.org/mozilla-central/source/toolkit/components/extensions/ExtensionContent.jsm#71 [2] https://developer.chrome.com/extensions/runtime
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: chrome.runtime.id is undefined in context scripts → chrome.runtime.id is undefined in content scripts
Whiteboard: [runtime]triaged
Comment 2•8 years ago
|
||
Agreed, with the minor point that it is the id of the addon stored in the addons manager, which may not correspond directly to the manifest if its absent from the manifest.
Assignee | ||
Comment 3•8 years ago
|
||
Thanks Andy. This is a very easy fix so I'm just going to bang it off.
Assignee: nobody → bob.silverberg
Status: NEW → ASSIGNED
Iteration: --- → 49.3 - Jun 6
Comment 4•8 years ago
|
||
+1
Assignee | ||
Comment 5•8 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/56634/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/56634/
Attachment #8758402 -
Flags: review?(kmaglione+bmo)
Comment 6•8 years ago
|
||
Comment on attachment 8758402 [details] MozReview Request: Bug 1276338 - chrome.runtime.id is undefined in content scripts, r?kmag https://reviewboard.mozilla.org/r/56634/#review53304 ::: toolkit/components/extensions/test/mochitest/test_ext_runtime_id.html:47 (Diff revision 1) > + yield extension.startup(); > + > + let backgroundId = yield extension.awaitMessage("background-id"); > + let win = window.open("file_sample.html"); > + let contentId = yield extension.awaitMessage("content-id"); > + is(backgroundId, contentId, "runtime.id from background script matches id from content script"); We should check that they're both the same as the extension ID, not just that they're the same. You can pass an ID as the second argument of `loadExtension`
Attachment #8758402 -
Flags: review?(kmaglione+bmo)
Assignee | ||
Comment 7•8 years ago
|
||
Comment on attachment 8758402 [details] MozReview Request: Bug 1276338 - chrome.runtime.id is undefined in content scripts, r?kmag Review request updated; see interdiff: https://reviewboard.mozilla.org/r/56634/diff/1-2/
Attachment #8758402 -
Flags: review?(kmaglione+bmo)
Assignee | ||
Comment 8•8 years ago
|
||
https://reviewboard.mozilla.org/r/56634/#review53304 > We should check that they're both the same as the extension ID, not just that they're the same. > > You can pass an ID as the second argument of `loadExtension` Nice! I did not know that.
Comment 9•8 years ago
|
||
Comment on attachment 8758402 [details] MozReview Request: Bug 1276338 - chrome.runtime.id is undefined in content scripts, r?kmag https://reviewboard.mozilla.org/r/56634/#review53654 Looks good. Thanks!
Attachment #8758402 -
Flags: review?(kmaglione+bmo) → review+
Assignee | ||
Comment 10•8 years ago
|
||
https://treeherder.mozilla.org/#/jobs?repo=try&revision=7f8ac0527d59
Assignee | ||
Updated•8 years ago
|
Keywords: checkin-needed
Comment 11•8 years ago
|
||
Pushed by cbook@mozilla.com: https://hg.mozilla.org/integration/fx-team/rev/1b67bc89fe9a chrome.runtime.id is undefined in content scripts, r=kmag
Keywords: checkin-needed
Comment 12•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/1b67bc89fe9a
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
Updated•6 years ago
|
Product: Toolkit → WebExtensions
You need to log in
before you can comment on or make changes to this bug.
Description
•