Bug 1596918: Part 4g - Misc cleanup/fixes. r=mccr8

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kris Maglione 2019-12-10 23:07:41 +00:00
Родитель 2c38fe8acb
Коммит cee320b5fb
28 изменённых файлов: 76 добавлений и 79 удалений

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

@ -8,6 +8,10 @@
// same histogram ID) overlap. That causes TelemetryStopwatch to log an
// error.
SimpleTest.ignoreAllUncaughtExceptions(true);
const { PromiseTestUtils } = ChromeUtils.import(
"resource://testing-common/PromiseTestUtils.jsm"
);
PromiseTestUtils.whitelistRejectionsGlobally(/Not in fullscreen mode/);
SimpleTest.requestCompleteLog();

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

@ -32,7 +32,7 @@ function sum(aArray) {
* Resolves once the hang is done.
*/
function hangContentProcess(browser, aMs) {
return SpecialPowers.spawn(browser, [aMs], async function(ms) {
return ContentTask.spawn(browser, aMs, function(ms) {
let then = Date.now();
while (Date.now() - then < ms) {
// Let's burn some CPU...

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

@ -643,7 +643,7 @@ add_task(async function dontTemporarilyShowAboutExtensionPath() {
gBrowser.removeProgressListener(wpl);
is(gURLBar.value, "", "URL bar value should be empty.");
SpecialPowers.spawn(tab.linkedBrowser, [], function() {
await SpecialPowers.spawn(tab.linkedBrowser, [], function() {
is(
content.document.body.textContent,
"New tab!",

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

@ -164,13 +164,13 @@ async function testSearchEngine(engineDetails) {
searchURL: base.replace("{code}", engineDetails.codes.newTab),
async preTest(tab) {
let browser = tab.linkedBrowser;
await BrowserTestUtils.loadURI(browser, "about:newtab");
await BrowserTestUtils.browserLoaded(browser);
BrowserTestUtils.loadURI(browser, "about:newtab");
await BrowserTestUtils.browserLoaded(browser, false, "about:newtab");
await promiseContentSearchReady(browser);
},
async run(tab) {
await SpecialPowers.spawn(tab.linkedBrowser, [], async function(args) {
await SpecialPowers.spawn(tab.linkedBrowser, [], async function() {
let input = content.document.querySelector("input[id*=search-]");
input.focus();
input.value = "foo";

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

@ -10,7 +10,7 @@ add_task(async function test() {
"browser/components/sessionstore/test/browser_339445_sample.html";
let tab = BrowserTestUtils.addTab(gBrowser, testURL);
await promiseBrowserLoaded(tab.linkedBrowser);
await promiseBrowserLoaded(tab.linkedBrowser, true, testURL);
await SpecialPowers.spawn(tab.linkedBrowser, [], function() {
let doc = content.document;
@ -24,7 +24,7 @@ add_task(async function test() {
let tab2 = gBrowser.duplicateTab(tab);
await promiseTabRestored(tab2);
await SpecialPowers.spawn(tab2.linkedBrowser, [], function() {
await ContentTask.spawn(tab2.linkedBrowser, null, function() {
let doc2 = content.document;
is(
doc2.getElementById("storageTestItem").textContent,

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

@ -34,12 +34,12 @@ add_task(async function() {
);
// When reloading, the javascript: uri we're using will throw an exception.
// That's deliberate, so we need to tell mochitest to ignore it:
SimpleTest.expectUncaughtException(true);
await SpecialPowers.spawn(tab.linkedBrowser, [], async function() {
// This is sync, so by the time we return we should have changed the URL bar.
content.location.reload();
}).catch(e => {
// Ignore expected exception.
});
ok(!!gURLBar.value, "URL bar should not be blank.");
BrowserTestUtils.removeTab(tab);
SimpleTest.expectUncaughtException(false);
});

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

@ -178,9 +178,9 @@ async function sleep(ms = 500) {
async function focusAndWaitForFieldsIdentified(browser, selector) {
info("expecting the target input being focused and identified");
/* eslint no-shadow: ["error", { "allow": ["selector", "previouslyFocused", "previouslyIdentified"] }] */
const { previouslyFocused, previouslyIdentified } = await SpecialPowers.spawn(
const { previouslyFocused, previouslyIdentified } = await ContentTask.spawn(
browser,
[{ selector }],
{ selector },
async function({ selector }) {
const { FormLikeFactory } = ChromeUtils.import(
"resource://gre/modules/FormLikeFactory.jsm"

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

@ -154,24 +154,17 @@ async function clickOn(selector, beforeContentFn) {
URL
);
let { SpecialPowers } = lastTab.ownerGlobal;
if (beforeContentFn) {
await lastTab.linkedBrowser.ownerGlobal.SpecialPowers.spawn(
lastTab.linkedBrowser,
[],
beforeContentFn
);
await SpecialPowers.spawn(lastTab.linkedBrowser, [], beforeContentFn);
}
await lastTab.linkedBrowser.ownerGlobal.SpecialPowers.spawn(
lastTab.linkedBrowser,
[selector],
async function(arg) {
E10SUtils.wrapHandlingUserInput(content, true, function() {
let element = content.document.querySelector(arg);
element.click();
});
}
);
await SpecialPowers.spawn(lastTab.linkedBrowser, [selector], arg => {
E10SUtils.wrapHandlingUserInput(content, true, function() {
let element = content.document.querySelector(arg);
element.click();
});
});
// Wait for the popup to actually be shown before making the screenshot
await BrowserTestUtils.waitForEvent(

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

@ -80,7 +80,7 @@ async function addJsonViewTab(
await Promise.race([
error,
// eslint-disable-next-line no-shadow
SpecialPowers.spawn(browser, [data], async function(data) {
ContentTask.spawn(browser, data, async function(data) {
// Check if there is a JSONView object.
const { JSONView } = content.wrappedJSObject;
if (!JSONView) {

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

@ -984,7 +984,7 @@ async function selectIndexAndWaitForSourceEditor(monitor, index) {
*/
async function performRequests(monitor, tab, count) {
const wait = waitForNetworkEvents(monitor, count);
await SpecialPowers.spawn(tab.linkedBrowser, [count], requestCount => {
await ContentTask.spawn(tab.linkedBrowser, count, requestCount => {
content.wrappedJSObject.performRequests(requestCount);
});
await wait;

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

@ -30,7 +30,6 @@ support-files =
skip-if = fission
[browser_contextmenu_inspect.js]
[browser_contextual_identity.js]
fail-if = fission #Bug 1585437
[browser_device_change.js]
[browser_device_custom_edit.js]
[browser_device_custom_remove.js]
@ -46,7 +45,6 @@ fail-if = fission #Bug 1585437
[browser_ext_messaging.js]
tags = devtools webextensions
[browser_favicon.js]
fail-if = fission #Bug 1585437
[browser_frame_script_active.js]
[browser_hide_container.js]
[browser_in_rdm_pane.js]
@ -71,7 +69,6 @@ skip-if = fission
[browser_state_restore.js]
[browser_tab_close.js]
[browser_tab_remoteness_change.js]
fail-if = fission #Bug 1585437
[browser_target_blank.js]
[browser_telemetry_activate_rdm.js]
[browser_toolbox_computed_view.js]

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

@ -5,6 +5,13 @@
const TEST_URL = TEST_URI_ROOT + "contextual_identity.html";
const { PromiseTestUtils } = ChromeUtils.import(
"resource://testing-common/PromiseTestUtils.jsm"
);
PromiseTestUtils.whitelistRejectionsGlobally(
/Permission denied to access property "document" on cross-origin object/
);
// Opens `uri' in a new tab with the provided userContextId.
// Returns the newly opened tab and browser.
async function addTabInUserContext(uri, userContextId) {

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

@ -5,6 +5,13 @@
// Test that favicons make it to the parent process.
const { PromiseTestUtils } = ChromeUtils.import(
"resource://testing-common/PromiseTestUtils.jsm"
);
PromiseTestUtils.whitelistRejectionsGlobally(
/Permission denied to access property "document" on cross-origin object/
);
const TEST_URL = `${URL_ROOT}favicon.html`;
function waitForLinkAvailable(browser) {

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

@ -5,6 +5,13 @@
// Verify RDM closes synchronously when tabs change remoteness.
const { PromiseTestUtils } = ChromeUtils.import(
"resource://testing-common/PromiseTestUtils.jsm"
);
PromiseTestUtils.whitelistRejectionsGlobally(
/Permission denied to access property "document" on cross-origin object/
);
const TEST_URL = "http://example.com/";
add_task(async function() {

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

@ -70,7 +70,7 @@ var reloadPageAndWaitForStyleSheets = async function(ui) {
const onReset = ui.once("stylesheets-reset");
const browser = gBrowser.selectedBrowser;
await SpecialPowers.spawn(browser, [], "() => content.location.reload()");
await SpecialPowers.spawn(browser, [], () => content.location.reload());
await onReset;
};

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

@ -75,9 +75,9 @@ async function generatePageErrorStubs() {
expectUncaughtException();
}
await SpecialPowers.spawn(gBrowser.selectedBrowser, [code], function(
subCode
) {
// Note: This needs to use ContentTask rather than SpecialPowers.spawn
// because the latter includes cross-process stack information.
await ContentTask.spawn(gBrowser.selectedBrowser, code, function(subCode) {
const script = content.document.createElement("script");
script.append(content.document.createTextNode(subCode));
content.document.body.append(script);

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

@ -27,8 +27,10 @@ async function runTest(input, url) {
"The length of the inputStream matches: " + input.length
);
// FIXME: SpecialPowers.spawn currently crashes when trying to return
// values containing input streams.
/* eslint-disable no-shadow */
let dataBack = await SpecialPowers.spawn(browser, [data], function(data) {
let dataBack = await ContentTask.spawn(browser, data, function(data) {
let dataBack = {
inputStream: data.inputStream,
check: true,

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

@ -25,15 +25,13 @@ async function test_navigation(nextPage, cancelContentJSPref, shouldCancel) {
opening: TEST_PAGE,
});
const loopEnded = SpecialPowers.spawn(
tab.linkedBrowser,
[],
async function() {
return new Promise(resolve => {
content.window.addEventListener("LongLoopEnded", resolve);
const loopEnded = ContentTask.spawn(tab.linkedBrowser, [], async function() {
await new Promise(resolve => {
content.addEventListener("LongLoopEnded", resolve, {
once: true,
});
}
);
});
});
// Wait for the test page's long-running JS loop to start; it happens ~500ms
// after load.

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

@ -617,9 +617,9 @@ async function testFileAccess() {
ok(test.file.exists(), `${test.file.path} exists`);
}
let result = await SpecialPowers.spawn(
let result = await ContentTask.spawn(
test.browser,
[test.file.path],
test.file.path,
test.func
);

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

@ -278,11 +278,7 @@ class ContentPage {
}
spawn(params, task) {
return this.browser.ownerGlobal.SpecialPowers.spawn(
this.browser,
[params],
task
);
return ContentTask.spawn(this.browser, params, task);
}
async close() {

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

@ -450,5 +450,5 @@ async function testToggleHelper(browser, videoID, canToggle) {
// Click on the very top-left pixel of the document and ensure that we
// see all of the mouse events for it.
await BrowserTestUtils.synthesizeMouseAtPoint(1, 1, {}, browser);
assertSawMouseEvents(browser, true);
await assertSawMouseEvents(browser, true);
}

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

@ -337,18 +337,17 @@ add_task(async function test_datepicker_clicked() {
`data:text/html, <input type="date" value="${inputValue}">`
);
// Click the first item (top-left corner) of the calendar
let promise = BrowserTestUtils.waitForContentEvent(
helper.tab.linkedBrowser,
"input"
);
helper.click(helper.getElement(DAYS_VIEW).children[0]);
await SpecialPowers.spawn(helper.tab.linkedBrowser, [], async function() {
let inputEl = content.document.querySelector("input");
await ContentTaskUtils.waitForEvent(inputEl, "input");
});
await promise;
let value = await SpecialPowers.spawn(
gBrowser.selectedBrowser,
helper.tab.linkedBrowser,
[],
async () => {
return content.document.querySelector("input").value;
}
() => content.document.querySelector("input").value
);
Assert.equal(value, firstDayOnCalendar);

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

@ -19,8 +19,6 @@
<script type="application/javascript"><![CDATA[
const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
;
ContentTask.setTestScope(window.arguments[0]);
var gPrefsvc = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
var gFindBar = null;

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

@ -18,8 +18,6 @@
<script type="application/javascript"><![CDATA[
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
;
ContentTask.setTestScope(window.arguments[0]);
var gFindBar = null;
var gBrowser;

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

@ -15,8 +15,6 @@
<script type="application/javascript"><![CDATA[
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
;
ContentTask.setTestScope(window.arguments[0]);
const SEARCH_TEXT = "minefield";
let gFindBar = null;

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

@ -18,8 +18,6 @@
<script type="application/javascript"><![CDATA[
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
;
ContentTask.setTestScope(window.arguments[0]);
var gFindBar = null;
var gBrowser;
@ -47,8 +45,9 @@
info("Starting test with browser '" + browserId + "'");
gBrowser = document.getElementById(browserId);
gFindBar.browser = gBrowser;
let promise = BrowserTestUtils.browserLoaded(gBrowser);
BrowserTestUtils.loadURI(gBrowser, "data:text/html,hello there");
const url = "data:text/html,hello there";
let promise = BrowserTestUtils.browserLoaded(gBrowser, false, url);
BrowserTestUtils.loadURI(gBrowser, url);
await promise;
await onDocumentLoaded();
}

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

@ -21,8 +21,6 @@
<script type="application/javascript"><![CDATA[
const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
;
ContentTask.setTestScope(window.arguments[0]);
var gPrefsvc = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);

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

@ -78,13 +78,9 @@ async function testCopyPaste(isPrivate) {
let browser = tab.linkedBrowser;
// Sanitize environment
await SpecialPowers.spawn(
browser,
[SHORT_STRING_NO_CACHE],
async shortStr => {
await content.navigator.clipboard.writeText(shortStr);
}
);
await ContentTask.spawn(browser, SHORT_STRING_NO_CACHE, async shortStr => {
await content.navigator.clipboard.writeText(shortStr);
});
let initialFdCount = getClipboardCacheFDCount();