Bug 1596918: Part 4d - Fix callers which try to return non-clonable values. r=mccr8

Differential Revision: https://phabricator.services.mozilla.com/D53745

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kris Maglione 2019-12-10 23:07:34 +00:00
Родитель 356e59c6bc
Коммит 37c15883a5
18 изменённых файлов: 40 добавлений и 38 удалений

Просмотреть файл

@ -454,7 +454,7 @@ add_task(async function() {
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();

Просмотреть файл

@ -185,7 +185,7 @@ add_task(async function accesskeys_selection() {
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();

Просмотреть файл

@ -25,8 +25,10 @@ add_task(async function() {
// 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")
)
);

Просмотреть файл

@ -41,7 +41,7 @@ add_task(async function test_frametree() {
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.
@ -76,7 +76,7 @@ add_task(async function test_frametree_dynamic() {
frame,
content.document.getElementsByTagName("iframe")[1]
);
return ContentTaskUtils.waitForEvent(frame, "load");
await ContentTaskUtils.waitForEvent(frame, "load");
});
// The page still has two iframes.
@ -88,7 +88,7 @@ add_task(async function test_frametree_dynamic() {
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.
@ -113,7 +113,10 @@ add_task(async function test_frametree_dynamic() {
async function countNonDynamicFrames(browser) {
return SpecialPowers.spawn(browser, [], async () => {
let count = 0;
SessionStoreUtils.forEachNonDynamicChildFrame(content, () => count++);
content.SessionStoreUtils.forEachNonDynamicChildFrame(
content,
() => count++
);
return count;
});
}
@ -121,7 +124,7 @@ async function countNonDynamicFrames(browser) {
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(",");

Просмотреть файл

@ -70,8 +70,8 @@ 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());
})
);
}

Просмотреть файл

@ -80,7 +80,7 @@ async function waitForWorkerRegistration(swTab) {
const swBrowser = swTab.linkedBrowser;
await asyncWaitUntil(async () =>
SpecialPowers.spawn(swBrowser, [], function() {
return content.wrappedJSObject.getRegistration();
return !!content.wrappedJSObject.getRegistration();
})
);
}

Просмотреть файл

@ -1082,10 +1082,10 @@ function waitForActive(dbg) {
*/
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);
}
);
@ -1097,7 +1097,7 @@ function clickElementInTab(selector) {
return SpecialPowers.spawn(
gBrowser.selectedBrowser,
[{ selector }],
function*({ selector }) {
function({ selector }) {
content.wrappedJSObject.document.querySelector(selector).click();
}
);

Просмотреть файл

@ -66,8 +66,9 @@ async function runTest() {
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}`);

Просмотреть файл

@ -48,13 +48,13 @@ add_task(async function test_image_download() {
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);
});

Просмотреть файл

@ -49,7 +49,7 @@ add_task(async function() {
// 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.");

Просмотреть файл

@ -8,7 +8,7 @@ add_task(async function() {
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) {

Просмотреть файл

@ -32,7 +32,7 @@ add_task(async function() {
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];

Просмотреть файл

@ -32,7 +32,7 @@ add_task(async function() {
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];

Просмотреть файл

@ -112,7 +112,7 @@ this.CookiePolicyHelper = {
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);
});
}

Просмотреть файл

@ -22,7 +22,6 @@
"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.
@ -89,7 +88,7 @@
frame.setAttribute("src", contentSrc);
return new Promise(resolve => {
frame.addEventListener("load", resolve);
frame.addEventListener("load", () => resolve(), { once: true });
content.document.body.appendChild(frame);
});
}).then(() => {

Просмотреть файл

@ -22,8 +22,10 @@ function withAboutStudies(testFunc) {
// 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");
});

Просмотреть файл

@ -110,15 +110,16 @@ function resumeWithExpectedSuccess() {
});
}
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
@ -130,7 +131,6 @@ function callGUM(testParameters) {
// 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) {

Просмотреть файл

@ -63,12 +63,7 @@ function API_getAddonByID(browser, 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));
});
}