Skip to content

Commit

Permalink
Bug 1811854 - switch remaining tests to BrowserTestUtils.loadURIStrin…
Browse files Browse the repository at this point in the history
…g from BrowserTestUtils.loadURI, r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D167558
  • Loading branch information
gijsk committed Jan 24, 2023
1 parent 65c86b4 commit 6b5475d
Show file tree
Hide file tree
Showing 37 changed files with 57 additions and 65 deletions.
2 changes: 1 addition & 1 deletion accessible/tests/mochitest/name/test_browserui.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
let docLoaded = waitForEvent(EVENT_DOCUMENT_LOAD_COMPLETE, event =>
event.accessible.QueryInterface(nsIAccessibleDocument).URL === ABOUT_LICENSE_URL,
`Loaded tab: ${ABOUT_LICENSE_URL}`);
BrowserTestUtils.loadURI(win.gBrowser.selectedBrowser,
BrowserTestUtils.loadURIString(win.gBrowser.selectedBrowser,
"about:license");
await loaded;
await docLoaded;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function doUrlbarTest({ trigger, assert }) {

async function doHandoffTest({ trigger, assert }) {
await doTest(async browser => {
BrowserTestUtils.loadURI(browser, "about:newtab");
BrowserTestUtils.loadURIString(browser, "about:newtab");
await BrowserTestUtils.browserStopped(browser, "about:newtab");
await SpecialPowers.spawn(browser, [], function() {
const searchInput = content.document.querySelector(".fake-editable");
Expand All @@ -54,7 +54,7 @@ async function doUrlbarAddonpageTest({ trigger, assert }) {

await doTest(async browser => {
const onLoad = BrowserTestUtils.browserLoaded(browser);
BrowserTestUtils.loadURI(browser, extensionURL);
BrowserTestUtils.loadURIString(browser, extensionURL);
await onLoad;
await openPopup("x");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ var TestRunner = {
.removeAttribute("remotecontrol");

let selectedBrowser = browserWindow.gBrowser.selectedBrowser;
lazy.BrowserTestUtils.loadURI(selectedBrowser, HOME_PAGE);
lazy.BrowserTestUtils.loadURIString(selectedBrowser, HOME_PAGE);
await lazy.BrowserTestUtils.browserLoaded(selectedBrowser);

for (let i = 0; i < this.combos.length; i++) {
Expand Down Expand Up @@ -242,7 +242,7 @@ var TestRunner = {
gBrowser.removeTab(gBrowser.selectedTab, { animate: false });
}
gBrowser.unpinTab(gBrowser.selectedTab);
lazy.BrowserTestUtils.loadURI(
lazy.BrowserTestUtils.loadURIString(
gBrowser.selectedBrowser,
"data:text/html;charset=utf-8,<h1>Done!"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ var ControlCenter = {
"navigator:browser"
);
let gBrowser = browserWindow.gBrowser;
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, channel.file.path);
BrowserTestUtils.loadURIString(
gBrowser.selectedBrowser,
channel.file.path
);
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
await openIdentityPopup();
},
Expand Down Expand Up @@ -290,7 +293,7 @@ var ControlCenter = {
async function loadPage(url) {
let browserWindow = Services.wm.getMostRecentWindow("navigator:browser");
let gBrowser = browserWindow.gBrowser;
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, url);
BrowserTestUtils.loadURIString(gBrowser.selectedBrowser, url);
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser, false, url);
}

Expand Down
8 changes: 4 additions & 4 deletions docshell/test/chrome/bug215405_window.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
var testName = "[nostore]";

// Load a page with a no-store header
BrowserTestUtils.loadURI(gBrowser, nostoreURI);
BrowserTestUtils.loadURIString(gBrowser, nostoreURI);
yield undefined;


Expand All @@ -103,7 +103,7 @@
// Load a new document into the browser
var simple = "data:text/html,<html><head><title>test2</title></head>" +
"<body>test2</body></html>";
BrowserTestUtils.loadURI(gBrowser, simple);
BrowserTestUtils.loadURIString(gBrowser, simple);
yield undefined;


Expand All @@ -127,7 +127,7 @@

// Load a page with a no-cache header. This should not be
// restricted like no-store (bug 567365)
BrowserTestUtils.loadURI(gBrowser, nocacheURI);
BrowserTestUtils.loadURIString(gBrowser, nocacheURI);
yield undefined;


Expand All @@ -150,7 +150,7 @@
isnot(currScrollY, originalYPosition,
testName + " failed to scroll window vertically");

BrowserTestUtils.loadURI(gBrowser, simple);
BrowserTestUtils.loadURIString(gBrowser, simple);
yield undefined;


Expand Down
4 changes: 2 additions & 2 deletions dom/base/test/chrome/test_chromeOuterWindowID.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ windows.
ok(nonRemote && !nonRemote.isRemoteBrowser,
"Should have found a non-remote browser in test window " + num);

BrowserTestUtils.loadURI(remote, page);
BrowserTestUtils.loadURIString(remote, page);
await BrowserTestUtils.browserLoaded(remote);
BrowserTestUtils.loadURI(nonRemote, page);
BrowserTestUtils.loadURIString(nonRemote, page);
await BrowserTestUtils.browserLoaded(nonRemote);

let result = {};
Expand Down
4 changes: 2 additions & 2 deletions dom/events/test/test_bug415498.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=415498

// 1) This document uses addEventListener to register a method throwing an exception
var chromeDir = getRootDirectory(window.location.href);
BrowserTestUtils.loadURI(browser, chromeDir + "bug415498-doc1.html");
BrowserTestUtils.loadURIString(browser, chromeDir + "bug415498-doc1.html");
yield undefined;

ok(verifyErrorReceived("HierarchyRequestError"),
Expand All @@ -72,7 +72,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=415498

// 2) This document sets window.onload to register a method throwing an exception
var chromeDir = getRootDirectory(window.location.href);
BrowserTestUtils.loadURI(browser, chromeDir + "bug415498-doc2.html");
BrowserTestUtils.loadURIString(browser, chromeDir + "bug415498-doc2.html");
yield undefined;

ok(verifyErrorReceived("HierarchyRequestError"),
Expand Down
2 changes: 1 addition & 1 deletion dom/events/test/test_bug617528.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=617528
</div>\
</body>\
</html>';
BrowserTestUtils.loadURI(browser, uri);
BrowserTestUtils.loadURIString(browser, uri);
}

function onPageShow() {
Expand Down
2 changes: 1 addition & 1 deletion dom/media/test/browser/wmfme/browser_wmfme_crash.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ add_task(async function testPlaybackRecoveryFromCrash() {
window.gBrowser,
"about:blank"
);
BrowserTestUtils.loadURI(tab.linkedBrowser, VIDEO_PAGE);
BrowserTestUtils.loadURIString(tab.linkedBrowser, VIDEO_PAGE);
await BrowserTestUtils.browserLoaded(tab.linkedBrowser);

await playVideo(tab);
Expand Down
2 changes: 1 addition & 1 deletion dom/serviceworkers/test/test_privateBrowsing.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
win.addEventListener("load", function() {
win.addEventListener("DOMContentLoaded", function onInnerLoad() {
if (win.content.location.href != contentPage) {
BrowserTestUtils.loadURI(win.gBrowser, contentPage);
BrowserTestUtils.loadURIString(win.gBrowser, contentPage);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions dom/tests/mochitest/beacon/test_beaconCookies.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
ok(true, "cookie set by beacon request in normal window");
testOnPrivateWindow();
}, "cookie-changed");
BrowserTestUtils.loadURI(aNormalWindow.gBrowser.selectedBrowser, baseURL + "file_beaconCookies.html");
BrowserTestUtils.loadURIString(aNormalWindow.gBrowser.selectedBrowser, baseURL + "file_beaconCookies.html");
});
}

Expand All @@ -65,7 +65,7 @@
ok(true, "private cookie set by beacon request in private window");
cleanup();
}, "private-cookie-changed");
BrowserTestUtils.loadURI(aPrivateWindow.gBrowser.selectedBrowser, baseURL + "file_beaconCookies.html");
BrowserTestUtils.loadURIString(aPrivateWindow.gBrowser.selectedBrowser, baseURL + "file_beaconCookies.html");
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
testOnPrivateWindow();
}, "cookie-changed");
let testURL = baseURL + "file_beaconSafelist.html";
BrowserTestUtils.loadURI(win.gBrowser.selectedBrowser, testURL);
BrowserTestUtils.loadURIString(win.gBrowser.selectedBrowser, testURL);
await BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser, false, testURL);
await SpecialPowers.spawn(win.gBrowser.selectedBrowser, [], async () => {
await new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion dom/workers/test/test_sharedWorker_privateBrowsing.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
win.addEventListener("load", function() {
win.addEventListener("DOMContentLoaded", function onInnerLoad() {
if (win.content.location.href != contentPage) {
BrowserTestUtils.loadURI(win.gBrowser, contentPage);
BrowserTestUtils.loadURIString(win.gBrowser, contentPage);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ add_task(async function() {
try {
const browser = win.gBrowser.selectedTab.linkedBrowser;

BrowserTestUtils.loadURI(browser, parentURL);
BrowserTestUtils.loadURIString(browser, parentURL);
await BrowserTestUtils.browserLoaded(browser, false, parentURL);

async function setup(url) {
Expand Down
2 changes: 1 addition & 1 deletion layout/base/tests/browser_bug1791083.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ add_task(async function test() {
// new location.
newWin.resizeTo(50, 50);

BrowserTestUtils.loadURI(newWin.gBrowser.selectedBrowser, URL);
BrowserTestUtils.loadURIString(newWin.gBrowser.selectedBrowser, URL);
await BrowserTestUtils.browserLoaded(newWin.gBrowser.selectedBrowser);

await SpecialPowers.spawn(
Expand Down
4 changes: 2 additions & 2 deletions layout/base/tests/browser_disableDialogs_onbeforeunload.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ async function openPage(enableDialogs) {
{ gBrowser, url: "about:blank" },
async function(browser) {
// Load the page.
BrowserTestUtils.loadURI(browser, PAGE_URL);
BrowserTestUtils.loadURIString(browser, PAGE_URL);
await BrowserTestUtils.browserLoaded(browser);
// Load the content script in the frame.
let methodName = enableDialogs ? "enableDialogs" : "disableDialogs";
await SpecialPowers.spawn(browser, [methodName], async function(name) {
content.windowUtils[name]();
});
// And then navigate away.
BrowserTestUtils.loadURI(browser, "http://example.com/");
BrowserTestUtils.loadURIString(browser, "http://example.com/");
await BrowserTestUtils.browserLoaded(browser);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function openPage(shouldClick) {
{ gBrowser, url: "about:blank" },
async function(browser) {
// Load the page.
BrowserTestUtils.loadURI(browser, PAGE_URL);
BrowserTestUtils.loadURIString(browser, PAGE_URL);
await BrowserTestUtils.browserLoaded(browser);

if (shouldClick) {
Expand All @@ -68,7 +68,7 @@ async function openPage(shouldClick) {
"Click should update document interactivity state"
);
// And then navigate away.
BrowserTestUtils.loadURI(browser, "http://example.com/");
BrowserTestUtils.loadURIString(browser, "http://example.com/");
await BrowserTestUtils.browserLoaded(browser);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function openPage(shouldClick) {
{ gBrowser, url: "about:blank" },
async function(browser) {
// Load the page.
BrowserTestUtils.loadURI(browser, PAGE_URL);
BrowserTestUtils.loadURIString(browser, PAGE_URL);
await BrowserTestUtils.browserLoaded(browser);

let frameBC = browser.browsingContext.children[0];
Expand Down Expand Up @@ -89,7 +89,7 @@ async function openPage(shouldClick) {
"Click should update frame interactivity state"
);
// And then navigate away.
BrowserTestUtils.loadURI(browser, "http://example.com/");
BrowserTestUtils.loadURIString(browser, "http://example.com/");
await BrowserTestUtils.browserLoaded(browser);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ add_task(async function() {
newWin.gBrowser.selectedBrowser,
true /* includeSubFrames */
);
BrowserTestUtils.loadURI(newWin.gBrowser.selectedBrowser, pageUrl);
BrowserTestUtils.loadURIString(newWin.gBrowser.selectedBrowser, pageUrl);
await browserLoadedPromise;

newWin.gBrowser.selectedBrowser.focus();
Expand Down
11 changes: 0 additions & 11 deletions testing/mochitest/BrowserTestUtils/BrowserTestUtils.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -939,17 +939,6 @@ export var BrowserTestUtils = {
});
},

/**
* Compatibility shim. Should go away Very Soon.
* @param {xul:browser} browser
* A xul:browser.
* @param {string} uri
* The URI to load.
*/
loadURI(browser, uri) {
return this.loadURIString(browser, uri);
},

/**
* Maybe create a preloaded browser and ensure it's finished loading.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
subject => subject == win);

let browser = win.gBrowser.selectedBrowser;
BrowserTestUtils.loadURI(browser, aTestData.url);
BrowserTestUtils.loadURIString(browser, aTestData.url);
await BrowserTestUtils.waitForContentEvent(browser, "DOMContentLoaded");

let doc = win.gBrowser.contentDocument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@

var createBlockedIframe = function(aWindow, aBrowser, aTopUrl, aUrl) {
(async function() {
BrowserTestUtils.loadURI(aBrowser, aTopUrl);
BrowserTestUtils.loadURIString(aBrowser, aTopUrl);
await BrowserTestUtils.browserLoaded(aBrowser);

await SpecialPowers.spawn(aBrowser, [aUrl], async function(url) {
Expand All @@ -118,7 +118,7 @@

var createBlockedPage = function(aWindow, aBrowser, aTopUrl, aUrl) {
(async function() {
BrowserTestUtils.loadURI(aBrowser, aTopUrl);
BrowserTestUtils.loadURIString(aBrowser, aTopUrl);
await BrowserTestUtils.waitForContentEvent(aBrowser, "DOMContentLoaded");

let doc = aWindow.gBrowser.contentDocument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
};
win.gBrowser.addProgressListener(progressListener, Ci.nsIWebProgress.NOTIFY_CONTENT_BLOCKING);

BrowserTestUtils.loadURI(browser, aTestData.url);
BrowserTestUtils.loadURIString(browser, aTestData.url);
await BrowserTestUtils.browserLoaded(
browser,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
subject => subject == win).then(() => {
win.addEventListener("DOMContentLoaded", function onInnerLoad() {
if (win.content.location.href != contentPage) {
BrowserTestUtils.loadURI(win.gBrowser, contentPage);
BrowserTestUtils.loadURIString(win.gBrowser, contentPage);
return;
}
win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
Expand All @@ -43,7 +43,7 @@
SimpleTest.executeSoon(function() { aCallback(win); });
}, false, true);
}, true);
SimpleTest.executeSoon(function() { BrowserTestUtils.loadURI(win.gBrowser, contentPage); });
SimpleTest.executeSoon(function() { BrowserTestUtils.loadURIString(win.gBrowser, contentPage); });
});
}, {capture: true, once: true});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
subject => subject == win).then(() => {
win.addEventListener("DOMContentLoaded", function onInnerLoad() {
if (win.content.location.href != contentPage) {
BrowserTestUtils.loadURI(win.gBrowser, contentPage);
BrowserTestUtils.loadURIString(win.gBrowser, contentPage);
return;
}
win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
Expand All @@ -44,7 +44,7 @@
}, false, true);
}, true);
SimpleTest.executeSoon(function() {
BrowserTestUtils.loadURI(win.gBrowser, contentPage);
BrowserTestUtils.loadURIString(win.gBrowser, contentPage);
});
});
}, {capture: true, once: true});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
subject => subject == win).then(() => {
win.addEventListener("DOMContentLoaded", function onInnerLoad() {
if (win.content.location.href != contentPage) {
BrowserTestUtils.loadURI(win.gBrowser, contentPage);
BrowserTestUtils.loadURIString(win.gBrowser, contentPage);
return;
}
win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
Expand All @@ -45,7 +45,7 @@
}, false, true);
}, true);
SimpleTest.executeSoon(function() {
BrowserTestUtils.loadURI(win.gBrowser, contentPage);
BrowserTestUtils.loadURIString(win.gBrowser, contentPage);
});
});
}, {capture: true, once: true});
Expand Down
Loading

0 comments on commit 6b5475d

Please sign in to comment.