diff --git a/browser/components/extensions/test/browser/browser.ini b/browser/components/extensions/test/browser/browser.ini index 40cf27f9a6ee..f159e5f71054 100644 --- a/browser/components/extensions/test/browser/browser.ini +++ b/browser/components/extensions/test/browser/browser.ini @@ -1,3 +1,4 @@ [browser_extensions_simple.js] +[browser_ext_tabs_executeScript.js] [browser_ext_tabs_query.js] [browser_ext_tabs_update.js] diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js new file mode 100644 index 000000000000..6a13fd57befe --- /dev/null +++ b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js @@ -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); +}); diff --git a/toolkit/components/extensions/ExtensionContent.jsm b/toolkit/components/extensions/ExtensionContent.jsm index 3b9806397b55..c66b49e19e0a 100644 --- a/toolkit/components/extensions/ExtensionContent.jsm +++ b/toolkit/components/extensions/ExtensionContent.jsm @@ -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; }