Bug 1596918: Part 4e - Fix callers which rely on frame message manager globals. r=mccr8

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kris Maglione 2019-12-07 18:44:35 +00:00
Родитель 8c28f5ff8d
Коммит 63b8ddb1c0
18 изменённых файлов: 50 добавлений и 39 удалений

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

@ -2,3 +2,8 @@ ChromeUtils.import("resource:///modules/SitePermissions.jsm", this);
const { PermissionTestUtils } = ChromeUtils.import(
"resource://testing-common/PermissionTestUtils.jsm"
);
SpecialPowers.addTaskImport(
"E10SUtils",
"resource://gre/modules/E10SUtils.jsm"
);

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

@ -18,7 +18,7 @@ async function checkState(browser) {
// Now go back. This should trigger the popstate event handler.
let popstatePromise = SpecialPowers.spawn(browser, [], async () => {
let event = await ContentTaskUtils.waitForEvent(this, "popstate", true);
let event = await ContentTaskUtils.waitForEvent(content, "popstate", true);
ok(event.state, "Event should have a state property.");
is(content.testState, "foo", "testState after going back");
@ -47,7 +47,7 @@ async function checkState(browser) {
await popstatePromise;
popstatePromise = SpecialPowers.spawn(browser, [], async () => {
let event = await ContentTaskUtils.waitForEvent(this, "popstate", true);
let event = await ContentTaskUtils.waitForEvent(content, "popstate", true);
// When content fires a PopStateEvent and we observe it from a chrome event
// listener (as we do here, and, thankfully, nowhere else in the tree), the

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

@ -237,7 +237,7 @@ async function contentSetUp() {
var select = document.querySelector("select#scaleSelect");
select.selectedIndex = 2;
select.dispatchEvent(new Event("change"));
select.dispatchEvent(new content.Event("change"));
});
}
@ -305,7 +305,7 @@ async function runTests(browser) {
);
el.dispatchEvent(ev);
} else {
ev = new Event(test.action.event);
ev = new content.Event(test.action.event);
}
el.dispatchEvent(ev);

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

@ -139,7 +139,7 @@ add_task(async function test() {
}
// Dispatch the event for changing the zoom
ev = new Event(subTest.action.event);
ev = new content.Event(subTest.action.event);
} else {
// We zoom using keyboard
// Simulate key press

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

@ -17,7 +17,10 @@ add_task(async function testRemoveSubtree() {
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() {
function ignoreNode(node) {
// Duplicate the walker logic to skip blank nodes...
return node.nodeType === Node.TEXT_NODE && !/[^\s]/.test(node.nodeValue);
return (
node.nodeType === content.Node.TEXT_NODE &&
!/[^\s]/.test(node.nodeValue)
);
}
let nextSibling = content.document.querySelector("#longlist").nextSibling;

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

@ -12,7 +12,7 @@ add_task(async function() {
const webConsoleFront = target.activeConsole;
// Fetch WebConsoleCommands so that it is available for next Content Tasks
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
const { require } = ChromeUtils.import(
"resource://devtools/shared/Loader.jsm"
);
@ -37,7 +37,7 @@ async function evaluateJSAndCheckResult(webConsoleFront, input, expected) {
}
async function registerNewCommand(webConsoleFront) {
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
this.WebConsoleCommands.register("setFoo", (owner, value) => {
owner.window.foo = value;
return "ok";
@ -55,13 +55,13 @@ async function registerNewCommand(webConsoleFront) {
result: "ok",
});
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
is(content.top.foo, "bar", "top.foo should equal to 'bar'");
});
}
async function wrapCommand(webConsoleFront) {
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
const origKeys = this.WebConsoleCommands.getCommand("keys");
const newKeys = (...args) => {
@ -97,7 +97,7 @@ async function wrapCommand(webConsoleFront) {
},
});
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
this.WebConsoleCommands.register("keys", this.origKeys);
is(
this.WebConsoleCommands.getCommand("keys"),
@ -109,7 +109,7 @@ async function wrapCommand(webConsoleFront) {
}
async function unregisterCommand(webConsoleFront) {
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
this.WebConsoleCommands.unregister("setFoo");
});
@ -123,7 +123,7 @@ async function unregisterCommand(webConsoleFront) {
}
async function registerAccessor(webConsoleFront) {
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
this.WebConsoleCommands.register("$foo", {
get(owner) {
const foo = owner.window.document.getElementById("quack");
@ -138,7 +138,7 @@ async function registerAccessor(webConsoleFront) {
result: ">o_/",
});
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
is(
content.document.getElementById("quack").textContent,
">o_/",
@ -153,7 +153,7 @@ async function registerAccessor(webConsoleFront) {
}
async function unregisterAfterOverridingTwice(webConsoleFront) {
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
this.WebConsoleCommands.register("keys", (owner, obj) => "command 1");
});
@ -162,7 +162,7 @@ async function unregisterAfterOverridingTwice(webConsoleFront) {
result: "command 1",
});
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
const orig = this.WebConsoleCommands.getCommand("keys");
this.WebConsoleCommands.register("keys", (owner, obj) => {
if (obj === "quack") {
@ -180,7 +180,7 @@ async function unregisterAfterOverridingTwice(webConsoleFront) {
result: "bang!",
});
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
await ContentTask.spawn(gBrowser.selectedBrowser, null, function() {
this.WebConsoleCommands.unregister("keys");
});

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

@ -21,7 +21,7 @@ windows.
<script type="application/javascript"><![CDATA[
SimpleTest.waitForExplicitFinish();
const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
;
const {ContentTask} = ChromeUtils.import("resource://testing-common/ContentTask.jsm");
const BROWSER_DOC = "window_chromeOuterWindowID.xhtml";
const TEST_PAGE = "http://example.com";

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

@ -1,11 +1,13 @@
async function idbCheckFunc() {
let factory;
let factory, console;
try {
// in a worker, this resolves directly.
factory = indexedDB;
console = self.console;
} catch (ex) {
// in a frame-script, we need to pierce "content"
factory = content.indexedDB;
console = content.console;
}
try {
console.log("opening db");
@ -75,6 +77,7 @@ const workerScriptBlob = new Blob([workerScript]);
* idbCheckFunc and return the result to us.
*/
async function workerCheckDeployer({ srcBlob, workerType }) {
const { console } = content;
let worker, port;
const url = content.URL.createObjectURL(srcBlob);
if (workerType === "dedicated") {

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

@ -40,7 +40,7 @@ async function testBody(testRoot) {
link.setAttribute("href", testRoot + gStyleSheet);
let stateChanged = ContentTaskUtils.waitForEvent(
this,
docShell.chromeEventHandler,
"StyleSheetApplicableStateChanged",
true
);
@ -59,7 +59,7 @@ async function testBody(testRoot) {
is(evt.applicable, true, "evt.applicable has the right value");
stateChanged = ContentTaskUtils.waitForEvent(
this,
docShell.chromeEventHandler,
"StyleSheetApplicableStateChanged",
true
);

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

@ -64,19 +64,17 @@ function spawnInNewReaderTab(url, func) {
return BrowserTestUtils.withNewTab(
{ gBrowser, url: `about:reader?url=${encodeURIComponent(url)}` },
async function(browser) {
// This imports the test utils for all tests, so we'll declare it as
// a global here which will make it ESLint happy.
/* global NarrateTestUtils */
SpecialPowers.addTaskImport(
"NarrateTestUtils",
"chrome://mochitests/content/browser/" +
"toolkit/components/narrate/test/NarrateTestUtils.jsm"
);
await SpecialPowers.spawn(browser, [], async function() {
// This imports the test utils for all tests, so we'll declare it as
// a global here which will make it ESLint happy.
/* global NarrateTestUtils */
ChromeUtils.import(
"chrome://mochitests/content/browser/" +
"toolkit/components/narrate/test/NarrateTestUtils.jsm",
Cu.getGlobalForObject({})
);
await NarrateTestUtils.getReaderReadyPromise(content);
});
await SpecialPowers.spawn(browser, [], func);
}
);

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

@ -60,7 +60,7 @@ add_task(async () => {
let video = doc.querySelector(`#${videoID}`);
let promise = ContentTaskUtils.waitForEvent(
this,
docShell.chromeEventHandler,
"MozStopPictureInPicture",
{ capture: true }
);

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

@ -29,7 +29,7 @@ async function callMediaPlay(shouldStartPlaying) {
audio.isPlayStarted = true;
resolve();
});
setTimeout(() => {
content.setTimeout(() => {
if (audio.isPlayStarted) {
return;
}

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

@ -210,7 +210,7 @@ function resumeWithoutExpectedSuccess() {
let promise = ac.resume();
ac.resumePromises.push(promise);
return new Promise((resolve, reject) => {
setTimeout(() => {
content.setTimeout(() => {
if (ac.state == "suspended") {
ok(true, "audio context is still suspended");
resolve();

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

@ -91,7 +91,7 @@ function resumeWithoutExpectedSuccess() {
let promise = ac.resume();
ac.resumePromises.push(promise);
return new Promise((resolve, reject) => {
setTimeout(() => {
content.setTimeout(() => {
if (ac.state == "suspended") {
ok(true, "audio context is still suspended");
resolve();

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

@ -87,10 +87,9 @@ add_task(async function test_crash_in_previous_frameloader() {
const { ctypes } = ChromeUtils.import(
"resource://gre/modules/ctypes.jsm"
);
ChromeUtils.import("resource://gre/modules/Timer.jsm");
let dies = function() {
privateNoteIntentionalCrash();
ChromeUtils.privateNoteIntentionalCrash();
let zero = new ctypes.intptr_t(8);
let badptr = ctypes.cast(zero, ctypes.PointerType(ctypes.int32_t));
badptr.contents;

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

@ -18,7 +18,7 @@ function check_autoplay_audio_onplay() {
autoPlay.pause();
autoPlay.play();
setTimeout(() => {
content.setTimeout(() => {
ok(true, "Doesn't receive play event when media was blocked.");
autoPlay.onplay = null;
resolve();

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

@ -20,7 +20,7 @@ function play_not_in_tree_audio() {
content.document.body.removeChild(audio);
// Add timeout to ensure the audio is removed from DOM tree.
setTimeout(function() {
content.setTimeout(function() {
info("Prepare to start playing audio.");
audio.play();
}, 1000);

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

@ -12,6 +12,9 @@ add_task(async function test_getSelectionDetails_input() {
await BrowserTestUtils.withNewTab({ gBrowser, url }, async browser => {
await SpecialPowers.spawn(browser, [], () => {
function checkSelection({ id, text, linkURL }) {
const { BrowserUtils } = ChromeUtils.import(
"resource://gre/modules/BrowserUtils.jsm"
);
content.document.getElementById(id).select();
// It seems that when running as a test, the previous line will set
// the both the window's selection and the input's selection to contain