author | Rob Wu <rob@robwu.nl> |
Sun, 28 Aug 2016 17:22:03 -0700 | |
changeset 312176 | d316aa33106d4b9ad5fce1e89d8818efad79e141 |
parent 312175 | 0e36be603b70f1f2c05baa833309244ef82d19e8 |
child 312177 | 6658a683e292b3ef5fcc94ae7f185c78c3078299 |
push id | 31910 |
push user | ryanvm@gmail.com |
push date | Thu, 01 Sep 2016 02:44:38 +0000 |
treeherder | autoland@d316aa33106d [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | billm |
bugs | 1298716 |
milestone | 51.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/mobile/android/components/extensions/test/mochitest/test_ext_pageAction.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_pageAction.html @@ -13,17 +13,17 @@ <script type="text/javascript"> "use strict"; let dataURI = "iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAC4klEQVRYhdWXLWzbQBSADQtDAwsHC1tUhUxqfL67lk2tdn+OJg0ODU0rLByqgqINBY6tmlbn7LMTJ5FaFVVBk1G0oUGjG2jT2Y7jxmmcbU/6iJ+f36fz+e5sGP9riCGm9hB37RG+scd4Yo/wsDXCZyIE2xuXsce4bY+wXkAsQtzYmExrfFgvkJkRbkzo1ehoxx5iXcgI/9iYUGt8WH9MqDXEcmNChmEYrRCf2SHWeYgQx3x0tLNRIeKQLTtEFyJEep4NTuhk8BC+yMrwEE3+iozo42d8gK7FAOkMsRiiN8QhW2ttSK5QTfRRV4QoymVeJMvPvDp7gCZigD613MN6yRFA3SWarow9QB9LCfG+NeF9qCtjAKOSQjCqVKhfVsiHEQ+grgx/lRGqUihAc1uL8EFD+KCRO+GrF4J61phcoRoPoEzkYhZYpykh5sMb7kOdIeY+jHKur4QI4Feh4AFX1nVeLxrAvQchGsBz5ls6wa2QdwcvIcE2863bTH79KOvsz/uUYJsp+J0pSzNlDckVqqVGUAF+n6uS7txcOl6wot4JVy70ufDLy4pWLUQVPE81pRI0mGe9oxLMHSeohHvMs/STUNaUK6vDPCvOyxMFDx4achehRDJmHnydnkPww5OFfLxrGIZBFDyYl4LpMzlTQFIP6AQx86w2UeYBccFpJrcKv5L9eGDtUAU6RIELqsB74uynjy/UBRF1gS5BTFxwQT1wTiXoUg9MH7m/3NZRRoi5IJytUbMgzv4Wc832+oQkiKgEehmyMkkpKsFkQV11QsRJL5rJYBLItQgRaUZEmnoZXsomz3vGiWw+I9KMF9SVFOqZEemZekli1jN3U/UOqhHHvC6oWWGElhfSpGdOk6+O9prdwvtLj5BjRsQxdRnot+Zeifpy/2/0stktKTRNLmbk0mwXyl8253fyojj+8rxOHNAhjjm5n0/5OOCGOKBzkrMO0Z75lvSAzKlrF32Z/3z8BqLAn+yMV7VhAAAAAElFTkSuQmCC"; let image = atob(dataURI); const IMAGE_ARRAYBUFFER = Uint8Array.from(image, byte => byte.charCodeAt(0)).buffer; -function backgroundScript() { +function background() { browser.test.assertTrue("pageAction" in browser, "Namespace 'pageAction' exists in browser"); browser.test.assertTrue("show" in browser.pageAction, "API method 'show' exists in browser.pageAction"); // TODO: Use the Tabs API to obtain the tab ids for showing pageActions. let tabId = 1; browser.test.onMessage.addListener(msg => { if (msg === "pageAction-show") { browser.pageAction.show(tabId).then(() => { @@ -41,17 +41,17 @@ function backgroundScript() { browser.test.sendMessage("page-action-clicked"); }); browser.test.sendMessage("ready"); } add_task(function* test_contentscript() { let extension = ExtensionTestUtils.loadExtension({ - background: "(" + backgroundScript.toString() + ")()", + background, manifest: { "name": "PageAction Extension", "page_action": { "default_title": "Page Action", "default_icon": { "18": "extension.png", }, },
--- a/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_popup.html +++ b/mobile/android/components/extensions/test/mochitest/test_ext_pageAction_popup.html @@ -16,17 +16,17 @@ Cu.import("resource://gre/modules/Services.jsm"); let dataURI = "iVBORw0KGgoAAAANSUhEUgAAACQAAAAkCAYAAADhAJiYAAAC4klEQVRYhdWXLWzbQBSADQtDAwsHC1tUhUxqfL67lk2tdn+OJg0ODU0rLByqgqINBY6tmlbn7LMTJ5FaFVVBk1G0oUGjG2jT2Y7jxmmcbU/6iJ+f36fz+e5sGP9riCGm9hB37RG+scd4Yo/wsDXCZyIE2xuXsce4bY+wXkAsQtzYmExrfFgvkJkRbkzo1ehoxx5iXcgI/9iYUGt8WH9MqDXEcmNChmEYrRCf2SHWeYgQx3x0tLNRIeKQLTtEFyJEep4NTuhk8BC+yMrwEE3+iozo42d8gK7FAOkMsRiiN8QhW2ttSK5QTfRRV4QoymVeJMvPvDp7gCZigD613MN6yRFA3SWarow9QB9LCfG+NeF9qCtjAKOSQjCqVKhfVsiHEQ+grgx/lRGqUihAc1uL8EFD+KCRO+GrF4J61phcoRoPoEzkYhZYpykh5sMb7kOdIeY+jHKur4QI4Feh4AFX1nVeLxrAvQchGsBz5ls6wa2QdwcvIcE2863bTH79KOvsz/uUYJsp+J0pSzNlDckVqqVGUAF+n6uS7txcOl6wot4JVy70ufDLy4pWLUQVPE81pRI0mGe9oxLMHSeohHvMs/STUNaUK6vDPCvOyxMFDx4achehRDJmHnydnkPww5OFfLxrGIZBFDyYl4LpMzlTQFIP6AQx86w2UeYBccFpJrcKv5L9eGDtUAU6RIELqsB74uynjy/UBRF1gS5BTFxwQT1wTiXoUg9MH7m/3NZRRoi5IJytUbMgzv4Wc832+oQkiKgEehmyMkkpKsFkQV11QsRJL5rJYBLItQgRaUZEmnoZXsomz3vGiWw+I9KMF9SVFOqZEemZekli1jN3U/UOqhHHvC6oWWGElhfSpGdOk6+O9prdwvtLj5BjRsQxdRnot+Zeifpy/2/0stktKTRNLmbk0mwXyl8253fyojj+8rxOHNAhjjm5n0/5OOCGOKBzkrMO0Z75lvSAzKlrF32Z/3z8BqLAn+yMV7VhAAAAAElFTkSuQmCC"; let image = atob(dataURI); const IMAGE_ARRAYBUFFER = Uint8Array.from(image, byte => byte.charCodeAt(0)).buffer; add_task(function* test_contentscript() { - function backgroundScript() { + function background() { // TODO: Use the Tabs API to obtain the tab ids for showing pageActions. let tabId = 1; let onClickedListenerEnabled = false; browser.test.onMessage.addListener((msg, details) => { if (msg === "page-action-show") { // TODO: switch to using .show(tabId).then(...) once bug 1270742 lands. browser.pageAction.show(tabId).then(() => { @@ -66,33 +66,33 @@ add_task(function* test_contentscript() if (details.location == location.href) { window.close(); } } }); } let extension = ExtensionTestUtils.loadExtension({ - background: `(${backgroundScript}())`, + background, manifest: { "name": "PageAction Extension", "page_action": { "default_title": "Page Action", "default_popup": "default.html", "default_icon": { "18": "extension.png", }, }, }, files: { - "default.html": `<html><head><meta charset="utf-8"><script src="popup.js"></${"script"}></head></html>`, + "default.html": `<html><head><meta charset="utf-8"><script src="popup.js"><\/script></head></html>`, "extension.png": IMAGE_ARRAYBUFFER, - "a.html": `<html><head><meta charset="utf-8"><script src="popup.js"></${"script"}></head></html>`, - "b.html": `<html><head><meta charset="utf-8"><script src="popup.js"></${"script"}></head></html>`, - "popup.js": `(${popupScript})()`, + "a.html": `<html><head><meta charset="utf-8"><script src="popup.js"><\/script></head></html>`, + "b.html": `<html><head><meta charset="utf-8"><script src="popup.js"><\/script></head></html>`, + "popup.js": popupScript, }, }); let tabClosedPromise = () => { return new Promise(resolve => { let chromeWin = Services.wm.getMostRecentWindow("navigator:browser"); let BrowserApp = chromeWin.BrowserApp;
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_background_debug_global.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_background_debug_global.html @@ -24,29 +24,28 @@ const { /** * This test is asserting that ext-backgroundPage.js successfully sets its * debug global in the AddonWrapper provided by XPIProvider.jsm * * It does _not_ test any functionality in devtools and does not guarantee * debugging is actually working correctly end-to-end. */ -function backgroundScript() { +function background() { window.testThing = "test!"; browser.test.notifyPass("background script ran"); } const ID = "debug@tests.mozilla.org"; let extensionData = { useAddonManager: "temporary", - background: "(" + backgroundScript.toString() + ")()", + background, manifest: { applications: {gecko: {id: ID}}, }, - files: {}, }; add_task(function* () { let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); yield extension.awaitFinish("background script ran");
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_background_page.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_background_page.html @@ -21,17 +21,17 @@ Cu.import("resource://testing-common/Tes add_task(function* testAlertNotShownInBackgroundWindow() { ok(!Services.wm.getEnumerator("alert:alert").hasMoreElements(), "Alerts should not be present at the start of the test."); let consoleOpened = TestUtils.topicObserved("web-console-created"); let extension = ExtensionTestUtils.loadExtension({ - background: "new " + function() { + background: function() { browser.test.log("background script executed"); alert("I am an alert in the background."); browser.test.notifyPass("alertCalled"); }, });
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_contentscript_unrecognizedprop_warning.html @@ -12,17 +12,17 @@ <body> <script type="text/javascript"> "use strict"; const BASE = "http://mochi.test:8888/chrome/toolkit/components/extensions/test/mochitest"; add_task(function* test_contentscript() { - function backgroundScript() { + function background() { browser.runtime.onMessage.addListener((msg) => { if (msg == "loaded") { browser.tabs.query({active: true, currentWindow: true}).then((tabs) => { // NOTE: we're removing the tab from here because doing a win.close() // from the chrome test code is raising a "TypeError: can 't access // dead object" exception. browser.tabs.remove(tabs[0].id); @@ -42,20 +42,20 @@ add_task(function* test_contentscript() { "matches": ["http://mochi.test/*/file_sample.html"], "js": ["content_script.js"], "run_at": "document_idle", "unrecognized_property": "with-a-random-value", }, ], }, - background: "(" + backgroundScript.toString() + ")()", + background, files: { - "content_script.js": "(" + contentScript.toString() + ")()", + "content_script.js": contentScript, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); SimpleTest.waitForExplicitFinish(); let waitForConsole = new Promise(resolve => { SimpleTest.monitorConsole(resolve, [{
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_eventpage_warning.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_eventpage_warning.html @@ -20,20 +20,20 @@ function createEventPageExtension(eventP browser.test.sendMessage("running", 1); } return ExtensionTestUtils.loadExtension({ manifest: { "background": eventPage, }, files: { - "event-page-script.js": `(${eventPageScript})()`, + "event-page-script.js": eventPageScript, "event-page.html": `<html><head> <meta charset="utf-8"> - <script src="event-page-script.js"></${"script"}> + <script src="event-page-script.js"><\/script> </head></html>`, }, }); } add_task(function* test_eventpages() { // Used in other tests to prevent the monitorConsole to grip. SimpleTest.waitForExplicitFinish();
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_shutdown_cleanup.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_shutdown_cleanup.html @@ -22,17 +22,17 @@ const {GlobalManager} = Cu.import("resou /* eslint-disable mozilla/balanced-listeners */ add_task(function* testShutdownCleanup() { is(GlobalManager.initialized, false, "GlobalManager start as not initialized"); let extension = ExtensionTestUtils.loadExtension({ - background: "new " + function() { + background: function() { browser.test.notifyPass("background page loaded"); }, }); yield extension.startup(); yield extension.awaitFinish("background page loaded");
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_storage_cleanup.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_storage_cleanup.html @@ -101,17 +101,17 @@ add_task(function* test_uninstall() { yield SpecialPowers.pushPrefEnv({ set: [["extensions.webextensions.keepUuidOnUninstall", true]], }); yield SpecialPowers.pushPrefEnv({ set: [["extensions.webextensions.keepStorageOnUninstall", true]], }); let extension = ExtensionTestUtils.loadExtension({ - background: `(${writeData})()`, + background: writeData, manifest: { applications: {gecko: {id: ID}}, permissions: ["storage"], }, useAddonManager: "temporary", }); yield extension.startup(); @@ -120,17 +120,17 @@ add_task(function* test_uninstall() { // Check that we can still see data we wrote to storage but clear the // "leave storage" flag so our storaged gets cleared on uninstall. // This effectively tests the keepUuidOnUninstall logic, which ensures // that when we read storage again and check that it is cleared, that // it is actually a meaningful test! yield SpecialPowers.popPrefEnv(); extension = ExtensionTestUtils.loadExtension({ - background: `(${readData})()`, + background: readData, manifest: { applications: {gecko: {id: ID}}, permissions: ["storage"], }, useAddonManager: "temporary", }); yield extension.startup(); @@ -138,17 +138,17 @@ add_task(function* test_uninstall() { is(results.matchLocalStorage, true, "localStorage data is still present"); is(results.matchIDB, true, "indexedDB data is still present"); is(results.matchBrowserStorage, true, "browser.storage.local data is still present"); yield extension.unload(); // Read again. This time, our data should be gone. extension = ExtensionTestUtils.loadExtension({ - background: `(${readData})()`, + background: readData, manifest: { applications: {gecko: {id: ID}}, permissions: ["storage"], }, useAddonManager: "temporary", }); yield extension.startup();
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_trustworthy_origin.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_trustworthy_origin.html @@ -20,23 +20,22 @@ Cu.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyServiceGetter(this, "gContentSecurityManager", "@mozilla.org/contentsecuritymanager;1", "nsIContentSecurityManager"); add_task(function* () { - function backgroundScript() { + function background() { browser.test.sendMessage("ready", browser.runtime.getURL("/test.html")); } let extensionData = { - background: "(" + backgroundScript.toString() + ")()", - manifest: {}, + background, files: { "test.html": `<html><head></head><body></body></html>`, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup();
--- a/toolkit/components/extensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_webnavigation_resolved_urls.html @@ -10,17 +10,17 @@ <link rel="stylesheet" href="chrome://mochikit/contents/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; add_task(function* webnav_unresolved_uri_on_expected_URI_scheme() { - function backgroundScript() { + function background() { let checkURLs; browser.webNavigation.onCompleted.addListener((msg) => { if (checkURLs.length > 0) { let expectedURL = checkURLs.shift(); browser.test.assertEq(expectedURL, msg.url, "Got the expected URL"); browser.tabs.remove(msg.tabId).then(() => { browser.test.sendMessage("next"); @@ -38,17 +38,17 @@ add_task(function* webnav_unresolved_uri } let extensionData = { manifest: { permissions: [ "webNavigation", ], }, - background: "new " + backgroundScript, + background, files: { "tab.html": `<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> </html> `,
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_api_injection.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_background_api_injection.html @@ -10,17 +10,17 @@ </head> <body> <script type="text/javascript"> "use strict"; add_task(function* testBackgroundWindow() { let extension = ExtensionTestUtils.loadExtension({ - background: "new " + function() { + background: function() { const BASE = "http://mochi.test:8888/tests/toolkit/components/extensions/test/mochitest"; browser.test.log("background script executed"); window.location = `${BASE}/file_privilege_escalation.html`; }, }); let awaitConsole = new Promise(resolve => {
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_canvas.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_background_canvas.html @@ -27,17 +27,17 @@ add_task(function* test_background_canva browser.test.notifyPass("background-canvas"); } catch (e) { browser.test.fail(`Error: ${e} :: ${e.stack}`); browser.test.notifyFail("background-canvas"); } } let extensionData = { - background: `(${background})()`, + background, }; let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); yield extension.awaitFinish("background-canvas"); yield extension.unload(); });
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_generated_url.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_background_generated_url.html @@ -22,17 +22,17 @@ add_task(function* test_url_of_generated let extension = ExtensionTestUtils.loadExtension({ manifest: { background: { scripts: ["bg.js"], }, web_accessible_resources: ["_generated_background_page.html"], }, files: { - "bg.js": `(${backgroundScript})();`, + "bg.js": backgroundScript, }, }); yield extension.startup(); const EXPECTED_URL = yield extension.awaitMessage("script done"); let win = window.open(EXPECTED_URL); ok(win, "Should open new tab at URL: " + EXPECTED_URL);
--- a/toolkit/components/extensions/test/mochitest/test_ext_background_teardown.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_background_teardown.html @@ -9,30 +9,30 @@ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"> </head> <body> <script> "use strict"; add_task(function* test_background_reload_and_unload() { - function backgroundScript() { + function background() { browser.test.onMessage.addListener(msg => { browser.test.assertEq("reload-background", msg); location.reload(); }); browser.test.sendMessage("background-url", location.href); } let chromeScript = SpecialPowers.loadChromeScript( SimpleTest.getTestFileURL("file_teardown_test.js")); yield chromeScript.promiseOneMessage("chromescript-startup"); let extensionData = { - background: `(${backgroundScript})();`, + background, }; let extension = ExtensionTestUtils.loadExtension(extensionData); function* getContextEvents() { chromeScript.sendAsyncMessage("get-context-events"); let contextEvents = yield chromeScript.promiseOneMessage("context-events"); return contextEvents.filter(event => event.extensionId == extension.id); }
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript.html @@ -9,17 +9,17 @@ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; add_task(function* test_contentscript() { - function backgroundScript() { + function background() { 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"); @@ -64,23 +64,23 @@ add_task(function* test_contentscript() }, { "matches": ["http://mochi.test/*/file_sample.html"], "js": ["content_script.js"], "run_at": "document_idle", }, ], }, - background: "(" + backgroundScript.toString() + ")()", + background, files: { - "content_script_start.js": "(" + contentScriptStart.toString() + ")()", - "content_script_end.js": "(" + contentScriptEnd.toString() + ")()", - "content_script_idle.js": "(" + contentScriptIdle.toString() + ")()", - "content_script.js": "(" + contentScript.toString() + ")()", + "content_script_start.js": contentScriptStart, + "content_script_end.js": contentScriptEnd, + "content_script_idle.js": contentScriptIdle, + "content_script.js": contentScript, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); let loadingCount = 0; let interactiveCount = 0; let completeCount = 0;
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_api_injection.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_api_injection.html @@ -47,18 +47,18 @@ add_task(function* test_contentscript_ap }, ], "web_accessible_resources": [ "content_script_iframe.html", ], }, files: { - "content_script.js": "new " + contentScript, - "content_script_iframe.js": "new " + contentScriptIframe, + "content_script.js": contentScript, + "content_script_iframe.js": contentScriptIframe, "content_script_iframe.html": document.querySelector("#test-asset").textContent, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); let awaitConsole = new Promise(resolve => { let chromeScript = SpecialPowers.loadChromeScript(
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_context.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_context.html @@ -31,17 +31,17 @@ add_task(function* test_contentscript_co manifest: { content_scripts: [{ "matches": ["http://example.com/"], "js": ["content_script.js"], }], }, files: { - "content_script.js": `(${contentScript})()`, + "content_script.js": contentScript, }, }); yield extension.startup(); let win = window.open("http://example.com/"); yield extension.awaitMessage("content-script-ready"); yield extension.awaitMessage("content-script-show");
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_create_iframe.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_create_iframe.html @@ -20,17 +20,17 @@ </head> </html> </textarea> <script type="text/javascript"> "use strict"; add_task(function* test_contentscript_create_iframe() { - function backgroundScript() { + function background() { browser.runtime.onMessage.addListener((msg, sender) => { let {name, availableAPIs, manifest, testGetManifest} = msg; let hasExtTabsAPI = availableAPIs.indexOf("tabs") > 0; let hasExtWindowsAPI = availableAPIs.indexOf("windows") > 0; browser.test.assertFalse(hasExtTabsAPI, "the created iframe should not be able to use privileged APIs (tabs)"); browser.test.assertFalse(hasExtWindowsAPI, "the created iframe should not be able to use privileged APIs (windows)"); @@ -92,22 +92,22 @@ add_task(function* test_contentscript_cr "run_at": "document_idle", }, ], web_accessible_resources: [ "content_script_iframe.html", ], }, - background: "(" + backgroundScript + ")()", + background, files: { - "content_script.js": "new " + contentScript, + "content_script.js": contentScript, "content_script_iframe.html": document.querySelector("#test-asset").textContent, - "content_script_iframe.js": "new " + contentScriptIframe, + "content_script_iframe.js": contentScriptIframe, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); let contentScriptIframeCreatedPromise = new Promise(resolve => { extension.onMessage("content-script-iframe-loaded", () => { resolve(); }); });
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_devtools_metadata.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_devtools_metadata.html @@ -13,17 +13,17 @@ <script type="text/javascript"> "use strict"; add_task(function* test_contentscript_devtools_sandbox_metadata() { function contentScript() { browser.runtime.sendMessage("contentScript.executed"); } - function backgroundScript() { + function background() { browser.runtime.onMessage.addListener((msg) => { if (msg == "contentScript.executed") { browser.test.notifyPass("contentScript.executed"); } }); } let extensionData = { @@ -32,19 +32,19 @@ add_task(function* test_contentscript_de { "matches": ["http://mochi.test/*/file_sample.html"], "js": ["content_script.js"], "run_at": "document_idle", }, ], }, - background: "new " + backgroundScript, + background, files: { - "content_script.js": "new " + contentScript, + "content_script.js": contentScript, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); let win = window.open("file_sample.html");
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_exporthelpers.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_exporthelpers.html @@ -69,17 +69,17 @@ add_task(function* test_contentscript_ex content_scripts: [{ js: ["contentscript.js"], matches: ["http://mochi.test/*/file_sample.html"], run_at: "document_start", }], }, files: { - "contentscript.js": `(${contentScript})();`, + "contentscript.js": contentScript, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); let win = window.open("file_sample.html");
--- a/toolkit/components/extensions/test/mochitest/test_ext_contentscript_teardown.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_contentscript_teardown.html @@ -12,36 +12,36 @@ <script> "use strict"; add_task(function* test_contentscript_reload_and_unload() { function contentScript() { browser.test.sendMessage("contentscript-run"); } - function backgroundScript() { + function background() { let removedTabs = 0; browser.tabs.onRemoved.addListener(() => { browser.test.assertEq(1, ++removedTabs, "Expected only one tab to be removed during the test"); browser.test.sendMessage("tab-closed"); }); } let extensionData = { - background: `(${backgroundScript})();`, + background, manifest: { content_scripts: [{ "matches": ["http://mochi.test/*/file_sample.html"], "js": ["contentscript.js"], }], }, files: { - "contentscript.js": `(${contentScript})();`, + "contentscript.js": contentScript, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); let chromeScript = SpecialPowers.loadChromeScript( SimpleTest.getTestFileURL("file_teardown_test.js"));
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies.html @@ -9,17 +9,17 @@ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; add_task(function* test_cookies() { - function backgroundScript() { + function background() { function assertExpected(expected, cookie) { for (let key of Object.keys(cookie)) { browser.test.assertTrue(key in expected, `found property ${key}`); browser.test.assertEq(expected[key], cookie[key], `property value for ${key} is correct`); } browser.test.assertEq(Object.keys(expected).length, Object.keys(cookie).length, "all expected properties found"); } @@ -163,17 +163,17 @@ add_task(function* test_cookies() { browser.test.assertEq("", cookie.name, "default name set"); browser.test.assertEq("", cookie.value, "default value set"); browser.test.assertEq(true, cookie.session, "no expiry date created session cookie"); browser.test.notifyPass("cookies"); }); } let extension = ExtensionTestUtils.loadExtension({ - background: `(${backgroundScript})()`, + background, manifest: { permissions: ["cookies", "*://example.org/"], }, }); yield extension.startup(); info("extension loaded"); yield extension.awaitFinish("cookies");
--- a/toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_cookies_expiry.html @@ -37,17 +37,17 @@ add_task(function* test_cookies_expiry() }, 1000); } let domain = ".example.com"; let extension = ExtensionTestUtils.loadExtension({ manifest: { "permissions": ["http://example.com/", "cookies"], }, - background: `(${background})()`, + background, }); let cookieSvc = SpecialPowers.Services.cookies; let cookie = { host: domain, name: "first", path: "/",
--- a/toolkit/components/extensions/test/mochitest/test_ext_exclude_include_globs.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_exclude_include_globs.html @@ -9,17 +9,17 @@ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; add_task(function* test_contentscript() { - function backgroundScript() { + function background() { browser.runtime.onMessage.addListener(([script], sender) => { browser.test.sendMessage("run", {script}); browser.test.sendMessage("run-" + script); }); browser.test.sendMessage("running"); } function contentScriptAll() { @@ -48,22 +48,22 @@ add_task(function* test_contentscript() }, { "matches": ["http://example.org/", "http://*.example.org/"], "exclude_globs": ["*test1*"], "js": ["content_script_excludes_test1.js"], }, ], }, - background: "(" + backgroundScript.toString() + ")()", + background, files: { - "content_script_all.js": "(" + contentScriptAll.toString() + ")()", - "content_script_includes_test1.js": "(" + contentScriptIncludesTest1.toString() + ")()", - "content_script_excludes_test1.js": "(" + contentScriptExcludesTest1.toString() + ")()", + "content_script_all.js": contentScriptAll, + "content_script_includes_test1.js": contentScriptIncludesTest1, + "content_script_excludes_test1.js": contentScriptExcludesTest1, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); let ran = 0; extension.onMessage("run", ({script}) => {
--- a/toolkit/components/extensions/test/mochitest/test_ext_generate.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_generate.html @@ -8,31 +8,31 @@ <script type="text/javascript" src="head.js"></script> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; -function backgroundScript() { +function background() { browser.test.log("running background script"); browser.test.onMessage.addListener((x, y) => { browser.test.assertEq(x, 10, "x is 10"); browser.test.assertEq(y, 20, "y is 20"); browser.test.notifyPass("background test passed"); }); browser.test.sendMessage("running", 1); } let extensionData = { - background: "(" + backgroundScript.toString() + ")()", + background, }; add_task(function* test_background() { let extension = ExtensionTestUtils.loadExtension(extensionData); info("load complete"); let [, x] = yield Promise.all([extension.startup(), extension.awaitMessage("running")]); is(x, 1, "got correct value from extension"); info("startup complete");
--- a/toolkit/components/extensions/test/mochitest/test_ext_geturl.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_geturl.html @@ -8,17 +8,17 @@ <script type="text/javascript" src="head.js"></script> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; -function backgroundScript() { +function background() { browser.runtime.onMessage.addListener(([url1, url2]) => { let url3 = browser.runtime.getURL("test_file.html"); let url4 = browser.extension.getURL("test_file.html"); browser.test.assertTrue(url1 !== undefined, "url1 defined"); browser.test.assertTrue(url1.startsWith("moz-extension://"), "url1 has correct scheme"); browser.test.assertTrue(url1.endsWith("test_file.html"), "url1 has correct leaf name"); @@ -33,27 +33,27 @@ function backgroundScript() { function contentScript() { let url1 = browser.runtime.getURL("test_file.html"); let url2 = browser.extension.getURL("test_file.html"); browser.runtime.sendMessage([url1, url2]); } let extensionData = { - background: "(" + backgroundScript.toString() + ")()", + background, manifest: { "content_scripts": [{ "matches": ["http://mochi.test/*/file_sample.html"], "js": ["content_script.js"], "run_at": "document_idle", }], }, files: { - "content_script.js": "(" + contentScript.toString() + ")()", + "content_script.js": contentScript, }, }; add_task(function* test_contentscript() { let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); let win = window.open("file_sample.html");
--- a/toolkit/components/extensions/test/mochitest/test_ext_i18n.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_i18n.html @@ -208,20 +208,20 @@ add_task(function* test_get_accept_langu manifest: { "content_scripts": [{ "matches": ["http://mochi.test/*/file_sample.html"], "run_at": "document_start", "js": ["content_script.js"], }], }, - background: `(${background})()`, + background, files: { - "content_script.js": `(${content})()`, + "content_script.js": content, }, }); let win = window.open("file_sample.html"); yield extension.startup(); yield extension.awaitMessage("ready"); @@ -326,17 +326,17 @@ add_task(function* test_detect_language( "of winkels nie en slegs oornagbesoekers word toegelaat bateleur"; // String with intermixed French/English text const fr_en_string = "France is the largest country in Western Europe and the third-largest in Europe as a whole. " + "A accès aux chiens et aux frontaux qui lui ont été il peut consulter et modifier ses collections et exporter " + "Cet article concerne le pays européen aujourd’hui appelé République française. Pour d’autres usages du nom France, " + "Pour une aide rapide et effective, veuiller trouver votre aide dans le menu ci-dessus." + "Motoring events began soon after the construction of the first successful gasoline-fueled automobiles. The quick brown fox jumped over the lazy dog"; - function backgroundScript() { + function background() { function checkResult(source, result, expected) { browser.test.assertEq(expected.isReliable, result.isReliable, "result.confident is true"); browser.test.assertEq( expected.languages.length, result.languages.length, `result.languages contains the expected number of languages in ${source}`); expected.languages.forEach((lang, index) => { browser.test.assertEq( @@ -382,20 +382,20 @@ add_task(function* test_detect_language( manifest: { "content_scripts": [{ "matches": ["http://mochi.test/*/file_sample.html"], "run_at": "document_start", "js": ["content_script.js"], }], }, - background: `(${backgroundScript})()`, + background, files: { - "content_script.js": `(${content})()`, + "content_script.js": content, }, }); let win = window.open("file_sample.html"); yield extension.startup(); yield extension.awaitMessage("ready");
--- a/toolkit/components/extensions/test/mochitest/test_ext_i18n_css.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_i18n_css.html @@ -10,17 +10,17 @@ </head> <body> <script type="text/javascript"> "use strict"; add_task(function* test_i18n_css() { let extension = ExtensionTestUtils.loadExtension({ - background: "new " + function() { + background: function() { function fetch(url) { return new Promise((resolve, reject) => { let xhr = new XMLHttpRequest(); xhr.open("GET", url); xhr.onload = () => { resolve(xhr.responseText); }; xhr.onerror = reject; xhr.send(); });
--- a/toolkit/components/extensions/test/mochitest/test_ext_inIncognitoContext_window.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_inIncognitoContext_window.html @@ -23,23 +23,22 @@ add_task(function* test_in_incognito_con browser.windows.create({url: browser.runtime.getURL("/tab.html"), incognito: true}); } function tabScript() { browser.runtime.sendMessage(browser.extension.inIncognitoContext); } let extension = ExtensionTestUtils.loadExtension({ - background: `(${background})()`, - manifest: {}, + background, files: { - "tab.js": `(${tabScript})()`, + "tab.js": tabScript, "tab.html": `<!DOCTYPE html><html><head> <meta charset="utf-8"> - <script src="tab.js"></${"script"}> + <script src="tab.js"><\/script> </head></html>`, }, }); yield extension.startup(); yield extension.awaitFinish("inIncognitoContext"); yield extension.unload(); });
--- a/toolkit/components/extensions/test/mochitest/test_ext_jsversion.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_jsversion.html @@ -13,49 +13,49 @@ <body> <script type="text/javascript"> "use strict"; add_task(function* test_versioned_js() { // We need to deal with escaping the close script tags. // May as well consolidate it into one place. - let script = attrs => `<script ${attrs}></${"script"}>`; + let script = attrs => `<script ${attrs}><\/script>`; let extension = ExtensionTestUtils.loadExtension({ manifest: { "background": {"page": "background.html"}, }, files: { "background.html": ` <meta charset="utf-8"> ${script('src="background.js" type="application/javascript"')} ${script('src="background-1.js" type="application/javascript;version=1.8"')} ${script('src="background-2.js" type="application/javascript;version=latest"')} ${script('src="background-3.js" type="application/javascript"')} `, - "background.js": "new " + function() { + "background.js": function() { window.reportResult = msg => { browser.test.assertEq( msg, "background-script-3", "Expected a message only from the unversioned background script."); browser.test.sendMessage("finished"); }; }, - "background-1.js": "new " + function() { + "background-1.js": function() { window.reportResult("background-script-1"); }, - "background-2.js": "new " + function() { + "background-2.js": function() { window.reportResult("background-script-2"); }, - "background-3.js": "new " + function() { + "background-3.js": function() { window.reportResult("background-script-3"); }, }, }); let messages = [/Versioned JavaScript.*not supported in WebExtension.*developer\.mozilla\.org/, /Versioned JavaScript.*not supported in WebExtension.*developer\.mozilla\.org/];
--- a/toolkit/components/extensions/test/mochitest/test_ext_notifications.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_notifications.html @@ -14,44 +14,44 @@ // A 1x1 PNG image. // Source: https://commons.wikimedia.org/wiki/File:1x1.png (Public Domain) let image = atob("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAA" + "ACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII="); const IMAGE_ARRAYBUFFER = Uint8Array.from(image, byte => byte.charCodeAt(0)).buffer; add_task(function* test_notification() { - function backgroundScript() { + function background() { let opts = { type: "basic", title: "Testing Notification", message: "Carry on", }; browser.notifications.create(opts).then(id => { browser.test.sendMessage("running", id); browser.test.notifyPass("background test passed"); }); } let extension = ExtensionTestUtils.loadExtension({ manifest: { permissions: ["notifications"], }, - background: `(${backgroundScript})()`, + background, }); yield extension.startup(); let x = yield extension.awaitMessage("running"); is(x, "0", "got correct id from notifications.create"); yield extension.awaitFinish(); yield extension.unload(); }); add_task(function* test_notification_events() { - function backgroundScript() { + function background() { let opts = { type: "basic", title: "Testing Notification", message: "Carry on", }; // Test an ignored listener. browser.notifications.onButtonClicked.addListener(function() {}); @@ -72,29 +72,29 @@ add_task(function* test_notification_eve browser.test.sendMessage("running", id); }); } let extension = ExtensionTestUtils.loadExtension({ manifest: { permissions: ["notifications"], }, - background: `(${backgroundScript})()`, + background, }); yield extension.startup(); let x = yield extension.awaitMessage("closed"); is(x, "5", "got correct id from onClosed listener"); x = yield extension.awaitMessage("running"); is(x, "5", "got correct id from notifications.create"); yield extension.awaitFinish(); yield extension.unload(); }); add_task(function* test_notification_clear() { - function backgroundScript() { + function background() { let opts = { type: "basic", title: "Testing Notification", message: "Carry on", }; browser.notifications.onClosed.addListener(id => { browser.test.sendMessage("closed", id); @@ -107,49 +107,49 @@ add_task(function* test_notification_cle browser.test.notifyPass("background test passed"); }); } let extension = ExtensionTestUtils.loadExtension({ manifest: { permissions: ["notifications"], }, - background: `(${backgroundScript})()`, + background, }); yield extension.startup(); let x = yield extension.awaitMessage("closed"); is(x, "99", "got correct id from onClosed listener"); x = yield extension.awaitMessage("cleared"); is(x, true, "got correct boolean from notifications.clear"); yield extension.awaitFinish(); yield extension.unload(); }); add_task(function* test_notifications_empty_getAll() { - function backgroundScript() { + function background() { browser.notifications.getAll().then(notifications => { browser.test.assertEq("object", typeof notifications, "getAll() returned an object"); browser.test.assertEq(0, Object.keys(notifications).length, "the object has no properties"); browser.test.notifyPass("getAll empty"); }); } let extension = ExtensionTestUtils.loadExtension({ manifest: { permissions: ["notifications"], }, - background: `(${backgroundScript})()`, + background, }); yield extension.startup(); yield extension.awaitFinish("getAll empty"); yield extension.unload(); }); add_task(function* test_notifications_populated_getAll() { - function backgroundScript() { + function background() { let opts = { type: "basic", iconUrl: "a.png", title: "Testing Notification", message: "Carry on", }; browser.notifications.create("p1", opts).then(() => { @@ -171,28 +171,28 @@ add_task(function* test_notifications_po browser.test.notifyPass("getAll populated"); }); } let extension = ExtensionTestUtils.loadExtension({ manifest: { permissions: ["notifications"], }, - background: `(${backgroundScript})()`, + background, files: { "a.png": IMAGE_ARRAYBUFFER, }, }); yield extension.startup(); yield extension.awaitFinish("getAll populated"); yield extension.unload(); }); add_task(function* test_buttons_unsupported() { - function backgroundScript() { + function background() { let opts = { type: "basic", title: "Testing Notification", message: "Carry on", buttons: [{title: "Button title"}], }; let exception = {}; @@ -208,17 +208,17 @@ add_task(function* test_buttons_unsuppor ); browser.test.notifyPass("buttons-unsupported"); } let extension = ExtensionTestUtils.loadExtension({ manifest: { permissions: ["notifications"], }, - background: `(${backgroundScript})()`, + background, }); yield extension.startup(); yield extension.awaitFinish("buttons-unsupported"); yield extension.unload(); }); </script>
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect.html @@ -8,17 +8,17 @@ <script type="text/javascript" src="head.js"></script> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; -function backgroundScript() { +function background() { browser.runtime.onConnect.addListener(port => { browser.test.assertEq(port.name, "ernie", "port name correct"); browser.test.assertTrue(port.sender.url.endsWith("file_sample.html"), "URL correct"); browser.test.assertTrue(port.sender.tab.url.endsWith("file_sample.html"), "tab URL correct"); let expected = "message 1"; port.onMessage.addListener(msg => { browser.test.assertEq(msg, expected, "message is expected"); @@ -43,28 +43,28 @@ function contentScript() { if (msg == "message 2") { port.postMessage("message 3"); port.disconnect(); } }); } let extensionData = { - background: "(" + backgroundScript.toString() + ")()", + background, manifest: { "permissions": ["tabs"], "content_scripts": [{ "matches": ["http://mochi.test/*/file_sample.html"], "js": ["content_script.js"], "run_at": "document_start", }], }, files: { - "content_script.js": "(" + contentScript.toString() + ")()", + "content_script.js": contentScript, }, }; add_task(function* test_contentscript() { let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); let win = window.open("file_sample.html");
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect_twoway.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_connect_twoway.html @@ -9,17 +9,17 @@ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"> </head> <body> <script> "use strict"; add_task(function* test_connect_bidirectionally_and_postMessage() { - function backgroundScript() { + function background() { let onConnectCount = 0; browser.runtime.onConnect.addListener(port => { // 3. onConnect by connect() from CS. browser.test.assertEq("from-cs", port.name); browser.test.assertEq(1, ++onConnectCount, "BG onConnect should be called once"); let tabId = port.sender.tab.id; @@ -93,25 +93,25 @@ add_task(function* test_connect_bidirect "CS port.onMessage should be called once"); // 10. should trigger port.onMessage in BG. port.postMessage("from CS to port"); }); } let extensionData = { - background: `(${backgroundScript})();`, + background, manifest: { content_scripts: [{ js: ["contentscript.js"], matches: ["http://mochi.test/*/file_sample.html"], }], }, files: { - "contentscript.js": `(${contentScript})();`, + "contentscript.js": contentScript, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); info("extension loaded"); yield extension.awaitMessage("ready");
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_disconnect.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_disconnect.html @@ -8,17 +8,17 @@ <script type="text/javascript" src="head.js"></script> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; -function backgroundScript() { +function background() { browser.runtime.onConnect.addListener(port => { browser.test.assertEq(port.name, "ernie", "port name correct"); port.onDisconnect.addListener(() => { // Closing an already-disconnected port is a no-op. port.disconnect(); port.disconnect(); browser.test.sendMessage("disconnected"); }); @@ -26,28 +26,28 @@ function backgroundScript() { }); } function contentScript() { browser.runtime.connect({name: "ernie"}); } let extensionData = { - background: "(" + backgroundScript.toString() + ")()", + background, manifest: { "permissions": ["tabs"], "content_scripts": [{ "matches": ["http://mochi.test/*/file_sample.html"], "js": ["content_script.js"], "run_at": "document_idle", }], }, files: { - "content_script.js": "(" + contentScript.toString() + ")()", + "content_script.js": contentScript, }, }; add_task(function* test_contentscript() { let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); let win = window.open("file_sample.html");
--- a/toolkit/components/extensions/test/mochitest/test_ext_runtime_id.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_runtime_id.html @@ -31,20 +31,20 @@ add_task(function* test_runtime_id() { applications: {gecko: {id}}, "content_scripts": [{ "matches": ["http://mochi.test/*/file_sample.html"], "run_at": "document_start", "js": ["content_script.js"], }], }, - background: `(${background})()`, + background, files: { - "content_script.js": `(${content})()`, + "content_script.js": content, }, }); yield extension.startup(); let backgroundId = yield extension.awaitMessage("background-id"); is(backgroundId, id, "runtime.id from background script is correct"); let win = window.open("file_sample.html");
--- a/toolkit/components/extensions/test/mochitest/test_ext_sandbox_var.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_sandbox_var.html @@ -8,41 +8,41 @@ <script type="text/javascript" src="head.js"></script> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; -function backgroundScript() { +function background() { browser.runtime.onMessage.addListener(result => { browser.test.assertEq(result, 12, "x is 12"); browser.test.notifyPass("background test passed"); }); } function contentScript() { window.x = 12; browser.runtime.onMessage.addListener(function() {}); browser.runtime.sendMessage(window.x); } let extensionData = { - background: "(" + backgroundScript.toString() + ")()", + background, manifest: { "content_scripts": [{ "matches": ["http://mochi.test/*/file_sample.html"], "js": ["content_script.js"], "run_at": "document_idle", }], }, files: { - "content_script.js": "(" + contentScript.toString() + ")()", + "content_script.js": contentScript, }, }; add_task(function* test_contentscript() { let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); let win = window.open("file_sample.html");
--- a/toolkit/components/extensions/test/mochitest/test_ext_schema.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_schema.html @@ -18,17 +18,17 @@ add_task(function* testEmptySchema() { function background() { browser.test.assertTrue(!("manifest" in browser), "browser.manifest is not defined"); browser.test.assertTrue("storage" in browser, "browser.storage should be defined"); browser.test.assertTrue(!("contextMenus" in browser), "browser.contextMenus should not be defined"); browser.test.notifyPass("schema"); } let extension = ExtensionTestUtils.loadExtension({ - background: `(${background})()`, + background, manifest: { permissions: ["storage"], }, }); yield extension.startup(); yield extension.awaitFinish("schema"); yield extension.unload(); @@ -41,17 +41,17 @@ add_task(function* testUnknownProperties let extension = ExtensionTestUtils.loadExtension({ manifest: { permissions: ["unknownPermission"], unknown_property: {}, }, - background: `(${background})()`, + background, }); let messages = [ {message: /processing permissions\.0: Unknown permission "unknownPermission"/}, {message: /processing unknown_property: An unexpected property was found in the WebExtension manifest/}, ]; let waitForConsole = new Promise(resolve => {
--- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_doublereply.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_doublereply.html @@ -8,17 +8,17 @@ <script type="text/javascript" src="head.js"></script> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; -function backgroundScript() { +function background() { // Add two listeners that both send replies. We're supposed to ignore all but one // of them. Which one is chosen is non-deterministic. browser.runtime.onMessage.addListener((msg, sender, sendReply) => { browser.test.assertTrue(sender.tab.url.endsWith("file_sample.html"), "sender url correct"); if (msg == "getreply") { sendReply("reply1"); @@ -62,28 +62,28 @@ function contentScript() { if (resp != "reply1" && resp != "reply2") { return; // test failed } browser.runtime.sendMessage("done"); }); } let extensionData = { - background: "(" + backgroundScript.toString() + ")()", + background, manifest: { "permissions": ["tabs"], "content_scripts": [{ "matches": ["http://mochi.test/*/file_sample.html"], "js": ["content_script.js"], "run_at": "document_start", }], }, files: { - "content_script.js": "(" + contentScript.toString() + ")()", + "content_script.js": contentScript, }, }; add_task(function* test_contentscript() { let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); let win = window.open("file_sample.html");
--- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_no_receiver.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_no_receiver.html @@ -17,17 +17,17 @@ function loadContentScriptExtension(cont let extensionData = { manifest: { "content_scripts": [{ "js": ["contentscript.js"], "matches": ["http://mochi.test/*/file_sample.html"], }], }, files: { - "contentscript.js": `(${contentScript})();`, + "contentscript.js": contentScript, }, }; return ExtensionTestUtils.loadExtension(extensionData); } add_task(function* test_content_script_sendMessage_without_listener() { function contentScript() { browser.runtime.sendMessage("msg").then(reply => {
--- a/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_sendmessage_reply.html @@ -8,17 +8,17 @@ <script type="text/javascript" src="head.js"></script> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; -function backgroundScript() { +function background() { browser.runtime.onMessage.addListener((msg, sender, sendReply) => { browser.test.assertTrue(sender.tab.url.endsWith("file_sample.html"), "sender url correct"); if (msg == 0) { sendReply("reply1"); } else if (msg == 1) { window.setTimeout(function() { sendReply("reply2"); @@ -40,28 +40,28 @@ function contentScript() { return; // test failed } browser.runtime.sendMessage(2); }); }); } let extensionData = { - background: "(" + backgroundScript.toString() + ")()", + background, manifest: { "permissions": ["tabs"], "content_scripts": [{ "matches": ["http://mochi.test/*/file_sample.html"], "js": ["content_script.js"], "run_at": "document_idle", }], }, files: { - "content_script.js": "(" + contentScript.toString() + ")()", + "content_script.js": contentScript, }, }; add_task(function* test_contentscript() { let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); let win = window.open("file_sample.html");
--- a/toolkit/components/extensions/test/mochitest/test_ext_storage_content.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_storage_content.html @@ -174,17 +174,17 @@ let extensionData = { "js": ["content_script.js"], "run_at": "document_idle", }], permissions: ["storage"], }, files: { - "content_script.js": "(" + contentScript.toString() + ")()", + "content_script.js": contentScript, }, }; add_task(function* test_contentscript() { let win = window.open("file_sample.html"); yield waitForLoad(win); let extension = ExtensionTestUtils.loadExtension(extensionData);
--- a/toolkit/components/extensions/test/mochitest/test_ext_storage_tab.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_storage_tab.html @@ -81,28 +81,28 @@ add_task(function* test_multiple_pages() return browser.storage.local.set({key: {foo: {bar: "baz"}}}); } }); browser.runtime.sendMessage("tab-ready"); } let extension = ExtensionTestUtils.loadExtension({ - background: `(${background})()`, + background, files: { "tab.html": `<!DOCTYPE html> <html> <head> <meta charset="utf-8"> - <script src="tab.js"></${"script"}> + <script src="tab.js"><\/script> </head> </html>`, - "tab.js": `(${tab})()`, + "tab.js": tab, }, manifest: { permissions: ["storage"], }, }); yield extension.startup();
--- a/toolkit/components/extensions/test/mochitest/test_ext_subframes_privileges.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_subframes_privileges.html @@ -9,17 +9,17 @@ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; add_task(function* test_webext_tab_subframe_privileges() { - function backgroundScript() { + function background() { browser.runtime.onMessage.addListener(({msg, success, tabId, error}) => { if (msg == "webext-tab-subframe-privileges") { if (success) { browser.tabs.remove(tabId) .then(() => browser.test.notifyPass(msg)); } else { browser.test.log(`Got an unexpected error: ${error}`); browser.tabs.query({active: true}) @@ -52,33 +52,33 @@ add_task(function* test_webext_tab_subfr msg: "webext-tab-subframe-privileges", success: false, error: `Privileged APIs missing in WebExtension tab sub-frame`, }); } } let extensionData = { - background: "new " + backgroundScript, + background, files: { "tab.html": `<!DOCTYPE> <head> <meta charset="utf-8"> </head> <body> <iframe src="tab-subframe.html"></iframe> </body> </html>`, "tab-subframe.html": `<!DOCTYPE> <head> <meta charset="utf-8"> - <script src="tab-subframe.js"></${"script"}> + <script src="tab-subframe.js"><\/script> </head> </html>`, - "tab-subframe.js": `(${tabSubframeScript})()`, + "tab-subframe.js": tabSubframeScript, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); yield extension.awaitFinish("webext-tab-subframe-privileges"); yield extension.unload(); @@ -104,32 +104,32 @@ add_task(function* test_webext_backgroun </head> <body> <iframe src="background-subframe.html"></iframe> </body> </html>`, "background-subframe.html": `<!DOCTYPE> <head> <meta charset="utf-8"> - <script src="background-subframe.js"></${"script"}> + <script src="background-subframe.js"><\/script> </head> </html>`, - "background-subframe.js": `(${backgroundSubframeScript})()`, + "background-subframe.js": backgroundSubframeScript, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); yield extension.awaitFinish("webext-background-subframe-privileges"); yield extension.unload(); }); add_task(function* test_webext_contentscript_iframe_subframe_privileges() { - function backgroundScript() { + function background() { browser.runtime.onMessage.addListener(({name, hasTabsAPI, hasStorageAPI}) => { if (name == "contentscript-iframe-loaded") { browser.test.assertFalse(hasTabsAPI, "Subframe of a content script privileged iframes has no access to privileged APIs"); browser.test.assertTrue(hasStorageAPI, "Subframe of a content script privileged iframes has access to content script APIs"); browser.test.notifyPass("webext-contentscript-subframe-privileges"); @@ -147,44 +147,44 @@ add_task(function* test_webext_contentsc function contentScript() { let iframe = document.createElement("iframe"); iframe.setAttribute("src", browser.runtime.getURL("/contentscript-iframe.html")); document.body.appendChild(iframe); } let extensionData = { - background: "new " + backgroundScript, + background, manifest: { "permissions": ["storage"], "content_scripts": [{ "matches": ["http://example.com/*"], "js": ["contentscript.js"], }], web_accessible_resources: [ "contentscript-iframe.html", ], }, files: { - "contentscript.js": `(${contentScript})()`, + "contentscript.js": contentScript, "contentscript-iframe.html": `<!DOCTYPE> <head> <meta charset="utf-8"> </head> <body> <iframe src="contentscript-iframe-subframe.html"></iframe> </body> </html>`, "contentscript-iframe-subframe.html": `<!DOCTYPE> <head> <meta charset="utf-8"> - <script src="contentscript-iframe-subframe.js"></${"script"}> + <script src="contentscript-iframe-subframe.js"><\/script> </head> </html>`, - "contentscript-iframe-subframe.js": `(${subframeScript})()`, + "contentscript-iframe-subframe.js": subframeScript, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); let win = window.open("http://example.com");
--- a/toolkit/components/extensions/test/mochitest/test_ext_tab_teardown.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_tab_teardown.html @@ -59,17 +59,17 @@ function* runTabReloadAndCloseTest(exten "ExtensionContext URL at closing tab should be tab URL"); chromeScript.sendAsyncMessage("cleanup"); chromeScript.destroy(); yield extension.unload(); } add_task(function* test_extension_page_tabs_create_reload_and_close() { - function backgroundScript() { + function background() { let tabId; browser.test.onMessage.addListener(msg => { if (msg === "open extension page") { chrome.tabs.create({url: "page.html"}, tab => { tabId = tab.id; }); } else if (msg === "reload extension page") { chrome.tabs.reload(tabId); @@ -81,35 +81,35 @@ add_task(function* test_extension_page_t }); } function pageScript() { browser.test.sendMessage("extension page loaded", document.URL); } let extensionData = { - background: `(${backgroundScript})();`, + background, files: { "page.html": `<!DOCTYPE html><meta charset="utf-8"><script src="page.js"><\/script>`, - "page.js": `(${pageScript})();`, + "page.js": pageScript, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); yield* runTabReloadAndCloseTest(extension); }); add_task(function* test_extension_page_window_open_reload_and_close() { // This tests whether a context that is opened via window.open is properly // disposed when the tab closes. // The background page cannot use window.open (bugzil.la/1282021), so we open // another extension page that manages the window.open-tab for testing. - function backgroundScript() { + function background() { chrome.tabs.create({url: "window.open.html"}); } function windowOpenScript() { let win; browser.test.onMessage.addListener(msg => { if (msg === "open extension page") { win = window.open("page.html"); @@ -126,22 +126,22 @@ add_task(function* test_extension_page_w browser.test.sendMessage("setup-intermediate-tab"); } function pageScript() { browser.test.sendMessage("extension page loaded", document.URL); } let extensionData = { - background: `(${backgroundScript})();`, + background, files: { "page.html": `<!DOCTYPE html><meta charset="utf-8"><script src="page.js"><\/script>`, - "page.js": `(${pageScript})();`, + "page.js": pageScript, "window.open.html": `<!DOCTYPE html><meta charset="utf-8"><script src="window.open.js"><\/script>`, - "window.open.js": `(${windowOpenScript})();`, + "window.open.js": windowOpenScript, }, }; let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); yield extension.awaitMessage("setup-intermediate-tab"); yield* runTabReloadAndCloseTest(extension); }); </script>
--- a/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_web_accessible_resources.html @@ -136,43 +136,43 @@ add_task(function* test_web_accessible_r ], "web_accessible_resources": [ "/accessible.html", "wild*.html", ], }, - background: `(${background})()`, + background, files: { - "content_script.js": `(${contentScript})()`, + "content_script.js": contentScript, "accessible.html": `<html><head> <meta charset="utf-8"> - <script src="accessible.js"></${"script"}> + <script src="accessible.js"><\/script> </head></html>`, "accessible.js": 'browser.runtime.sendMessage(["page-script", location.href]);', "inaccessible.html": `<html><head> <meta charset="utf-8"> - <script src="inaccessible.js"></${"script"}> + <script src="inaccessible.js"><\/script> </head></html>`, "inaccessible.js": 'browser.runtime.sendMessage(["page-script", location.href]);', "wild1.html": `<html><head> <meta charset="utf-8"> - <script src="wild.js"></${"script"}> + <script src="wild.js"><\/script> </head></html>`, "wild2.htm": `<html><head> <meta charset="utf-8"> - <script src="wild.js"></${"script"}> + <script src="wild.js"><\/script> </head></html>`, "wild.js": 'browser.runtime.sendMessage(["page-script", location.href]);', }, }); yield extension.startup(); @@ -226,21 +226,21 @@ add_task(function* test_web_accessible_r "run_at": "document_start", "js": ["content_script_helper.js", "content_script.js"], }], "web_accessible_resources": [ "image.png", "test_script.js", ], }, - background: `(${background})()`, + background, files: { "content_script_helper.js": `${testImageLoading}`, - "content_script.js": `(${content})()`, - "test_script.js": `(${testScript})()`, + "content_script.js": content, + "test_script.js": testScript, "image.png": IMAGE_ARRAYBUFFER, }, }); // This is used to watch the blocked data bounce off CSP. function examiner() { SpecialPowers.addObserver(this, "csp-on-violate-policy", false); } @@ -321,21 +321,21 @@ add_task(function* test_web_accessible_r "run_at": "document_start", "js": ["content_script_helper.js", "content_script.js"], }], "web_accessible_resources": [ "image.png", "test_script.js", ], }, - background: `(${background})()`, + background, files: { "content_script_helper.js": `${testImageLoading}`, - "content_script.js": `(${content})()`, - "test_script.js": `(${testScript})()`, + "content_script.js": content, + "test_script.js": testScript, "image.png": IMAGE_ARRAYBUFFER, }, }); SpecialPowers.setBoolPref("security.mixed_content.block_display_content", true); yield Promise.all([extension.startup(), extension.awaitMessage("background-ready")]);
--- a/toolkit/components/extensions/test/mochitest/test_ext_webnavigation.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webnavigation.html @@ -127,17 +127,17 @@ add_task(function* webnav_transitions_pr } let extensionData = { manifest: { permissions: [ "webNavigation", ], }, - background: `(${backgroundScriptTransitions})()`, + background: backgroundScriptTransitions, }; let extension = ExtensionTestUtils.loadExtension(extensionData); extension.onMessage("received", ({url, event, details}) => { received.push({url, event, details}); if (event == waitingEvent && url == waitingURL) { @@ -344,17 +344,17 @@ add_task(function* webnav_transitions_pr add_task(function* webnav_ordering() { let extensionData = { manifest: { permissions: [ "webNavigation", ], }, - background: "(" + backgroundScript.toString() + ")()", + background: backgroundScript, }; let extension = ExtensionTestUtils.loadExtension(extensionData); extension.onMessage("received", ({url, event}) => { received.push({url, event}); if (event == waitingEvent && url == waitingURL) { @@ -510,17 +510,17 @@ add_task(function* webnav_error_event() } let extensionData = { manifest: { permissions: [ "webNavigation", ], }, - background: `(${backgroundScriptErrorEvent})()`, + background: backgroundScriptErrorEvent, }; let extension = ExtensionTestUtils.loadExtension(extensionData); extension.onMessage("received", ({url, event, details}) => { received.push({url, event, details}); if (event == waitingEvent && url == waitingURL) {
--- a/toolkit/components/extensions/test/mochitest/test_ext_webnavigation_filters.html +++ b/toolkit/components/extensions/test/mochitest/test_ext_webnavigation_filters.html @@ -9,17 +9,17 @@ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> </head> <body> <script type="text/javascript"> "use strict"; add_task(function* test_webnav_unresolved_uri_on_expected_URI_scheme() { - function backgroundScript() { + function background() { let lastTest; function cleanupTestListeners() { if (lastTest) { let {event, okListener, failListener} = lastTest; lastTest = null; browser.test.log(`Cleanup previous test event listeners`); browser.webNavigation[event].removeListener(okListener); @@ -65,17 +65,17 @@ add_task(function* test_webnav_unresolve } let extensionData = { manifest: { permissions: [ "webNavigation", ], }, - background: "new " + backgroundScript, + background, }; let extension = ExtensionTestUtils.loadExtension(extensionData); yield extension.startup(); yield extension.awaitMessage("ready"); @@ -252,17 +252,17 @@ add_task(function* test_webnav_unresolve info("WebNavigation event filters test scenarios completed."); yield extension.unload(); win.close(); }); add_task(function* test_webnav_empty_filter_validation_error() { - function backgroundScript() { + function background() { let catchedException; try { browser.webNavigation.onCompleted.addListener( // Empty callback (not really used) () => {}, // Empty filter (which should raise a validation error exception). {url: []} @@ -282,17 +282,17 @@ add_task(function* test_webnav_empty_fil } let extension = ExtensionTestUtils.loadExtension({ manifest: { permissions: [ "webNavigation", ], }, - background: "new " + backgroundScript, + background, }); yield extension.startup(); yield extension.awaitFinish("webNav.emptyFilterValidationError"); yield extension.unload(); });