diff --git a/accessible/tests/browser/head.js b/accessible/tests/browser/head.js
index 0524b4789c58..6ad237096351 100644
--- a/accessible/tests/browser/head.js
+++ b/accessible/tests/browser/head.js
@@ -130,8 +130,14 @@ function waitForEvent(eventType, expectedId) {
let eventObserver = {
observe(subject) {
let event = subject.QueryInterface(Ci.nsIAccessibleEvent);
+ let id;
+ try {
+ id = event.accessible.id;
+ } catch (e) {
+ // This can throw NS_ERROR_FAILURE.
+ }
if (event.eventType === eventType &&
- event.accessible.id === expectedId) {
+ id === expectedId) {
Services.obs.removeObserver(this, "accessible-event");
resolve(event);
}
diff --git a/browser/base/content/test/alerts/browser_notification_do_not_disturb.js b/browser/base/content/test/alerts/browser_notification_do_not_disturb.js
index d66e12304bb6..7b23e96262e5 100644
--- a/browser/base/content/test/alerts/browser_notification_do_not_disturb.js
+++ b/browser/base/content/test/alerts/browser_notification_do_not_disturb.js
@@ -35,12 +35,11 @@ function test() {
addNotificationPermission(notificationURL).then(function openTab() {
tab = BrowserTestUtils.addTab(gBrowser, notificationURL);
gBrowser.selectedTab = tab;
- tab.linkedBrowser.addEventListener("load", onLoad, true);
+ BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => onLoad());
});
}
function onLoad() {
- tab.linkedBrowser.removeEventListener("load", onLoad, true);
openNotification(tab.linkedBrowser, "showNotification2").then(onAlertShowing);
}
diff --git a/browser/base/content/test/alerts/browser_notification_remove_permission.js b/browser/base/content/test/alerts/browser_notification_remove_permission.js
index a6fdd5042edb..50e128404c16 100644
--- a/browser/base/content/test/alerts/browser_notification_remove_permission.js
+++ b/browser/base/content/test/alerts/browser_notification_remove_permission.js
@@ -16,12 +16,11 @@ function test() {
addNotificationPermission(notificationURL).then(function openTab() {
tab = BrowserTestUtils.addTab(gBrowser, notificationURL);
gBrowser.selectedTab = tab;
- tab.linkedBrowser.addEventListener("load", onLoad, true);
+ BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => onLoad());
});
}
function onLoad() {
- tab.linkedBrowser.removeEventListener("load", onLoad, true);
openNotification(tab.linkedBrowser, "showNotification2").then(onAlertShowing);
}
diff --git a/browser/base/content/test/general/browser_blockHPKP.js b/browser/base/content/test/general/browser_blockHPKP.js
index 26c97cd56a24..a545fe678c7f 100644
--- a/browser/base/content/test/general/browser_blockHPKP.js
+++ b/browser/base/content/test/general/browser_blockHPKP.js
@@ -49,9 +49,7 @@ function test() {
function loadPinningPage() {
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kPinningDomain + kURLPath + "valid").then(function() {
- gBrowser.selectedBrowser.addEventListener("load",
- successfulPinningPageListener,
- true);
+ BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => successfulPinningPageListener.handleEvent());
});
}
@@ -59,7 +57,6 @@ function loadPinningPage() {
// fail to validate
var successfulPinningPageListener = {
handleEvent() {
- gBrowser.selectedBrowser.removeEventListener("load", this, true);
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, "https://" + kBadPinningDomain).then(function() {
return BrowserTestUtils.waitForErrorPage(gBrowser.selectedBrowser);
}).then(errorPageLoaded);
diff --git a/browser/base/content/test/general/browser_bug406216.js b/browser/base/content/test/general/browser_bug406216.js
index 96a69c4f6325..d010950df29b 100644
--- a/browser/base/content/test/general/browser_bug406216.js
+++ b/browser/base/content/test/general/browser_bug406216.js
@@ -24,10 +24,10 @@ function addTab(aURI, aIndex) {
if (aIndex == 0)
gBrowser.removeTab(gBrowser.tabs[0], {skipPermitUnload: true});
- tab.linkedBrowser.addEventListener("load", function(event) {
+ BrowserTestUtils.browserLoaded(tab.linkedBrowser).then(() => {
if (++count == URIS.length)
executeSoon(doTabsTest);
- }, {capture: true, once: true});
+ });
}
function doTabsTest() {
diff --git a/browser/base/content/test/general/browser_bug432599.js b/browser/base/content/test/general/browser_bug432599.js
index 8853c958070c..ee92798a6ffa 100644
--- a/browser/base/content/test/general/browser_bug432599.js
+++ b/browser/base/content/test/general/browser_bug432599.js
@@ -45,11 +45,11 @@ function test() {
waitForExplicitFinish();
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- gBrowser.selectedBrowser.addEventListener("load", function() {
+ BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
waitForStarChange(false, initTest);
- }, {capture: true, once: true});
+ });
- content.location = testURL;
+ gBrowser.loadURI(testURL);
}
function initTest() {
diff --git a/browser/base/content/test/general/browser_bug479408.js b/browser/base/content/test/general/browser_bug479408.js
index 77c607b6499c..1c81f1ecdadc 100644
--- a/browser/base/content/test/general/browser_bug479408.js
+++ b/browser/base/content/test/general/browser_bug479408.js
@@ -3,7 +3,7 @@ function test() {
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser,
"http://mochi.test:8888/browser/browser/base/content/test/general/browser_bug479408_sample.html");
- gBrowser.addEventListener("DOMLinkAdded", function(aEvent) {
+ BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "DOMLinkAdded", true).then(() => {
executeSoon(function() {
ok(!tab.linkedBrowser.engines,
"the subframe's search engine wasn't detected");
@@ -11,5 +11,5 @@ function test() {
gBrowser.removeTab(tab);
finish();
});
- }, {capture: true, once: true});
+ });
}
diff --git a/browser/base/content/test/general/browser_bug567306.js b/browser/base/content/test/general/browser_bug567306.js
index 54a1305638cc..16e6c26ba357 100644
--- a/browser/base/content/test/general/browser_bug567306.js
+++ b/browser/base/content/test/general/browser_bug567306.js
@@ -11,14 +11,12 @@ add_task(async function() {
let selectedBrowser = newwindow.gBrowser.selectedBrowser;
await new Promise((resolve, reject) => {
- selectedBrowser.addEventListener("pageshow", function pageshowListener() {
- if (selectedBrowser.currentURI.spec == "about:blank")
- return;
-
- selectedBrowser.removeEventListener("pageshow", pageshowListener, true);
- ok(true, "pageshow listener called: " + newwindow.content.location);
+ BrowserTestUtils.waitForContentEvent(selectedBrowser, "pageshow", true, (event) => {
+ return content.location.href != "about:blank";
+ }).then(function pageshowListener() {
+ ok(true, "pageshow listener called: " + newwindow.gBrowser.currentURI.spec);
resolve();
- }, true);
+ });
selectedBrowser.loadURI("data:text/html,
Select Me
");
});
diff --git a/browser/base/content/test/general/browser_bug581253.js b/browser/base/content/test/general/browser_bug581253.js
index 3708727072f7..8cfbcf7c990b 100644
--- a/browser/base/content/test/general/browser_bug581253.js
+++ b/browser/base/content/test/general/browser_bug581253.js
@@ -24,8 +24,7 @@ add_task(async function test_remove_bookmark_with_tag_via_edit_bookmark() {
Assert.ok(await PlacesUtils.bookmarks.fetch({url: testURL}), "the test url is bookmarked");
- // eslint-disable-next-line mozilla/no-cpows-in-tests
- content.location = testURL;
+ gBrowser.loadURI(testURL);
await BrowserTestUtils.waitForCondition(
() => BookmarkingUI.status == BookmarkingUI.STATUS_STARRED,
diff --git a/browser/base/content/test/general/browser_bug767836_perwindowpb.js b/browser/base/content/test/general/browser_bug767836_perwindowpb.js
index 8307277ac2da..923de42f9450 100644
--- a/browser/base/content/test/general/browser_bug767836_perwindowpb.js
+++ b/browser/base/content/test/general/browser_bug767836_perwindowpb.js
@@ -76,12 +76,13 @@ function openNewTab(aWindow, aCallback) {
let browser = aWindow.gBrowser.selectedBrowser;
// eslint-disable-next-line mozilla/no-cpows-in-tests
- if (browser.contentDocument.readyState === "complete") {
+ let doc = browser.contentDocumentAsCPOW;
+ if (doc && doc.readyState === "complete") {
executeSoon(aCallback);
return;
}
- browser.addEventListener("load", function() {
+ BrowserTestUtils.browserLoaded(browser).then(() => {
executeSoon(aCallback);
- }, {capture: true, once: true});
+ });
}
diff --git a/browser/base/content/test/general/browser_bug817947.js b/browser/base/content/test/general/browser_bug817947.js
index 24d118f0cd97..ce28c747b9f6 100644
--- a/browser/base/content/test/general/browser_bug817947.js
+++ b/browser/base/content/test/general/browser_bug817947.js
@@ -47,8 +47,8 @@ function preparePendingTab(aCallback) {
});
}
-function whenLoaded(aElement, aCallback) {
- aElement.addEventListener("load", function() {
+function whenLoaded(aBrowser, aCallback) {
+ BrowserTestUtils.browserLoaded(aBrowser).then(() => {
executeSoon(aCallback);
- }, {capture: true, once: true});
+ });
}
diff --git a/browser/base/content/test/general/browser_favicon_change_not_in_document.js b/browser/base/content/test/general/browser_favicon_change_not_in_document.js
index 55c0288fadd4..3ad14277bcd7 100644
--- a/browser/base/content/test/general/browser_favicon_change_not_in_document.js
+++ b/browser/base/content/test/general/browser_favicon_change_not_in_document.js
@@ -20,8 +20,8 @@ add_task(async function() {
let domLinkChangedFired = 0;
const linkAddedHandler = event => domLinkAddedFired++;
const linkChangedhandler = event => domLinkChangedFired++;
- gBrowser.addEventListener("DOMLinkAdded", linkAddedHandler);
- gBrowser.addEventListener("DOMLinkChanged", linkChangedhandler);
+ BrowserTestUtils.addContentEventListener(gBrowser.selectedBrowser, "DOMLinkAdded", linkAddedHandler);
+ BrowserTestUtils.addContentEventListener(gBrowser.selectedBrowser, "DOMLinkChanged", linkChangedhandler);
extraTab.linkedBrowser.loadURI(TEST_URL);
let expectedFavicon = "http://example.org/yet-another-icon";
await promiseTabLoaded(extraTab);
@@ -39,7 +39,5 @@ add_task(async function() {
is(domLinkAddedFired, 2, "Should fire the correct number of DOMLinkAdded event.");
is(domLinkChangedFired, 0, "Should not fire any DOMLinkChanged event.");
- gBrowser.removeEventListener("DOMLinkAdded", linkAddedHandler);
- gBrowser.removeEventListener("DOMLinkChanged", linkChangedhandler);
gBrowser.removeTab(extraTab);
});
diff --git a/browser/base/content/test/general/browser_gZipOfflineChild.js b/browser/base/content/test/general/browser_gZipOfflineChild.js
index 5dcb1cf45f5e..5312e8a9b5a8 100644
--- a/browser/base/content/test/general/browser_gZipOfflineChild.js
+++ b/browser/base/content/test/general/browser_gZipOfflineChild.js
@@ -13,16 +13,20 @@ registerCleanupFunction(function() {
Services.prefs.clearUserPref("offline-apps.allow_by_default");
});
-var cacheCount = 0;
-var intervalID = 0;
-
//
// Handle "message" events which are posted from the iframe upon
// offline cache events.
//
-function handleMessageEvents(event) {
- cacheCount++;
- switch (cacheCount) {
+function contentTask() {
+ let resolve;
+ let promise = new Promise(r => { resolve = r; });
+
+ var cacheCount = 0;
+ var intervalID = 0;
+
+ function handleMessageEvents(event) {
+ cacheCount++;
+ switch (cacheCount) {
case 1:
// This is the initial caching off offline data.
is(event.data, "oncache", "Child was successfully cached.");
@@ -54,12 +58,16 @@ function handleMessageEvents(event) {
case 2:
is(event.data, "onupdate", "Child was successfully updated.");
clearInterval(intervalID);
- finish();
+ resolve();
break;
default:
// how'd we get here?
ok(false, "cacheCount not 1 or 2");
+ }
}
+
+ content.addEventListener("message", handleMessageEvents);
+ return promise;
}
function test() {
@@ -72,9 +80,6 @@ function test() {
registerCleanupFunction(() => gBrowser.removeCurrentTab());
BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
- // eslint-disable-next-line mozilla/no-cpows-in-tests
- let window = gBrowser.selectedBrowser.contentWindow;
-
- window.addEventListener("message", handleMessageEvents);
+ ContentTask.spawn(gBrowser.selectedBrowser, null, contentTask).then(finish);
});
}
diff --git a/browser/base/content/test/general/browser_keywordBookmarklets.js b/browser/base/content/test/general/browser_keywordBookmarklets.js
index 4594c9d45706..c995c38eeb3e 100644
--- a/browser/base/content/test/general/browser_keywordBookmarklets.js
+++ b/browser/base/content/test/general/browser_keywordBookmarklets.js
@@ -45,9 +45,5 @@ add_task(async function test_keyword_bookmarklet() {
});
function promisePageShow() {
- return new Promise(resolve => {
- gBrowser.selectedBrowser.addEventListener("pageshow", function() {
- resolve();
- }, {once: true});
- });
+ return BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "pageshow");
}
diff --git a/browser/base/content/test/general/browser_keywordSearch.js b/browser/base/content/test/general/browser_keywordSearch.js
index 65d49374edef..e4a2c0a0ebf2 100644
--- a/browser/base/content/test/general/browser_keywordSearch.js
+++ b/browser/base/content/test/general/browser_keywordSearch.js
@@ -36,6 +36,45 @@ function test() {
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
+ // We use a web progress listener in the content process to cancel
+ // the request. For everything else, we can do the work in the
+ // parent, since it's easier.
+ ContentTask.spawn(gBrowser.selectedBrowser, null, function* gen() {
+ const Ci = Components.interfaces;
+
+ let listener = {
+ onStateChange: function onLocationChange(webProgress, req, flags, status) {
+ let docStart = Ci.nsIWebProgressListener.STATE_IS_DOCUMENT |
+ Ci.nsIWebProgressListener.STATE_START;
+ if (!(flags & docStart)) {
+ return;
+ }
+
+ req.cancel(Components.results.NS_ERROR_FAILURE);
+ },
+
+ QueryInterface: function QueryInterface(aIID) {
+ if (aIID.equals(Ci.nsIWebProgressListener) ||
+ aIID.equals(Ci.nsIWebProgressListener2) ||
+ aIID.equals(Ci.nsISupportsWeakReference) ||
+ aIID.equals(Ci.nsISupports)) {
+ return this;
+ }
+
+ throw Components.results.NS_ERROR_NO_INTERFACE;
+ }
+ };
+
+ let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIWebProgress);
+ webProgress.addProgressListener(listener,
+ Ci.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
+
+ addEventListener("unload", () => {
+ webProgress.removeProgressListener(listener);
+ });
+ });
+
let listener = {
onStateChange: function onLocationChange(webProgress, req, flags, status) {
// Only care about document starts
@@ -50,11 +89,10 @@ function test() {
is(req.originalURI.spec, gCurrTest.searchURL, "search URL was loaded");
info("Actual URI: " + req.URI.spec);
- req.cancel(Components.results.NS_ERROR_FAILURE);
-
executeSoon(nextTest);
}
};
+
gBrowser.addProgressListener(listener);
registerCleanupFunction(function() {
diff --git a/browser/base/content/test/general/browser_keywordSearch_postData.js b/browser/base/content/test/general/browser_keywordSearch_postData.js
index fdf3ff54dbac..13c453ee719e 100644
--- a/browser/base/content/test/general/browser_keywordSearch_postData.js
+++ b/browser/base/content/test/general/browser_keywordSearch_postData.js
@@ -68,7 +68,7 @@ function doTest() {
waitForLoad(function() {
// eslint-disable-next-line mozilla/no-cpows-in-tests
- let loadedText = gBrowser.contentDocument.body.textContent;
+ let loadedText = gBrowser.contentDocumentAsCPOW.body.textContent;
ok(loadedText, "search page loaded");
let needle = "searchterms=" + gCurrTest.expectText;
is(loadedText, needle, "The query POST data should be returned in the response");
@@ -84,12 +84,11 @@ function doTest() {
function waitForLoad(cb) {
let browser = gBrowser.selectedBrowser;
- browser.addEventListener("load", function listener() {
- if (browser.currentURI.spec == "about:blank")
- return;
+ function wantLoad(url) {
+ return url != "about:blank";
+ }
+ BrowserTestUtils.browserLoaded(browser, false, wantLoad).then(() => {
info("Page loaded: " + browser.currentURI.spec);
- browser.removeEventListener("load", listener, true);
-
cb();
}, true);
}
diff --git a/browser/base/content/test/general/browser_star_hsts.js b/browser/base/content/test/general/browser_star_hsts.js
index 90ce54a6df8f..42999ef777ea 100644
--- a/browser/base/content/test/general/browser_star_hsts.js
+++ b/browser/base/content/test/general/browser_star_hsts.js
@@ -66,19 +66,8 @@ function promiseStarState(aValue) {
function promiseTabLoadEvent(aTab, aURL, aFinalURL) {
if (!aFinalURL)
aFinalURL = aURL;
- return new Promise(resolve => {
- info("Wait for load tab event");
- aTab.linkedBrowser.addEventListener("load", function load(event) {
- if (event.originalTarget != aTab.linkedBrowser.contentDocument ||
- event.target.location.href == "about:blank" ||
- event.target.location.href != aFinalURL) {
- info("skipping spurious load event");
- return;
- }
- aTab.linkedBrowser.removeEventListener("load", load, true);
- info("Tab load event received");
- resolve();
- }, true, true);
- aTab.linkedBrowser.loadURI(aURL);
- });
+
+ info("Wait for load tab event");
+ aTab.linkedBrowser.loadURI(aURL);
+ return BrowserTestUtils.browserLoaded(aTab.linkedBrowser, false, aFinalURL);
}
diff --git a/browser/base/content/test/general/browser_tab_dragdrop2.js b/browser/base/content/test/general/browser_tab_dragdrop2.js
index e6fb8dcdeef0..5ddc76d62ce9 100644
--- a/browser/base/content/test/general/browser_tab_dragdrop2.js
+++ b/browser/base/content/test/general/browser_tab_dragdrop2.js
@@ -39,7 +39,7 @@ add_task(async function() {
// Run tests once again.
let promise = promiseTestsDone(win2);
- win2.content.test_panels();
+ win2.gBrowser.contentWindowAsCPOW.test_panels();
await promise;
ok(true, "tests succeeded a second time");
diff --git a/browser/base/content/test/general/browser_tabfocus.js b/browser/base/content/test/general/browser_tabfocus.js
index d5b942bcbb26..6b48c543e2aa 100644
--- a/browser/base/content/test/general/browser_tabfocus.js
+++ b/browser/base/content/test/general/browser_tabfocus.js
@@ -329,9 +329,7 @@ add_task(async function() {
gURLBar.focus();
await new Promise((resolve, reject) => {
- window.addEventListener("pageshow", function(event) {
- resolve();
- }, {capture: true, once: true});
+ BrowserTestUtils.waitForContentEvent(window.gBrowser.selectedBrowser, "pageshow", true).then(() => resolve());
document.getElementById("Browser:Back").doCommand();
});
diff --git a/browser/base/content/test/general/head.js b/browser/base/content/test/general/head.js
index ab957f6d6121..32fe182fb091 100644
--- a/browser/base/content/test/general/head.js
+++ b/browser/base/content/test/general/head.js
@@ -314,7 +314,8 @@ function whenNewTabLoaded(aWindow, aCallback) {
aWindow.BrowserOpenTab();
let browser = aWindow.gBrowser.selectedBrowser;
- if (browser.contentDocument.readyState === "complete") {
+ let doc = browser.contentDocumentAsCPOW;
+ if (doc && doc.readyState === "complete") {
aCallback();
return;
}
@@ -433,11 +434,11 @@ var FullZoomHelper = {
let didPs = false;
let didZoom = false;
- gBrowser.addEventListener("pageshow", function(event) {
+ BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "pageshow", true).then(() => {
didPs = true;
if (didZoom)
resolve();
- }, {capture: true, once: true});
+ });
if (direction == this.BACK)
gBrowser.goBack();
diff --git a/browser/base/content/test/newtab/head.js b/browser/base/content/test/newtab/head.js
index 359bdc4402c7..a5f1628c850b 100644
--- a/browser/base/content/test/newtab/head.js
+++ b/browser/base/content/test/newtab/head.js
@@ -40,50 +40,59 @@ requiredSize.innerWidth =
(3 * (290 + 20)) + // 3 cols * (tile width + side margins)
100; // breathing room
-var oldSize = {};
-Object.keys(requiredSize).forEach(prop => {
- info([prop, gBrowser.contentWindow[prop], requiredSize[prop]]);
- if (gBrowser.contentWindow[prop] < requiredSize[prop]) {
- oldSize[prop] = gBrowser.contentWindow[prop];
- info("Changing browser " + prop + " from " + oldSize[prop] + " to " +
- requiredSize[prop]);
- gBrowser.contentWindow[prop] = requiredSize[prop];
- }
-});
-
-var screenHeight = {};
-var screenWidth = {};
-Cc["@mozilla.org/gfx/screenmanager;1"].
- getService(Ci.nsIScreenManager).
- primaryScreen.
- GetAvailRectDisplayPix({}, {}, screenWidth, screenHeight);
-screenHeight = screenHeight.value;
-screenWidth = screenWidth.value;
-
-if (screenHeight < gBrowser.contentWindow.outerHeight) {
- info("Warning: Browser outer height is now " +
- gBrowser.contentWindow.outerHeight + ", which is larger than the " +
- "available screen height, " + screenHeight +
- ". That may cause problems.");
-}
-
-if (screenWidth < gBrowser.contentWindow.outerWidth) {
- info("Warning: Browser outer width is now " +
- gBrowser.contentWindow.outerWidth + ", which is larger than the " +
- "available screen width, " + screenWidth +
- ". That may cause problems.");
-}
-
-registerCleanupFunction(function() {
- while (gWindow.gBrowser.tabs.length > 1)
- gWindow.gBrowser.removeTab(gWindow.gBrowser.tabs[1]);
-
- Object.keys(oldSize).forEach(prop => {
- if (oldSize[prop]) {
- gBrowser.contentWindow[prop] = oldSize[prop];
- }
+add_task(async function setupWindowSize() {
+ let [oldSize, curWidth, curHeight] = await ContentTask.spawn(gBrowser.selectedBrowser, requiredSize, (requiredSizeArg) => {
+ var oldSizeVar = {};
+ Object.keys(requiredSizeArg).forEach(prop => {
+ info([prop, content[prop], requiredSizeArg[prop]]);
+ if (content[prop] < requiredSizeArg[prop]) {
+ oldSizeVar[prop] = content[prop];
+ info("Changing browser " + prop + " from " + oldSizeVar[prop] + " to " +
+ requiredSizeArg[prop]);
+ content[prop] = requiredSizeArg[prop];
+ }
+ });
+ return [oldSizeVar, content.outerWidth, content.outerHeight];
});
+ var screenHeight = {};
+ var screenWidth = {};
+ Cc["@mozilla.org/gfx/screenmanager;1"].
+ getService(Ci.nsIScreenManager).
+ primaryScreen.
+ GetAvailRectDisplayPix({}, {}, screenWidth, screenHeight);
+ screenHeight = screenHeight.value;
+ screenWidth = screenWidth.value;
+
+ if (screenHeight < curHeight) {
+ info("Warning: Browser outer height is now " +
+ curHeight + ", which is larger than the " +
+ "available screen height, " + screenHeight +
+ ". That may cause problems.");
+ }
+
+ if (screenWidth < curWidth) {
+ info("Warning: Browser outer width is now " +
+ curWidth + ", which is larger than the " +
+ "available screen width, " + screenWidth +
+ ". That may cause problems.");
+ }
+
+ registerCleanupFunction(function() {
+ while (gWindow.gBrowser.tabs.length > 1)
+ gWindow.gBrowser.removeTab(gWindow.gBrowser.tabs[1]);
+
+ ContentTask.spawn(gBrowser.selectedBrowser, oldSize, (oldSizeArg) => {
+ Object.keys(oldSizeArg).forEach(prop => {
+ if (oldSizeArg[prop]) {
+ content[prop] = oldSizeArg[prop];
+ }
+ });
+ });
+ });
+});
+
+registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF_NEWTAB_ENABLED);
Services.prefs.clearUserPref(PREF_NEWTAB_ACTIVITY_STREAM);
Services.prefs.setCharPref(PREF_NEWTAB_DIRECTORYSOURCE, gOrigDirectorySource);
diff --git a/browser/base/content/test/pageinfo/browser_pageInfo.js b/browser/base/content/test/pageinfo/browser_pageInfo.js
index 765223723fa6..a2ebd43d22b8 100644
--- a/browser/base/content/test/pageinfo/browser_pageInfo.js
+++ b/browser/base/content/test/pageinfo/browser_pageInfo.js
@@ -4,12 +4,11 @@ function test() {
var pageInfo;
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- gBrowser.selectedBrowser.addEventListener("load", function() {
+ BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
Services.obs.addObserver(observer, "page-info-dialog-loaded");
pageInfo = BrowserPageInfo();
- }, {capture: true, once: true});
- content.location =
- "https://example.com/browser/browser/base/content/test/pageinfo/feed_tab.html";
+ });
+ gBrowser.selectedBrowser.loadURI("https://example.com/browser/browser/base/content/test/pageinfo/feed_tab.html");
function observer(win, topic, data) {
Services.obs.removeObserver(observer, "page-info-dialog-loaded");
diff --git a/browser/base/content/test/pageinfo/browser_pageinfo_firstPartyIsolation.js b/browser/base/content/test/pageinfo/browser_pageinfo_firstPartyIsolation.js
index 7da1799e72cf..99f3f256d4e0 100644
--- a/browser/base/content/test/pageinfo/browser_pageinfo_firstPartyIsolation.js
+++ b/browser/base/content/test/pageinfo/browser_pageinfo_firstPartyIsolation.js
@@ -72,8 +72,8 @@ async function test() {
});
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- content.location = "https://example.com/browser/browser/base/content/test/pageinfo/image.html";
- await waitForEvent(gBrowser.selectedBrowser, "load");
+ gBrowser.selectedBrowser.loadURI("https://example.com/browser/browser/base/content/test/pageinfo/image.html");
+ await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
let spec = gBrowser.selectedBrowser.currentURI.spec;
diff --git a/browser/base/content/test/pageinfo/browser_pageinfo_image_info.js b/browser/base/content/test/pageinfo/browser_pageinfo_image_info.js
index d9ad8f68e920..6e1ceffa35ea 100644
--- a/browser/base/content/test/pageinfo/browser_pageinfo_image_info.js
+++ b/browser/base/content/test/pageinfo/browser_pageinfo_image_info.js
@@ -13,9 +13,9 @@ function test() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- gBrowser.selectedBrowser.addEventListener("load", function() {
+ BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(function() {
// eslint-disable-next-line mozilla/no-cpows-in-tests
- var doc = gBrowser.contentDocument;
+ var doc = gBrowser.contentDocumentAsCPOW;
var testImg = doc.getElementById("test-image");
var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
"mediaTab", getImageInfo(testImg));
@@ -35,14 +35,14 @@ function test() {
});
});
}, {capture: true, once: true});
- }, {capture: true, once: true});
+ });
- content.location =
+ gBrowser.loadURI(
"data:text/html," +
"" +
"" +
"" +
"" +
"" +
- "";
+ "");
}
diff --git a/browser/base/content/test/pageinfo/browser_pageinfo_images.js b/browser/base/content/test/pageinfo/browser_pageinfo_images.js
index 053c3f85e9ff..78ce46265ee9 100644
--- a/browser/base/content/test/pageinfo/browser_pageinfo_images.js
+++ b/browser/base/content/test/pageinfo/browser_pageinfo_images.js
@@ -5,7 +5,7 @@ function test() {
gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
- gBrowser.selectedBrowser.addEventListener("load", function() {
+ BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser).then(() => {
var pageInfo = BrowserPageInfo(gBrowser.selectedBrowser.currentURI.spec,
"mediaTab");
@@ -26,9 +26,9 @@ function test() {
});
});
}, {capture: true, once: true});
- }, {capture: true, once: true});
+ });
- content.location =
+ gBrowser.selectedBrowser.loadURI(
"data:text/html," +
"" +
" " +
@@ -44,5 +44,5 @@ function test() {
" test link" + // Cursor
" " + // Object
" " +
- "";
+ "