diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/base/content/test/general/browser_bug435325.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/base/content/test/general/browser_bug435325.js')
-rw-r--r-- | browser/base/content/test/general/browser_bug435325.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_bug435325.js b/browser/base/content/test/general/browser_bug435325.js new file mode 100644 index 000000000..2ae15deff --- /dev/null +++ b/browser/base/content/test/general/browser_bug435325.js @@ -0,0 +1,69 @@ +/* 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. */ + +var proxyPrefValue; + +function test() { + waitForExplicitFinish(); + + // 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. + proxyPrefValue = Services.prefs.getIntPref("network.proxy.type"); + Services.prefs.setIntPref("network.proxy.type", 0); + + Services.prefs.setBoolPref("browser.cache.disk.enable", false); + Services.prefs.setBoolPref("browser.cache.memory.enable", false); + + gBrowser.selectedTab = gBrowser.addTab("http://example.com/"); + + let contentScript = ` + let listener = function () { + removeEventListener("DOMContentLoaded", listener); + sendAsyncMessage("Test:DOMContentLoaded", { uri: content.document.documentURI }); + }; + addEventListener("DOMContentLoaded", listener); + `; + + function pageloaded({ data }) { + mm.removeMessageListener("Test:DOMContentLoaded", pageloaded); + checkPage(data); + } + + let mm = gBrowser.selectedBrowser.messageManager; + mm.addMessageListener("Test:DOMContentLoaded", pageloaded); + mm.loadFrameScript("data:," + contentScript, true); +} + +function checkPage(data) { + ok(Services.io.offline, "Setting Services.io.offline to true."); + + is(data.uri.substring(0, 27), + "about:neterror?e=netOffline", "Loading the Offline mode neterror page."); + + // Re-enable the proxy so example.com is resolved to localhost, rather than + // the actual example.com. + Services.prefs.setIntPref("network.proxy.type", proxyPrefValue); + + Services.obs.addObserver(function observer(aSubject, aTopic) { + ok(!Services.io.offline, "After clicking the Try Again button, we're back " + + "online."); + Services.obs.removeObserver(observer, "network:offline-status-changed", false); + finish(); + }, "network:offline-status-changed", false); + + ContentTask.spawn(gBrowser.selectedBrowser, null, function* () { + content.document.getElementById("errorTryAgain").click(); + }); +} + +registerCleanupFunction(function() { + Services.prefs.setBoolPref("browser.cache.disk.enable", true); + Services.prefs.setBoolPref("browser.cache.memory.enable", true); + Services.io.offline = false; + gBrowser.removeCurrentTab(); +}); |