diff --git a/browser/components/extensions/ext-tabs.js b/browser/components/extensions/ext-tabs.js index 7ef95e9e60ab..a0cce53d921b 100644 --- a/browser/components/extensions/ext-tabs.js +++ b/browser/components/extensions/ext-tabs.js @@ -809,11 +809,11 @@ extensions.registerSchemaAPI("tabs", (extension, context) => { }, insertCSS: function(tabId, details) { - return self.tabs._execute(tabId, details, "css", "insertCSS"); + return self.tabs._execute(tabId, details, "css", "insertCSS").then(() => {}); }, removeCSS: function(tabId, details) { - return self.tabs._execute(tabId, details, "css", "removeCSS"); + return self.tabs._execute(tabId, details, "css", "removeCSS").then(() => {}); }, connect: function(tabId, connectInfo) { diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js index 29c67486d098..183ec07e42e8 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js @@ -21,7 +21,8 @@ add_task(function* testExecuteScript() { browser.tabs.executeScript({ code: "42", }).then(result => { - browser.test.assertEq(42, result, "Expected callback result"); + browser.test.assertEq(1, result.length, "Expected one callback result"); + browser.test.assertEq(42, result[0], "Expected callback result"); }), browser.tabs.executeScript({ @@ -37,13 +38,15 @@ add_task(function* testExecuteScript() { browser.tabs.executeScript({ file: "script.js", }).then(result => { - browser.test.assertEq(undefined, result, "Expected callback result"); + browser.test.assertEq(1, result.length, "Expected one callback result"); + browser.test.assertEq(undefined, result[0], "Expected callback result"); }), browser.tabs.executeScript({ file: "script2.js", }).then(result => { - browser.test.assertEq(27, result, "Expected callback result"); + browser.test.assertEq(1, result.length, "Expected one callback result"); + browser.test.assertEq(27, result[0], "Expected callback result"); }), browser.tabs.executeScript({ @@ -62,9 +65,10 @@ add_task(function* testExecuteScript() { code: "location.href;", runAt: "document_end", }).then(result => { - browser.test.assertTrue(typeof(result) == "string", "Result is a string"); + browser.test.assertEq(1, result.length, "Expected callback result"); + browser.test.assertEq("string", typeof result[0], "Result is a string"); - browser.test.assertTrue(/\/file_iframe_document\.html$/.test(result), "Result is correct"); + browser.test.assertTrue(/\/file_iframe_document\.html$/.test(result[0]), "Result is correct"); }), browser.tabs.executeScript({ @@ -118,7 +122,7 @@ add_task(function* testExecuteScript() { browser.tabs.executeScript({ code: "Promise.resolve(42)", }).then(result => { - browser.test.assertEq(42, result, "Got expected promise resolution value as result"); + browser.test.assertEq(42, result[0], "Got expected promise resolution value as result"); }), browser.tabs.executeScript({ @@ -138,19 +142,21 @@ add_task(function* testExecuteScript() { code: "location.href;", frameId: frames[0].frameId, }).then(result => { - browser.test.assertTrue(/\/file_iframe_document\.html$/.test(result), `Result for frameId[0] is correct: ${result}`); + browser.test.assertEq(1, result.length, "Expected one result"); + browser.test.assertTrue(/\/file_iframe_document\.html$/.test(result[0]), `Result for frameId[0] is correct: ${result[0]}`); }), browser.tabs.executeScript({ code: "location.href;", frameId: frames[1].frameId, }).then(result => { - browser.test.assertEq("http://mochi.test:8888/", result, "Result for frameId[1] is correct"); + browser.test.assertEq(1, result.length, "Expected one result"); + browser.test.assertEq("http://mochi.test:8888/", result[0], "Result for frameId[1] is correct"); }), browser.tabs.create({url: "http://example.com/"}).then(tab => { return browser.tabs.executeScript(tab.id, {code: "location.href"}).then(result => { - browser.test.assertEq("http://example.com/", result, "Script executed correctly in new tab"); + browser.test.assertEq("http://example.com/", result[0], "Script executed correctly in new tab"); return browser.tabs.remove(tab.id); }); diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js b/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js index 20123f45d1a6..6a2101c3c8ae 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js @@ -49,7 +49,7 @@ add_task(function* testExecuteScript() { return browser.tabs.executeScript({ code: `(${checkCSS})()`, }); - }).then(result => { + }).then(([result]) => { browser.test.assertEq(background, result[0], "Expected background color"); browser.test.assertEq(foreground, result[1], "Expected foreground color"); return next(); diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_reload_bypass_cache.js b/browser/components/extensions/test/browser/browser_ext_tabs_reload_bypass_cache.js index 231718f51f34..640710d36b51 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_reload_bypass_cache.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_reload_bypass_cache.js @@ -33,14 +33,14 @@ add_task(function* () { return awaitLoad(tabId); }).then(() => { return browser.tabs.executeScript(tabId, {code: "document.body.textContent"}); - }).then(textContent => { + }).then(([textContent]) => { browser.test.assertEq("", textContent, "`textContent` should be empty when bypassCache=false"); return browser.tabs.reload(tabId, {bypassCache: true}); }).then(() => { return awaitLoad(tabId); }).then(() => { return browser.tabs.executeScript(tabId, {code: "document.body.textContent"}); - }).then(textContent => { + }).then(([textContent]) => { let [pragma, cacheControl] = textContent.split(":"); browser.test.assertEq("no-cache", pragma, "`pragma` should be set to `no-cache` when bypassCache is true"); browser.test.assertEq("no-cache", cacheControl, "`cacheControl` should be set to `no-cache` when bypassCache is true"); diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_removeCSS.js b/browser/components/extensions/test/browser/browser_ext_tabs_removeCSS.js index bcaafb2d1159..c4bb9a753319 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_removeCSS.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_removeCSS.js @@ -66,7 +66,7 @@ add_task(function* testExecuteScript() { return browser.tabs.executeScript({ code: `(${checkCSS})()`, }); - }).then(result => { + }).then(([result]) => { browser.test.assertEq(background, result[0], "Expected background color"); browser.test.assertEq(foreground, result[1], "Expected foreground color"); return next(); diff --git a/toolkit/components/extensions/ExtensionContent.jsm b/toolkit/components/extensions/ExtensionContent.jsm index 6fa31a45a341..0bdeaca25c31 100644 --- a/toolkit/components/extensions/ExtensionContent.jsm +++ b/toolkit/components/extensions/ExtensionContent.jsm @@ -614,13 +614,10 @@ DocumentManager = { return Promise.reject({message: `No window matching ${JSON.stringify(details)}`}); } - if (options.all_frames) { - return Promise.all(promises); - } - if (promises.length > 1) { + if (!options.all_frames && promises.length > 1) { return Promise.reject({message: `Internal error: Script matched multiple windows`}); } - return promises[0]; + return Promise.all(promises); }, enumerateWindows: function* (docShell) {