fune/browser/base/content/test/about/browser_bug435325.js
Nika Layzell 42028efc71 Bug 1671983 - Part 4: Stop awaiting BrowserTestUtils.loadURI, r=annyG,remote-protocol-reviewers,extension-reviewers,preferences-reviewers,whimboo,zombie
This method only is async in order to allow callers to wait for a process switch
triggered by the call to `loadURI` to be finished before resolving. With
DocumentChannel, we should never trigger a process switch eagerly like this
again, so we don't need any of the async behaviour here anymore.

This part is largely mechanical changes to tests, removing the `await` calls on
`loadURI`, and a follow-up part will remove the actual async logic from
`BrowserTestUtils.loadURI`.

Differential Revision: https://phabricator.services.mozilla.com/D94641
2020-11-12 18:01:03 +00:00

57 lines
1.9 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* Ensure that clicking the button in the Offline mode neterror page makes the browser go online. See bug 435325. */
add_task(async function checkSwitchPageToOnlineMode() {
// Go offline and disable the proxy and cache, then try to load the test URL.
Services.io.offline = true;
// Tests always connect to localhost, and per bug 87717, localhost is now
// reachable in offline mode. To avoid this, disable any proxy.
let proxyPrefValue = SpecialPowers.getIntPref("network.proxy.type");
await SpecialPowers.pushPrefEnv({
set: [
["network.proxy.type", 0],
["browser.cache.disk.enable", false],
["browser.cache.memory.enable", false],
],
});
await BrowserTestUtils.withNewTab("about:blank", async function(browser) {
let netErrorLoaded = BrowserTestUtils.waitForErrorPage(browser);
BrowserTestUtils.loadURI(browser, "http://example.com/");
await netErrorLoaded;
// Re-enable the proxy so example.com is resolved to localhost, rather than
// the actual example.com.
await SpecialPowers.pushPrefEnv({
set: [["network.proxy.type", proxyPrefValue]],
});
let changeObserved = TestUtils.topicObserved(
"network:offline-status-changed"
);
// Click on the 'Try again' button.
await SpecialPowers.spawn(browser, [], async function() {
ok(
content.document.documentURI.startsWith("about:neterror?e=netOffline"),
"Should be showing error page"
);
content.document
.querySelector("#netErrorButtonContainer > .try-again")
.click();
});
await changeObserved;
ok(
!Services.io.offline,
"After clicking the 'Try Again' button, we're back online."
);
});
});
registerCleanupFunction(function() {
Services.io.offline = false;
});