mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1199698 - [webext] Fix chrome.* from content scripts (r=gabor)
This commit is contained in:
parent
1c1fce4a9e
commit
828a74056a
@ -223,7 +223,10 @@ function ExtensionContext(extensionId, contentWindow)
|
||||
{id: extensionId, frameId}, delegate);
|
||||
|
||||
let chromeObj = Cu.createObjectIn(this.sandbox, {defineAs: "browser"});
|
||||
this.sandbox.wrappedJSObject.chrome = this.sandbox.wrappedJSObject.browser;
|
||||
|
||||
// Sandboxes don't get Xrays for some weird compatibility
|
||||
// reason. However, we waive here anyway in case that changes.
|
||||
Cu.waiveXrays(this.sandbox).chrome = Cu.waiveXrays(this.sandbox).browser;
|
||||
injectAPI(api(this), chromeObj);
|
||||
|
||||
this.onClose = new Set();
|
||||
|
@ -1,4 +1,9 @@
|
||||
browser.runtime.onMessage.addListener(([msg, expectedState, readyState], sender) => {
|
||||
if (msg == "chrome-namespace-ok") {
|
||||
browser.test.sendMessage(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
browser.test.assertEq(msg, "script-run", "message type is correct");
|
||||
browser.test.assertEq(readyState, expectedState, "readyState is correct");
|
||||
browser.test.sendMessage("script-run-" + expectedState);
|
||||
|
@ -0,0 +1 @@
|
||||
chrome.runtime.sendMessage(["chrome-namespace-ok"]);
|
@ -19,6 +19,11 @@
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"js": ["content_script_idle.js"],
|
||||
"run_at": "document_idle"
|
||||
},
|
||||
{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"js": ["content_script.js"],
|
||||
"run_at": "document_idle"
|
||||
}
|
||||
],
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
TESTING_JS_MODULES.extensions.content_script += [
|
||||
'background.js',
|
||||
'content_script.js',
|
||||
'content_script_end.js',
|
||||
'content_script_idle.js',
|
||||
'content_script_start.js',
|
||||
|
@ -28,6 +28,8 @@ add_task(function* test_contentscript()
|
||||
extension.onMessage("script-run-complete", () => { completeCount++; resolve(); });
|
||||
});
|
||||
|
||||
let chromeNamespacePromise = extension.awaitMessage("chrome-namespace-ok");
|
||||
|
||||
yield new Promise(resolve => { setTimeout(resolve, 0); });
|
||||
|
||||
let win = window.open();
|
||||
@ -36,7 +38,7 @@ add_task(function* test_contentscript()
|
||||
|
||||
ok(true, "page loaded");
|
||||
|
||||
yield Promise.all([waitForLoad(win), completePromise]);
|
||||
yield Promise.all([waitForLoad(win), completePromise, chromeNamespacePromise]);
|
||||
info("test page loaded");
|
||||
|
||||
win.close();
|
||||
|
Loading…
Reference in New Issue
Block a user