Bug 1199832 - [webext] browser.tabs.executeScript must create a context (r=gabor)

This commit is contained in:
Bill McCloskey 2015-08-28 16:00:40 -07:00
parent 6867e342f2
commit fdb75efced
3 changed files with 34 additions and 5 deletions

View File

@ -1,3 +1,4 @@
[browser_extensions_simple.js]
[browser_ext_tabs_executeScript.js]
[browser_ext_tabs_query.js]
[browser_ext_tabs_update.js]

View File

@ -0,0 +1,32 @@
add_task(function* () {
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/");
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"]
},
background: function() {
browser.runtime.onMessage.addListener((msg, sender) => {
browser.test.assertEq(msg, "script ran", "script ran");
browser.test.notifyPass("executeScript");
});
browser.tabs.executeScript({
file: "script.js"
});
},
files: {
"script.js": function() {
browser.runtime.sendMessage("script ran");
}
}
});
yield extension.startup();
yield extension.awaitFinish("executeScript");
yield extension.unload();
yield BrowserTestUtils.removeTab(tab);
});

View File

@ -336,11 +336,7 @@ let DocumentManager = {
executeScript(global, extensionId, script) {
let window = global.content;
let extensions = this.windows.get(window);
if (!extensions) {
return;
}
let context = extensions.get(extensionId);
let context = this.getContext(extensionId, window);
if (!context) {
return;
}