Bug 1596918: Part 4d - Fix callers which try to return non-clonable values. r=mccr8
☠☠ backed out by 60951c2dc41e ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Sat, 07 Dec 2019 18:44:35 +0000
changeset 568119 0bca4de31d40725d1b20c5e10db872a3180f0bca
parent 568118 11ec4393f23dfa2fd2c8cbe106d5a6126fe34885
child 568120 e5fd3ee22ea1e236b5b8fcc31c39e850b057774b
push id12493
push userffxbld-merge
push dateMon, 06 Jan 2020 15:38:57 +0000
treeherdermozilla-beta@63ae456b848d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1596918
milestone73.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
Bug 1596918: Part 4d - Fix callers which try to return non-clonable values. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D53745
browser/components/extensions/test/browser/browser_ext_contextMenus.js
browser/components/extensions/test/browser/browser_ext_menus_accesskey.js
browser/components/preferences/in-content/tests/browser_search_subdialogs_within_preferences_1.js
browser/components/sessionstore/test/browser_frametree.js
devtools/client/aboutdebugging/test/browser/helper-serviceworker.js
devtools/client/application/test/browser/head.js
devtools/client/debugger/test/mochitest/helpers.js
dom/serviceworkers/test/browser_navigation_process_swap.js
dom/tests/browser/browser_persist_mixed_content_image.js
dom/u2f/tests/browser/browser_appid_localhost.js
layout/style/test/browser_sourcemap.js
layout/style/test/browser_sourcemap_comment.js
layout/style/test/browser_sourceurl_comment.js
netwerk/cookie/test/browser/head.js
security/manager/ssl/tests/mochitest/stricttransportsecurity/test_sts_privatebrowsing_perwindowpb.html
toolkit/components/normandy/test/browser/browser_about_studies.js
toolkit/content/tests/browser/browser_autoplay_policy_web_audio_with_gum.js
toolkit/mozapps/extensions/test/browser/browser_webapi.js
--- a/browser/components/extensions/test/browser/browser_ext_contextMenus.js
+++ b/browser/components/extensions/test/browser/browser_ext_contextMenus.js
@@ -449,17 +449,17 @@ add_task(async function() {
   };
 
   result = await extension.awaitMessage("onclick");
   checkClickInfo(result);
   result = await extension.awaitMessage("browser.contextMenus.onClicked");
   checkClickInfo(result);
 
   // Select a lot of text
-  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function*(arg) {
+  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function(arg) {
     let doc = content.document;
     let range = doc.createRange();
     let selection = content.getSelection();
     selection.removeAllRanges();
     let textNode = doc.getElementById("longtext").firstChild;
     range.setStart(textNode, 0);
     range.setEnd(textNode, textNode.length);
     selection.addRange(range);
--- a/browser/components/extensions/test/browser/browser_ext_menus_accesskey.js
+++ b/browser/components/extensions/test/browser/browser_ext_menus_accesskey.js
@@ -180,17 +180,17 @@ add_task(async function accesskeys_selec
       permissions: ["menus"],
     },
     background,
   });
 
   await extension.startup();
 
   // Select all
-  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function*(arg) {
+  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function(arg) {
     let doc = content.document;
     let range = doc.createRange();
     let selection = content.getSelection();
     selection.removeAllRanges();
     range.selectNodeContents(doc.body);
     selection.addRange(range);
   });
 
--- a/browser/components/preferences/in-content/tests/browser_search_subdialogs_within_preferences_1.js
+++ b/browser/components/preferences/in-content/tests/browser_search_subdialogs_within_preferences_1.js
@@ -20,18 +20,20 @@ add_task(async function() {
     set: [
       ["browser.startup.homepage", "about:robots"],
       ["browser.startup.page", 1],
     ],
   });
 
   // Wait for Activity Stream to add its panels
   await BrowserTestUtils.waitForCondition(() =>
-    SpecialPowers.spawn(gBrowser.selectedTab.linkedBrowser, [], async () =>
-      content.document.getElementById("homeContentsGroup")
+    SpecialPowers.spawn(
+      gBrowser.selectedTab.linkedBrowser,
+      [],
+      () => !!content.document.getElementById("homeContentsGroup")
     )
   );
 
   await evaluateSearchResults("Set Home Page", "homepageGroup");
   BrowserTestUtils.removeTab(gBrowser.selectedTab);
 });
 
 /**
--- a/browser/components/sessionstore/test/browser_frametree.js
+++ b/browser/components/sessionstore/test/browser_frametree.js
@@ -36,17 +36,17 @@ add_task(async function test_frametree()
   // We're at page one again.
   is(await countNonDynamicFrames(browser), 0, "no child frames");
 
   // Append a dynamic frame.
   await SpecialPowers.spawn(browser, [URL], async ([url]) => {
     let frame = content.document.createElement("iframe");
     frame.setAttribute("src", url);
     content.document.body.appendChild(frame);
-    return ContentTaskUtils.waitForEvent(frame, "load");
+    await ContentTaskUtils.waitForEvent(frame, "load");
   });
 
   // The dynamic frame should be ignored.
   is(
     await countNonDynamicFrames(browser),
     0,
     "we still have a single root frame"
   );
@@ -71,29 +71,29 @@ add_task(async function test_frametree_d
   // Insert a dynamic frame.
   await SpecialPowers.spawn(browser, [URL], async ([url]) => {
     let frame = content.document.createElement("iframe");
     frame.setAttribute("src", url);
     content.document.body.insertBefore(
       frame,
       content.document.getElementsByTagName("iframe")[1]
     );
-    return ContentTaskUtils.waitForEvent(frame, "load");
+    await ContentTaskUtils.waitForEvent(frame, "load");
   });
 
   // The page still has two iframes.
   is(await countNonDynamicFrames(browser), 2, "two non-dynamic child frames");
   is(await enumerateIndexes(browser), "0,1", "correct indexes 0 and 1");
 
   // Append a dynamic frame.
   await SpecialPowers.spawn(browser, [URL], async ([url]) => {
     let frame = content.document.createElement("iframe");
     frame.setAttribute("src", url);
     content.document.body.appendChild(frame);
-    return ContentTaskUtils.waitForEvent(frame, "load");
+    await ContentTaskUtils.waitForEvent(frame, "load");
   });
 
   // The page still has two iframes.
   is(await countNonDynamicFrames(browser), 2, "two non-dynamic child frames");
   is(await enumerateIndexes(browser), "0,1", "correct indexes 0 and 1");
 
   // Remopve a non-dynamic iframe.
   await SpecialPowers.spawn(browser, [URL], async ([url]) => {
@@ -108,22 +108,25 @@ add_task(async function test_frametree_d
 
   // Cleanup.
   BrowserTestUtils.removeTab(tab);
 });
 
 async function countNonDynamicFrames(browser) {
   return SpecialPowers.spawn(browser, [], async () => {
     let count = 0;
-    SessionStoreUtils.forEachNonDynamicChildFrame(content, () => count++);
+    content.SessionStoreUtils.forEachNonDynamicChildFrame(
+      content,
+      () => count++
+    );
     return count;
   });
 }
 
 async function enumerateIndexes(browser) {
   return SpecialPowers.spawn(browser, [], async () => {
     let indexes = [];
-    SessionStoreUtils.forEachNonDynamicChildFrame(content, (frame, i) =>
+    content.SessionStoreUtils.forEachNonDynamicChildFrame(content, (frame, i) =>
       indexes.push(i)
     );
     return indexes.join(",");
   });
 }
--- a/devtools/client/aboutdebugging/test/browser/helper-serviceworker.js
+++ b/devtools/client/aboutdebugging/test/browser/helper-serviceworker.js
@@ -65,18 +65,18 @@ async function waitForServiceWorkerRegis
   return _waitForServiceWorkerStatus(workerText, "Registering", document);
 }
 /* exported waitForServiceWorkerRegistering */
 
 async function waitForRegistration(tab) {
   info("Wait until the registration appears on the window");
   const swBrowser = tab.linkedBrowser;
   await asyncWaitUntil(async () =>
-    SpecialPowers.spawn(swBrowser, [], function() {
-      return content.wrappedJSObject.getRegistration();
+    SpecialPowers.spawn(swBrowser, [], async function() {
+      return !!(await content.wrappedJSObject.getRegistration());
     })
   );
 }
 /* exported waitForRegistration */
 
 /**
  * Helper to listen once on a message sent using postMessage from the provided tab.
  *
--- a/devtools/client/application/test/browser/head.js
+++ b/devtools/client/application/test/browser/head.js
@@ -72,17 +72,17 @@ async function unregisterAllWorkers(clie
   }
 }
 
 async function waitForWorkerRegistration(swTab) {
   info("Wait until the registration appears on the window");
   const swBrowser = swTab.linkedBrowser;
   await asyncWaitUntil(async () =>
     SpecialPowers.spawn(swBrowser, [], function() {
-      return content.wrappedJSObject.getRegistration();
+      return !!content.wrappedJSObject.getRegistration();
     })
   );
 }
 
 function selectPage(panel, page) {
   /**
    * Select a page by simulating a user click in the sidebar.
    * @param {string} page The page we want to select (see `PAGE_TYPES`)
--- a/devtools/client/debugger/test/mochitest/helpers.js
+++ b/devtools/client/debugger/test/mochitest/helpers.js
@@ -1077,32 +1077,32 @@ function waitForActive(dbg) {
  *                     call. This is applied to structured clones of the
  *                     remaining arguments to invokeInTab.
  * @param {Any} ...args Remaining args to serialize and pass to fnc.
  * @return {Promise}
  * @static
  */
 function invokeInTab(fnc, ...args) {
   info(`Invoking in tab: ${fnc}(${args.map(uneval).join(",")})`);
-  return SpecialPowers.spawn(
+  return ContentTask.spawn(
     gBrowser.selectedBrowser,
-    [{ fnc, args }],
-    function*({ fnc, args }) {
+    { fnc, args },
+    function({ fnc, args }) {
       return content.wrappedJSObject[fnc](...args);
     }
   );
 }
 
 function clickElementInTab(selector) {
   info(`click element ${selector} in tab`);
 
   return SpecialPowers.spawn(
     gBrowser.selectedBrowser,
     [{ selector }],
-    function*({ selector }) {
+    function({ selector }) {
       content.wrappedJSObject.document.querySelector(selector).click();
     }
   );
 }
 
 const isLinux = Services.appinfo.OS === "Linux";
 const isMac = Services.appinfo.OS === "Darwin";
 const cmdOrCtrl = isLinux ? { ctrlKey: true } : { metaKey: true };
--- a/dom/serviceworkers/test/browser_navigation_process_swap.js
+++ b/dom/serviceworkers/test/browser_navigation_process_swap.js
@@ -61,18 +61,19 @@ async function runTest() {
     opening: SW_REGISTER_PAGE_URL,
   });
   info(`Loaded page ${SW_REGISTER_PAGE_URL}`);
 
   info(`Registering Service Worker ${SW_SCRIPT_URL}`);
   await SpecialPowers.spawn(
     tab.linkedBrowser,
     [{ scriptURL: SW_SCRIPT_URL }],
-    async ({ scriptURL }) =>
-      await content.wrappedJSObject.registerAndWaitForActive(scriptURL)
+    async ({ scriptURL }) => {
+      await content.wrappedJSObject.registerAndWaitForActive(scriptURL);
+    }
   );
   info(`Registered and activated Service Worker ${SW_SCRIPT_URL}`);
 
   // Step 2: open a page over file:// and navigate to trigger a process swap
   // for the response.
   info(`Loading ${FILE_URL}`);
   await loadURI(tab.linkedBrowser, FILE_URL);
 
--- a/dom/tests/browser/browser_persist_mixed_content_image.js
+++ b/dom/tests/browser/browser_persist_mixed_content_image.js
@@ -43,23 +43,23 @@ function createTemporarySaveDirectory() 
   return saveDir;
 }
 
 add_task(async function test_image_download() {
   await BrowserTestUtils.withNewTab(
     TEST_PATH + "test_mixed_content_image.html",
     async browser => {
       // Add the image, and wait for it to load.
-      await SpecialPowers.spawn(browser, [], function() {
+      await SpecialPowers.spawn(browser, [], async function() {
         let loc = content.document.location.href;
         let httpRoot = loc.replace("https", "http");
         let imgloc = new content.URL("dummy.png", httpRoot);
         let img = content.document.createElement("img");
         img.src = imgloc;
-        return new Promise(resolve => {
+        await new Promise(resolve => {
           img.onload = resolve;
           content.document.body.appendChild(img);
         });
       });
       gTestDir = createTemporarySaveDirectory();
 
       let destFile = gTestDir.clone();
 
--- a/dom/u2f/tests/browser/browser_appid_localhost.js
+++ b/dom/u2f/tests/browser/browser_appid_localhost.js
@@ -44,17 +44,17 @@ add_task(async function() {
     false
   );
 
   // Open a new tab.
   let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL);
 
   // Check that we have the right origin, and U2F is available.
   let ready = await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
-    return content.location.origin == "https://localhost" && content.u2f;
+    return content.location.origin == "https://localhost" && !!content.u2f;
   });
   ok(ready, "Origin is https://localhost. U2F is available.");
 
   // Test: Null AppID
   await promiseU2FRegister(tab, null).then(res => {
     is(res.errorCode, 0, "Null AppID should work.");
   });
 
--- a/layout/style/test/browser_sourcemap.js
+++ b/layout/style/test/browser_sourcemap.js
@@ -3,17 +3,17 @@ add_task(async function() {
   info(`URI is ${uri}`);
 
   await BrowserTestUtils.withNewTab(
     {
       gBrowser,
       url: uri,
     },
     async function(browser) {
-      await SpecialPowers.spawn(browser, [], function*() {
+      await SpecialPowers.spawn(browser, [], function() {
         let seenSheets = 0;
 
         for (let i = 0; i < content.document.styleSheets.length; ++i) {
           let sheet = content.document.styleSheets[i];
 
           info(`Checking ${sheet.href}`);
           if (/mapped\.css/.test(sheet.href)) {
             is(
--- a/layout/style/test/browser_sourcemap_comment.js
+++ b/layout/style/test/browser_sourcemap_comment.js
@@ -27,17 +27,17 @@ add_task(async function() {
   info(`URI is ${uri}`);
 
   await BrowserTestUtils.withNewTab(
     {
       gBrowser,
       url: uri,
     },
     async function(browser) {
-      await SpecialPowers.spawn(browser, [test_cases], function*(tests) {
+      await SpecialPowers.spawn(browser, [test_cases], function(tests) {
         for (let i = 0; i < content.document.styleSheets.length; ++i) {
           let sheet = content.document.styleSheets[i];
 
           info(`Checking sheet #${i}`);
           is(
             sheet.sourceMapURL,
             tests[i][1],
             `correct source map for sheet ${i}`
--- a/layout/style/test/browser_sourceurl_comment.js
+++ b/layout/style/test/browser_sourceurl_comment.js
@@ -27,17 +27,17 @@ add_task(async function() {
   info(`URI is ${uri}`);
 
   await BrowserTestUtils.withNewTab(
     {
       gBrowser,
       url: uri,
     },
     async function(browser) {
-      await SpecialPowers.spawn(browser, [test_cases], function*(tests) {
+      await SpecialPowers.spawn(browser, [test_cases], function(tests) {
         for (let i = 0; i < content.document.styleSheets.length; ++i) {
           let sheet = content.document.styleSheets[i];
 
           info(`Checking sheet #${i}`);
           is(sheet.sourceURL, tests[i][1], `correct source URL for sheet ${i}`);
         }
       });
     }
--- a/netwerk/cookie/test/browser/head.js
+++ b/netwerk/cookie/test/browser/head.js
@@ -107,17 +107,17 @@ this.CookiePolicyHelper = {
       await SpecialPowers.spawn(
         browser,
         [{ url: TEST_TOP_PAGE }],
         async obj => {
           return new content.Promise(resolve => {
             let ifr = content.document.createElement("iframe");
             ifr.setAttribute("id", "iframe");
             ifr.src = obj.url;
-            ifr.onload = resolve;
+            ifr.onload = () => resolve();
             content.document.body.appendChild(ifr);
           });
         }
       );
 
       // Let's exec the "good" callback.
       info(
         "Executing the test after setting the cookie behavior to " +
--- a/security/manager/ssl/tests/mochitest/stricttransportsecurity/test_sts_privatebrowsing_perwindowpb.html
+++ b/security/manager/ssl/tests/mochitest/stricttransportsecurity/test_sts_privatebrowsing_perwindowpb.html
@@ -17,17 +17,16 @@
 
   const STSPATH =
     "tests/security/manager/ssl/tests/mochitest/stricttransportsecurity";
   const NUM_TEST_FRAMES = 4;
   const CONTENT_PAGE =
     "http://mochi.test:8888/chrome/security/manager/ssl/tests/mochitest/stricttransportsecurity/page_blank.html";
 
   const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
-  ;
   const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 
   // This is how many sub-tests (testframes) in each round.
   // When the round begins, this will be initialized.
   var testsleftinround = 0;
   var currentround = "";
   var mainWindow = window.docShell.rootTreeItem.domWindow;
 
@@ -84,17 +83,17 @@
     let src = `https://example.com/${STSPATH}/${round}_bootstrap.html`;
 
     SpecialPowers.spawn(browser, [src], async function(contentSrc) {
       let frame = content.document.createElement("iframe");
       frame.setAttribute("id", "ifr_bootstrap");
       frame.setAttribute("src", contentSrc);
 
       return new Promise(resolve => {
-        frame.addEventListener("load", resolve);
+        frame.addEventListener("load", () => resolve(), { once: true });
         content.document.body.appendChild(frame);
       });
     }).then(() => {
       onMessageReceived(win, isPrivate, "BOOTSTRAP " + round);
     });
   }
 
   function loadVerifyFrames(win, isPrivate, round) {
--- a/toolkit/components/normandy/test/browser/browser_about_studies.js
+++ b/toolkit/components/normandy/test/browser/browser_about_studies.js
@@ -17,18 +17,20 @@ function withAboutStudies(testFunc) {
   return async (...args) =>
     BrowserTestUtils.withNewTab("about:studies", async browser =>
       testFunc(...args, browser)
     );
 }
 
 // Test that the code renders at all
 decorate_task(withAboutStudies, async function testAboutStudiesWorks(browser) {
-  const appFound = await SpecialPowers.spawn(browser, [], () =>
-    content.document.getElementById("app")
+  const appFound = await SpecialPowers.spawn(
+    browser,
+    [],
+    () => !!content.document.getElementById("app")
   );
   ok(appFound, "App element was found");
 });
 
 // Test that the learn more element is displayed correctly
 decorate_task(
   withPrefEnv({
     set: [["app.normandy.shieldLearnMoreUrl", "http://test/%OS%/"]],
--- a/toolkit/content/tests/browser/browser_autoplay_policy_web_audio_with_gum.js
+++ b/toolkit/content/tests/browser/browser_autoplay_policy_web_audio_with_gum.js
@@ -105,37 +105,37 @@ function resumeWithoutExpectedSuccess() 
 function resumeWithExpectedSuccess() {
   let ac = content.ac;
   ac.resumePromises.push(ac.resume());
   return Promise.all(ac.resumePromises).then(() => {
     ok(ac.state == "running", "audio context starts running");
   });
 }
 
-function callGUM(testParameters) {
+async function callGUM(testParameters) {
   info("- calling gum with " + JSON.stringify(testParameters.constraints));
   if (testParameters.shouldAllowStartingContext) {
     // Because of the prefs we've set and passed, this is going to allow the
     // window to start an AudioContext synchronously.
     testParameters.constraints.fake = true;
-    return content.navigator.mediaDevices.getUserMedia(
+    await content.navigator.mediaDevices.getUserMedia(
       testParameters.constraints
     );
+    return;
   }
 
   // Call gUM, without sucess: we've made it so that only fake requests
   // succeed without permission, and this is requesting non-fake-devices. Return
   // a resolved promise so that the test continues, but the getUserMedia Promise
   // will never be resolved.
   // We do this to check that it's not merely calling gUM that allows starting
   // an AudioContext, it's having the Promise it return resolved successfuly,
   // because of saved permissions for an origin or explicit user consent using
   // the prompt.
   content.navigator.mediaDevices.getUserMedia(testParameters.constraints);
-  return Promise.resolve();
 }
 
 async function testWebAudioWithGUM(testParameters) {
   info("- open new tab -");
   let tab = await BrowserTestUtils.openNewForegroundTab(
     window.gBrowser,
     "https://example.com"
   );
--- a/toolkit/mozapps/extensions/test/browser/browser_webapi.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_webapi.js
@@ -58,22 +58,17 @@ let addons = gProvider.createAddons([
 
 addons[3].permissions &= ~AddonManager.PERM_CAN_UNINSTALL;
 
 function API_getAddonByID(browser, id) {
   return SpecialPowers.spawn(browser, [id], async function(id) {
     let addon = await content.navigator.mozAddonManager.getAddonByID(id);
 
     // We can't send native objects back so clone its properties.
-    let result = {};
-    for (let prop in addon) {
-      result[prop] = addon[prop];
-    }
-
-    return result;
+    return JSON.parse(JSON.stringify(addon));
   });
 }
 
 add_task(
   testWithAPI(async function(browser) {
     function compareObjects(web, real) {
       for (let prop of Object.keys(web)) {
         let webVal = web[prop];