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 /mobile/android/tests/browser/chrome/test_offline_page.html | |
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 'mobile/android/tests/browser/chrome/test_offline_page.html')
-rw-r--r-- | mobile/android/tests/browser/chrome/test_offline_page.html | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/mobile/android/tests/browser/chrome/test_offline_page.html b/mobile/android/tests/browser/chrome/test_offline_page.html new file mode 100644 index 000000000..e1b723266 --- /dev/null +++ b/mobile/android/tests/browser/chrome/test_offline_page.html @@ -0,0 +1,111 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1089190 +Migrated from Robocop: https://bugzilla.mozilla.org/show_bug.cgi?id=1184186 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1089190</title> + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://global/skin"/> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> + <script type="application/javascript" src="head.js"></script> + <script type="application/javascript;version=1.7"> + + "use strict"; + + const { classes: Cc, interfaces: Ci, utils: Cu } = Components; + + Cu.import("resource://gre/modules/Services.jsm"); + Cu.import("resource://gre/modules/Messaging.jsm"); + Cu.import("resource://gre/modules/Task.jsm"); + + // Provide a helper to yield until we are sure the offline state has changed + function promiseOffline(isOffline) { + return new Promise((resolve, reject) => { + function observe(subject, topic, data) { + info("Received topic: " + topic); + Services.obs.removeObserver(observe, "network:offline-status-changed"); + resolve(); + } + Services.obs.addObserver(observe, "network:offline-status-changed", false); + Services.io.offline = isOffline; + }); + } + + // The chrome window + let chromeWin; + + // Track the <browser> where the tests are happening + let browser; + + // The proxy setting + let proxyPrefValue; + + const kUniqueURI = Services.io.newURI("http://mochi.test:8888/chrome/mobile/android/tests/browser/chrome/video_controls.html", null, null); + + add_task(function* test_offline() { + // 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); + + // Clear network cache. + Cc["@mozilla.org/netwerk/cache-storage-service;1"].getService(Ci.nsICacheStorageService).clear(); + + chromeWin = Services.wm.getMostRecentWindow("navigator:browser"); + let BrowserApp = chromeWin.BrowserApp; + + // Add a new tab with a blank page so we can better control the real page load and the offline state + browser = BrowserApp.addTab("about:blank", { selected: true, parentId: BrowserApp.selectedTab.id }).browser; + + SimpleTest.registerCleanupFunction(function() { + BrowserApp.closeTab(BrowserApp.getTabForBrowser(browser)); + Services.prefs.setIntPref("network.proxy.type", proxyPrefValue); + Services.io.offline = false; + }); + + // Go offline, expecting the error page. + yield promiseOffline(true); + + // Load our test web page + browser.loadURI(kUniqueURI.spec, null, null) + yield promiseBrowserEvent(browser, "DOMContentLoaded"); + + // This is an error page. + is(browser.contentDocument.documentURI.substring(0, 27), "about:neterror?e=netOffline", "Document URI is the error page."); + + // But location bar should show the original request. + is(browser.contentWindow.location.href, kUniqueURI.spec, "Docshell URI is the original URI."); + + Services.prefs.setIntPref("network.proxy.type", proxyPrefValue); + + // Go online and try to load the page again + yield promiseOffline(false); + + ok(browser.contentDocument.getElementById("errorTryAgain"), "The error page has got a #errorTryAgain element"); + + // Click "Try Again" button to start the page load + browser.contentDocument.getElementById("errorTryAgain").click(); + yield promiseBrowserEvent(browser, "DOMContentLoaded"); + + // This is not an error page. + is(browser.contentDocument.documentURI, kUniqueURI.spec, "Document URI is not the offline-error page, but the original URI."); + }); + + </script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1089190">Mozilla Bug 1089190</a> +<br> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1184186">Migrated from Robocop testOfflinePage</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +</pre> +</body> +</html> |