Skip to content

Commit 84fa9ff

Browse files
committed
Bug 1596918: Part 4g - Misc cleanup/fixes. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D53748 --HG-- extra : moz-landing-system : lando
1 parent dc4307d commit 84fa9ff

File tree

20 files changed

+45
-70
lines changed

20 files changed

+45
-70
lines changed

browser/base/content/test/tabs/browser_tabSpinnerProbe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function sum(aArray) {
3232
* Resolves once the hang is done.
3333
*/
3434
function hangContentProcess(browser, aMs) {
35-
return SpecialPowers.spawn(browser, [aMs], async function(ms) {
35+
return ContentTask.spawn(browser, aMs, function(ms) {
3636
let then = Date.now();
3737
while (Date.now() - then < ms) {
3838
// Let's burn some CPU...

browser/components/extensions/test/browser/browser_ext_url_overrides_newtab.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ add_task(async function dontTemporarilyShowAboutExtensionPath() {
643643

644644
gBrowser.removeProgressListener(wpl);
645645
is(gURLBar.value, "", "URL bar value should be empty.");
646-
SpecialPowers.spawn(tab.linkedBrowser, [], function() {
646+
await SpecialPowers.spawn(tab.linkedBrowser, [], function() {
647647
is(
648648
content.document.body.textContent,
649649
"New tab!",

browser/components/urlbar/tests/browser/browser_urlbar_blanking.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ add_task(async function() {
3434
);
3535
// When reloading, the javascript: uri we're using will throw an exception.
3636
// That's deliberate, so we need to tell mochitest to ignore it:
37-
SimpleTest.expectUncaughtException(true);
3837
await SpecialPowers.spawn(tab.linkedBrowser, [], async function() {
3938
// This is sync, so by the time we return we should have changed the URL bar.
4039
content.location.reload();
40+
}).catch(e => {
41+
// Ignore expected exception.
4142
});
4243
ok(!!gURLBar.value, "URL bar should not be blank.");
4344
BrowserTestUtils.removeTab(tab);
44-
SimpleTest.expectUncaughtException(false);
4545
});

browser/extensions/formautofill/test/browser/head.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ async function sleep(ms = 500) {
178178
async function focusAndWaitForFieldsIdentified(browser, selector) {
179179
info("expecting the target input being focused and identified");
180180
/* eslint no-shadow: ["error", { "allow": ["selector", "previouslyFocused", "previouslyIdentified"] }] */
181-
const { previouslyFocused, previouslyIdentified } = await SpecialPowers.spawn(
181+
const { previouslyFocused, previouslyIdentified } = await ContentTask.spawn(
182182
browser,
183-
[{ selector }],
183+
{ selector },
184184
async function({ selector }) {
185185
const { FormLikeFactory } = ChromeUtils.import(
186186
"resource://gre/modules/FormLikeFactory.jsm"

browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -154,24 +154,17 @@ async function clickOn(selector, beforeContentFn) {
154154
URL
155155
);
156156

157+
let { SpecialPowers } = lastTab.ownerGlobal;
157158
if (beforeContentFn) {
158-
await lastTab.linkedBrowser.ownerGlobal.SpecialPowers.spawn(
159-
lastTab.linkedBrowser,
160-
[],
161-
beforeContentFn
162-
);
159+
await SpecialPowers.spawn(lastTab.linkedBrowser, [], beforeContentFn);
163160
}
164161

165-
await lastTab.linkedBrowser.ownerGlobal.SpecialPowers.spawn(
166-
lastTab.linkedBrowser,
167-
[selector],
168-
async function(arg) {
169-
E10SUtils.wrapHandlingUserInput(content, true, function() {
170-
let element = content.document.querySelector(arg);
171-
element.click();
172-
});
173-
}
174-
);
162+
await SpecialPowers.spawn(lastTab.linkedBrowser, [selector], arg => {
163+
E10SUtils.wrapHandlingUserInput(content, true, function() {
164+
let element = content.document.querySelector(arg);
165+
element.click();
166+
});
167+
});
175168

176169
// Wait for the popup to actually be shown before making the screenshot
177170
await BrowserTestUtils.waitForEvent(

devtools/client/jsonview/test/head.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ async function addJsonViewTab(
8080
await Promise.race([
8181
error,
8282
// eslint-disable-next-line no-shadow
83-
SpecialPowers.spawn(browser, [data], async function(data) {
83+
ContentTask.spawn(browser, data, async function(data) {
8484
// Check if there is a JSONView object.
8585
const { JSONView } = content.wrappedJSObject;
8686
if (!JSONView) {

devtools/client/netmonitor/test/head.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ async function selectIndexAndWaitForSourceEditor(monitor, index) {
984984
*/
985985
async function performRequests(monitor, tab, count) {
986986
const wait = waitForNetworkEvents(monitor, count);
987-
await SpecialPowers.spawn(tab.linkedBrowser, [count], requestCount => {
987+
await ContentTask.spawn(tab.linkedBrowser, count, requestCount => {
988988
content.wrappedJSObject.performRequests(requestCount);
989989
});
990990
await wait;

devtools/client/styleeditor/test/head.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ var reloadPageAndWaitForStyleSheets = async function(ui) {
7070

7171
const onReset = ui.once("stylesheets-reset");
7272
const browser = gBrowser.selectedBrowser;
73-
await SpecialPowers.spawn(browser, [], "() => content.location.reload()");
73+
await SpecialPowers.spawn(browser, [], () => content.location.reload());
7474
await onReset;
7575
};
7676

devtools/client/webconsole/test/browser/browser_webconsole_stubs_page_error.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ async function generatePageErrorStubs() {
7575
expectUncaughtException();
7676
}
7777

78-
await SpecialPowers.spawn(gBrowser.selectedBrowser, [code], function(
79-
subCode
80-
) {
78+
// Note: This needs to use ContentTask rather than SpecialPowers.spawn
79+
// because the latter includes cross-process stack information.
80+
await ContentTask.spawn(gBrowser.selectedBrowser, code, function(subCode) {
8181
const script = content.document.createElement("script");
8282
script.append(content.document.createTextNode(subCode));
8383
content.document.body.append(script);

dom/base/test/browser_inputStream_structuredClone.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ async function runTest(input, url) {
2727
"The length of the inputStream matches: " + input.length
2828
);
2929

30+
// FIXME: SpecialPowers.spawn currently crashes when trying to return
31+
// values containing input streams.
3032
/* eslint-disable no-shadow */
31-
let dataBack = await SpecialPowers.spawn(browser, [data], function(data) {
33+
let dataBack = await ContentTask.spawn(browser, data, function(data) {
3234
let dataBack = {
3335
inputStream: data.inputStream,
3436
check: true,

dom/ipc/tests/browser_cancel_content_js.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ async function test_navigation(nextPage, cancelContentJSPref, shouldCancel) {
2525
opening: TEST_PAGE,
2626
});
2727

28-
const loopEnded = SpecialPowers.spawn(
29-
tab.linkedBrowser,
30-
[],
31-
async function() {
32-
return new Promise(resolve => {
33-
content.window.addEventListener("LongLoopEnded", resolve);
28+
const loopEnded = ContentTask.spawn(tab.linkedBrowser, [], async function() {
29+
await new Promise(resolve => {
30+
content.addEventListener("LongLoopEnded", resolve, {
31+
once: true,
3432
});
35-
}
36-
);
33+
});
34+
});
3735

3836
// Wait for the test page's long-running JS loop to start; it happens ~500ms
3937
// after load.

security/sandbox/test/browser_content_sandbox_fs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,9 +617,9 @@ async function testFileAccess() {
617617
ok(test.file.exists(), `${test.file.path} exists`);
618618
}
619619

620-
let result = await SpecialPowers.spawn(
620+
let result = await ContentTask.spawn(
621621
test.browser,
622-
[test.file.path],
622+
test.file.path,
623623
test.func
624624
);
625625

toolkit/components/extensions/ExtensionXPCShellUtils.jsm

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,7 @@ class ContentPage {
278278
}
279279

280280
spawn(params, task) {
281-
return this.browser.ownerGlobal.SpecialPowers.spawn(
282-
this.browser,
283-
[params],
284-
task
285-
);
281+
return ContentTask.spawn(this.browser, params, task);
286282
}
287283

288284
async close() {

toolkit/content/tests/browser/browser_datetime_datepicker.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,18 +337,17 @@ add_task(async function test_datepicker_clicked() {
337337
`data:text/html, <input type="date" value="${inputValue}">`
338338
);
339339
// Click the first item (top-left corner) of the calendar
340+
let promise = BrowserTestUtils.waitForContentEvent(
341+
helper.tab.linkedBrowser,
342+
"input"
343+
);
340344
helper.click(helper.getElement(DAYS_VIEW).children[0]);
341-
await SpecialPowers.spawn(helper.tab.linkedBrowser, [], async function() {
342-
let inputEl = content.document.querySelector("input");
343-
await ContentTaskUtils.waitForEvent(inputEl, "input");
344-
});
345+
await promise;
345346

346347
let value = await SpecialPowers.spawn(
347-
gBrowser.selectedBrowser,
348+
helper.tab.linkedBrowser,
348349
[],
349-
async () => {
350-
return content.document.querySelector("input").value;
351-
}
350+
() => content.document.querySelector("input").value
352351
);
353352
Assert.equal(value, firstDayOnCalendar);
354353

toolkit/content/tests/chrome/bug263683_window.xhtml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
<script type="application/javascript"><![CDATA[
2020
const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
2121
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
22-
;
23-
ContentTask.setTestScope(window.arguments[0]);
2422

2523
var gPrefsvc = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
2624
var gFindBar = null;

toolkit/content/tests/chrome/bug331215_window.xhtml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
<script type="application/javascript"><![CDATA[
2020
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
21-
;
22-
ContentTask.setTestScope(window.arguments[0]);
2321

2422
var gFindBar = null;
2523
var gBrowser;

toolkit/content/tests/chrome/bug451540_window.xhtml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
<script type="application/javascript"><![CDATA[
1717
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
18-
;
19-
ContentTask.setTestScope(window.arguments[0]);
2018
const SEARCH_TEXT = "minefield";
2119

2220
let gFindBar = null;

toolkit/content/tests/chrome/findbar_events_window.xhtml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
<script type="application/javascript"><![CDATA[
2020
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
21-
;
22-
ContentTask.setTestScope(window.arguments[0]);
2321

2422
var gFindBar = null;
2523
var gBrowser;
@@ -47,8 +45,9 @@
4745
info("Starting test with browser '" + browserId + "'");
4846
gBrowser = document.getElementById(browserId);
4947
gFindBar.browser = gBrowser;
50-
let promise = BrowserTestUtils.browserLoaded(gBrowser);
51-
BrowserTestUtils.loadURI(gBrowser, "data:text/html,hello there");
48+
const url = "data:text/html,hello there";
49+
let promise = BrowserTestUtils.browserLoaded(gBrowser, false, url);
50+
BrowserTestUtils.loadURI(gBrowser, url);
5251
await promise;
5352
await onDocumentLoaded();
5453
}

toolkit/content/tests/chrome/findbar_window.xhtml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
<script type="application/javascript"><![CDATA[
2222
const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
2323
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
24-
;
25-
ContentTask.setTestScope(window.arguments[0]);
2624

2725
var gPrefsvc = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
2826

widget/tests/browser/browser_test_clipboardcache.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,9 @@ async function testCopyPaste(isPrivate) {
7878
let browser = tab.linkedBrowser;
7979

8080
// Sanitize environment
81-
await SpecialPowers.spawn(
82-
browser,
83-
[SHORT_STRING_NO_CACHE],
84-
async shortStr => {
85-
await content.navigator.clipboard.writeText(shortStr);
86-
}
87-
);
81+
await ContentTask.spawn(browser, SHORT_STRING_NO_CACHE, async shortStr => {
82+
await content.navigator.clipboard.writeText(shortStr);
83+
});
8884

8985
let initialFdCount = getClipboardCacheFDCount();
9086

0 commit comments

Comments
 (0)