Bug 1354175 - Disable AppCache in insecure contexts. r?baku r?bkelly r?mayhemer draft
authorJonathan Kingston <jkt@mozilla.com>
Fri, 12 Jan 2018 19:09:30 +0000
changeset 750306 af6c16bdcba862d8b8f4f11ae2edb56661abd674
parent 749389 7b46ef2ae1412b15ed45e7d2367ca491344729f7
push id97615
push userbmo:jkt@mozilla.com
push dateThu, 01 Feb 2018 21:45:05 +0000
reviewersbaku, bkelly, mayhemer
bugs1354175
milestone60.0a1
Bug 1354175 - Disable AppCache in insecure contexts. r?baku r?bkelly r?mayhemer MozReview-Commit-ID: wYWHkGlV8h
browser/base/content/test/general/browser.ini
browser/base/content/test/general/mochitest.ini
browser/base/content/test/general/test_offlineNotification.html
devtools/client/commandline/test/browser.ini
devtools/client/commandline/test/browser_cmd_appcache_invalid.js
devtools/client/commandline/test/browser_cmd_appcache_invalid_appcache.appcache
devtools/client/commandline/test/browser_cmd_appcache_valid.js
dom/base/nsDeprecatedOperationList.h
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowInner.h
dom/locales/en-US/chrome/dom/dom.properties
dom/tests/mochitest/ajax/offline/.eslintrc.js
dom/tests/mochitest/ajax/offline/445544.cacheManifest
dom/tests/mochitest/ajax/offline/744719-cancel.cacheManifest
dom/tests/mochitest/ajax/offline/744719.cacheManifest
dom/tests/mochitest/ajax/offline/badManifestMagic.cacheManifest
dom/tests/mochitest/ajax/offline/browser.ini
dom/tests/mochitest/ajax/offline/browser_disableAppcache.js
dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs
dom/tests/mochitest/ajax/offline/explicitRedirect.sjs
dom/tests/mochitest/ajax/offline/fallback.cacheManifest
dom/tests/mochitest/ajax/offline/file_simpleManifest.cacheManifest
dom/tests/mochitest/ajax/offline/file_simpleManifest.html
dom/tests/mochitest/ajax/offline/file_testFile.sjs
dom/tests/mochitest/ajax/offline/foreign2.html
dom/tests/mochitest/ajax/offline/manifestRedirect.sjs
dom/tests/mochitest/ajax/offline/missingFile.cacheManifest
dom/tests/mochitest/ajax/offline/mochitest.ini
dom/tests/mochitest/ajax/offline/namespace1/redirectToDifferentOrigin.sjs
dom/tests/mochitest/ajax/offline/obsolete.html
dom/tests/mochitest/ajax/offline/offlineTests.js
dom/tests/mochitest/ajax/offline/overlap.cacheManifest
dom/tests/mochitest/ajax/offline/redirects.sjs
dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest
dom/tests/mochitest/ajax/offline/test_badManifestMagic.html
dom/tests/mochitest/ajax/offline/test_bug460353.html
dom/tests/mochitest/ajax/offline/test_bug474696.html
dom/tests/mochitest/ajax/offline/test_bug544462.html
dom/tests/mochitest/ajax/offline/test_bug744719-cancel.html
dom/tests/mochitest/ajax/offline/test_bug744719.html
dom/tests/mochitest/ajax/offline/test_bug765203.html
dom/tests/mochitest/ajax/offline/test_cancelOfflineCache.html
dom/tests/mochitest/ajax/offline/test_changingManifest.html
dom/tests/mochitest/ajax/offline/test_fallback.html
dom/tests/mochitest/ajax/offline/test_foreign.html
dom/tests/mochitest/ajax/offline/test_identicalManifest.html
dom/tests/mochitest/ajax/offline/test_lowDeviceStorage.html
dom/tests/mochitest/ajax/offline/test_lowDeviceStorageDuringUpdate.html
dom/tests/mochitest/ajax/offline/test_missingFile.html
dom/tests/mochitest/ajax/offline/test_obsolete.html
dom/tests/mochitest/ajax/offline/test_offlineIFrame.html
dom/tests/mochitest/ajax/offline/test_offlineMode.html
dom/tests/mochitest/ajax/offline/test_overlap.html
dom/tests/mochitest/ajax/offline/test_redirectManifest.html
dom/tests/mochitest/ajax/offline/test_redirectUpdateItem.html
dom/tests/mochitest/ajax/offline/test_refetchManifest.html
dom/tests/mochitest/ajax/offline/test_simpleManifest.html
dom/tests/mochitest/ajax/offline/test_updateCheck.html
dom/tests/mochitest/ajax/offline/test_updatingManifest.html
dom/tests/mochitest/ajax/offline/test_xhtmlManifest.xhtml
dom/tests/mochitest/ajax/offline/unknownSection.cacheManifest
dom/tests/mochitest/ajax/offline/updatingImplicit.html
dom/tests/mochitest/ajax/offline/updatingManifest.sjs
dom/tests/mochitest/ajax/offline/wildcardManifest.cacheManifest
dom/tests/moz.build
dom/webidl/Window.webidl
modules/libpref/init/all.js
netwerk/protocol/http/nsHttpChannel.cpp
testing/web-platform/meta/html/browsers/offline/appcache/workers/appcache-worker.html.ini
testing/web-platform/meta/html/browsers/offline/application-cache-api/api_status_idle.html.ini
testing/web-platform/meta/html/browsers/offline/application-cache-api/api_status_uncached.html.ini
testing/web-platform/meta/html/browsers/offline/application-cache-api/api_swapcache_error.html.ini
testing/web-platform/meta/html/browsers/offline/application-cache-api/api_update.html.ini
testing/web-platform/meta/html/browsers/offline/application-cache-api/api_update_error.html.ini
testing/web-platform/meta/html/browsers/offline/introduction-4/event_cached.html.ini
testing/web-platform/meta/html/browsers/offline/introduction-4/event_checking.html.ini
testing/web-platform/meta/html/browsers/offline/introduction-4/event_noupdate.html.ini
testing/web-platform/meta/html/browsers/offline/introduction-4/event_progress.html.ini
testing/web-platform/meta/html/browsers/offline/manifest_url_check.html.ini
testing/web-platform/meta/html/browsers/the-window-object/security-window/window-security.html.ini
testing/web-platform/meta/html/browsers/the-window-object/window-properties.html.ini
testing/web-platform/meta/html/dom/dynamic-markup-insertion/opening-the-input-stream/009.html.ini
testing/web-platform/meta/html/dom/interfaces.html.ini
uriloader/prefetch/nsOfflineCacheUpdateService.cpp
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -1,16 +1,17 @@
 ###############################################################################
 # DO NOT ADD MORE TESTS HERE.                                                 #
 # TRY ONE OF THE MORE TOPICAL SIBLING DIRECTORIES.                            #
 # THIS DIRECTORY HAS 200+ TESTS AND TAKES AGES TO RUN ON A DEBUG BUILD.       #
 # PLEASE, FOR THE LOVE OF WHATEVER YOU HOLD DEAR, DO NOT ADD MORE TESTS HERE. #
 ###############################################################################
 
 [DEFAULT]
+prefs = browser.cache.offline.insecure.enable=true
 support-files =
   POSTSearchEngine.xml
   alltabslistener.html
   app_bug575561.html
   app_subframe_bug575561.html
   audio.ogg
   browser_bug479408_sample.html
   browser_bug678392-1.html
@@ -47,18 +48,16 @@ support-files =
   file_double_close_tab.html
   file_favicon_change.html
   file_favicon_change_not_in_document.html
   file_fullscreen-window-open.html
   file_with_link_to_http.html
   head.js
   moz.png
   navigating_window_with_download.html
-  offlineQuotaNotification.cacheManifest
-  offlineQuotaNotification.html
   page_style_sample.html
   pinning_headers.sjs
   ssl_error_reports.sjs
   print_postdata.sjs
   searchSuggestionEngine.sjs
   searchSuggestionEngine.xml
   searchSuggestionEngine2.xml
   subtst_contextmenu.html
@@ -361,16 +360,17 @@ subsuite = clipboard
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_minimize.js]
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_modifiedclick_inherit_principal.js]
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_new_http_window_opened_from_file_tab.js]
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_offlineQuotaNotification.js]
+support-files = offlineQuotaNotification.cacheManifest offlineQuotaNotification.html
 skip-if = os == "linux" && !debug # bug 1304273
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_feed_discovery.js]
 support-files = feed_discovery.html
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
 [browser_gZipOfflineChild.js]
 support-files = test_offline_gzip.html gZipOfflineChild.cacheManifest gZipOfflineChild.cacheManifest^headers^ gZipOfflineChild.html gZipOfflineChild.html^headers^
 # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
--- a/browser/base/content/test/general/mochitest.ini
+++ b/browser/base/content/test/general/mochitest.ini
@@ -18,10 +18,8 @@ support-files =
   offlineEvent.cacheManifest^headers^
   offlineEvent.html
   subtst_contextmenu.html
   video.ogg
   !/image/test/mochitest/blue.png
 
 [test_bug364677.html]
 [test_bug395533.html]
-[test_offlineNotification.html]
-skip-if = e10s # Bug 1257785
deleted file mode 100644
--- a/browser/base/content/test/general/test_offlineNotification.html
+++ /dev/null
@@ -1,121 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=462856
--->
-<head>
-  <title>Test offline app notification</title>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="text/javascript" src="offlineByDefault.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
-</head>
-<body>
-<p id="display">
-<!-- Load the test frame twice from the same domain,
-     to make sure we get notifications for both -->
-<iframe name="testFrame" src="offlineChild.html"></iframe>
-<iframe name="testFrame2" src="offlineChild2.html"></iframe>
-<!-- Load from another domain to make sure we get a second allow/deny
-     notification -->
-<iframe name="testFrame3" src="http://example.com/tests/browser/base/content/test/general/offlineChild.html"></iframe>
-
-<iframe id="eventsTestFrame" src="offlineEvent.html"></iframe>
-
-<div id="content" style="display: none">
-</div>
-<pre id="test">
-<script class="testbody" type="text/javascript">
-/* import-globals-from offlineByDefault.js */
-SimpleTest.waitForExplicitFinish();
-const Cc = SpecialPowers.Cc;
-
-var numFinished = 0;
-
-window.addEventListener("message", function(event) {
-    is(event.data, "success", "Child was successfully cached.");
-
-    if (++numFinished == 3) {
-      // Clean up after ourself
-      var uri1 = SpecialPowers.Services.io.newURI(frames.testFrame.location);
-      var uri2 = SpecialPowers.Services.io.newURI(frames.testFrame3.location);
-
-      var principal1 = SpecialPowers.Services.scriptSecurityManager.createCodebasePrincipal(uri1, {});
-      var principal2 = SpecialPowers.Services.scriptSecurityManager.createCodebasePrincipal(uri2, {});
-
-      SpecialPowers.Services.perms.removeFromPrincipal(principal1, "offline-app");
-      SpecialPowers.Services.perms.removeFromPrincipal(principal2, "offline-app");
-
-      offlineByDefault.reset();
-
-      SimpleTest.finish();
-    }
-  });
-
-var count = 0;
-var expectedEvent = "";
-function eventHandler(evt) {
-  ++count;
-  is(evt.type, expectedEvent, "Wrong event!");
-}
-
-function testEventHandling() {
-  var events = [ "checking",
-                 "error",
-                 "noupdate",
-                 "downloading",
-                 "progress",
-                 "updateready",
-                 "cached",
-                 "obsolete"];
-  var w = document.getElementById("eventsTestFrame").contentWindow;
-  var e;
-  for (var i = 0; i < events.length; ++i) {
-    count = 0;
-    expectedEvent = events[i];
-    e = w.document.createEvent("event");
-    e.initEvent(expectedEvent, true, true);
-    w.applicationCache["on" + expectedEvent] = eventHandler;
-    w.applicationCache.addEventListener(expectedEvent, eventHandler, true);
-    w.applicationCache.dispatchEvent(e);
-    is(count, 2, "Wrong number events!");
-    w.applicationCache["on" + expectedEvent] = null;
-    w.applicationCache.removeEventListener(expectedEvent, eventHandler, true);
-    w.applicationCache.dispatchEvent(e);
-    is(count, 2, "Wrong number events!");
-  }
-
-  // Test some random event.
-  count = 0;
-  expectedEvent = "foo";
-  e = w.document.createEvent("event");
-  e.initEvent(expectedEvent, true, true);
-  w.applicationCache.addEventListener(expectedEvent, eventHandler, true);
-  w.applicationCache.dispatchEvent(e);
-  is(count, 1, "Wrong number events!");
-  w.applicationCache.removeEventListener(expectedEvent, eventHandler, true);
-  w.applicationCache.dispatchEvent(e);
-  is(count, 1, "Wrong number events!");
-}
-
-function loaded() {
-  testEventHandling();
-
-  // Click the notification panel's "Allow" button.  This should kick
-  // off updates, which will eventually lead to getting messages from
-  // the children.
-  var win = SpecialPowers.Services.wm.getMostRecentWindow("navigator:browser");
-  var panel = win.PopupNotifications.panel;
-  is(panel.childElementCount, 2, "2 notifications being displayed");
-  panel.firstElementChild.button.click();
-
-  // should have dismissed one of the notifications.
-  is(panel.childElementCount, 1, "1 notification now being displayed");
-  panel.firstElementChild.button.click();
-}
-
-SimpleTest.waitForFocus(loaded);
-
-</script>
-</pre>
-</body>
-</html>
--- a/devtools/client/commandline/test/browser.ini
+++ b/devtools/client/commandline/test/browser.ini
@@ -17,16 +17,17 @@ support-files =
   browser_cmd_appcache_invalid_appcache.appcache
   browser_cmd_appcache_invalid_appcache.appcache^headers^
   browser_cmd_appcache_invalid_index.html
   browser_cmd_appcache_invalid_page1.html
   browser_cmd_appcache_invalid_page2.html
   browser_cmd_appcache_invalid_page3.html
   browser_cmd_appcache_invalid_page3.html^headers^
 [browser_cmd_appcache_valid.js]
+skip-if = !e10s
 support-files =
   browser_cmd_appcache_valid_appcache.appcache
   browser_cmd_appcache_valid_appcache.appcache^headers^
   browser_cmd_appcache_valid_index.html
   browser_cmd_appcache_valid_page1.html
   browser_cmd_appcache_valid_page2.html
   browser_cmd_appcache_valid_page3.html
 [browser_cmd_commands.js]
--- a/devtools/client/commandline/test/browser_cmd_appcache_invalid.js
+++ b/devtools/client/commandline/test/browser_cmd_appcache_invalid.js
@@ -1,15 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
 
 // Tests that the appcache validate works as they should with an invalid
 // manifest.
 
-const TEST_URI = "http://sub1.test1.example.com/browser/devtools/client/commandline/" +
+const TEST_URI = "https://sub1.test1.example.com/browser/devtools/client/commandline/" +
                  "test/browser_cmd_appcache_invalid_index.html";
 
 function test() {
   return Task.spawn(spawnTest).then(finish, helpers.handleError);
 }
 
 function* spawnTest() {
   let lines = [
@@ -31,36 +32,36 @@ function* spawnTest() {
     "../../../../rel.html points to a resource that is not available at line 20.",
     "../../../../../rel.html points to a resource that is not available at line 21.",
     "/../ is not a valid URI prefix at line 22.",
     "/test.css points to a resource that is not available at line 23.",
     "/test.js points to a resource that is not available at line 24.",
     "test.png points to a resource that is not available at line 25.",
     "/main/features.js points to a resource that is not available at line 27.",
     "/main/settings/index.css points to a resource that is not available at line 28.",
-    "http://example.com/scene.jpg points to a resource that is not available at line 29.",
+    "https://example.com/scene.jpg points to a resource that is not available at line 29.",
     "/section1/blockedbyfallback.html points to a resource that is not available at line 30.",
-    "http://example.com/images/world.jpg points to a resource that is not available at line 31.",
+    "https://example.com/images/world.jpg points to a resource that is not available at line 31.",
     "/section2/blockedbyfallback.html points to a resource that is not available at line 32.",
     "/main/home points to a resource that is not available at line 34.",
     "main/app.js points to a resource that is not available at line 35.",
     "/settings/home points to a resource that is not available at line 37.",
     "/settings/app.js points to a resource that is not available at line 38.",
-    "The file http://sub1.test1.example.com/browser/devtools/client/" +
+    "The file https://sub1.test1.example.com/browser/devtools/client/" +
       "commandline/test/browser_cmd_appcache_invalid_page3.html was modified " +
-      "after http://sub1.test1.example.com/browser/devtools/client/" +
+      "after https://sub1.test1.example.com/browser/devtools/client/" +
       "commandline/test/browser_cmd_appcache_invalid_appcache.appcache. Unless " +
       "the text in the manifest file is changed the cached version will be used " +
       "instead at line 39.",
     "browser_cmd_appcache_invalid_page3.html has cache-control set to no-store. " +
       "This will prevent the application cache from storing the file at line 39.",
-    "http://example.com/logo.png points to a resource that is not available at line 40.",
-    "http://example.com/check.png points to a resource that is not available at line 41.",
+    "https://example.com/logo.png points to a resource that is not available at line 40.",
+    "https://example.com/check.png points to a resource that is not available at line 41.",
     "Spaces in URIs need to be replaced with %20 at line 42.",
-    "http://example.com/cr oss.png points to a resource that is not available at line 42.",
+    "https://example.com/cr oss.png points to a resource that is not available at line 42.",
     "Asterisk (*) incorrectly used in the CACHE section at line 43. If a line " +
       "in the NETWORK section contains only a single asterisk character, then " +
       "any URI not listed in the manifest will be treated as if the URI was " +
       "listed in the NETWORK section. Otherwise such URIs will be treated as " +
       "unavailable. Other uses of the * character are prohibited",
     "The SETTINGS section may only contain a single value, \u201cprefer-online\u201d or \u201cfast\u201d at line 47.",
     "FALLBACK section line 50 (/section1/ /offline1.html) prevents caching of " +
       "line 30 (/section1/blockedbyfallback.html) in the CACHE section.",
--- a/devtools/client/commandline/test/browser_cmd_appcache_invalid_appcache.appcache
+++ b/devtools/client/commandline/test/browser_cmd_appcache_invalid_appcache.appcache
@@ -21,30 +21,30 @@ CACHE:
 ../../../../../rel.html
 /../invalid.html
 /test.css
 /test.js
 test.png
 browser_cmd_appcache_invalid_index.html
 /main/features.js
 /main/settings/index.css
-http://example.com/scene.jpg
+https://example.com/scene.jpg
 /section1/blockedbyfallback.html
-http://example.com/images/world.jpg
+https://example.com/images/world.jpg
 /section2/blockedbyfallback.html
 browser_cmd_appcache_invalid_page1.html
 /main/home
 main/app.js
 browser_cmd_appcache_invalid_page2.html
 /settings/home
 /settings/app.js
 browser_cmd_appcache_invalid_page3.html
-http://example.com/logo.png
-http://example.com/check.png
-http://example.com/cr oss.png
+https://example.com/logo.png
+https://example.com/check.png
+https://example.com/cr oss.png
 /checking*.png
 
 SETTINGS:
 prefer-online
 fast
 
 FALLBACK:
 /section1/ /offline1.html
--- a/devtools/client/commandline/test/browser_cmd_appcache_valid.js
+++ b/devtools/client/commandline/test/browser_cmd_appcache_valid.js
@@ -1,14 +1,15 @@
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
 
 // Tests that the appcache commands works as they should
 
-const TEST_URI = "http://sub1.test2.example.com/browser/devtools/client/" +
+const TEST_URI = "https://sub1.test2.example.com/browser/devtools/client/" +
                  "commandline/test/browser_cmd_appcache_valid_index.html";
 
 function test() {
   return Task.spawn(spawnTest).then(finish, helpers.handleError);
 }
 
 function* spawnTest() {
   let options = yield helpers.openTab(TEST_URI);
@@ -105,17 +106,17 @@ function* spawnTest() {
         output: [ /successfully/ ]
       },
     },
 
     {
       setup: "appcache validate " + TEST_URI,
       check: {
         input:  "appcache validate " + TEST_URI,
-              // appcache validate http://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_index.html
+              // appcache validate https://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_index.html
         markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
         status: "VALID",
         args: {
           uri: {
             value: TEST_URI
           },
         }
       },
@@ -155,17 +156,17 @@ function* spawnTest() {
         ok(!text.includes("page3"), "page1 is not contained in output");
       }
     },
 
     {
       setup: "appcache viewentry --key " + TEST_URI,
       check: {
         input:  "appcache viewentry --key " + TEST_URI,
-              // appcache viewentry --key http://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_index.html
+              // appcache viewentry --key https://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_index.html
         markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
         status: "VALID",
         args: {}
       },
     },
   ]);
 
   yield helpers.closeToolbar(options);
--- a/dom/base/nsDeprecatedOperationList.h
+++ b/dom/base/nsDeprecatedOperationList.h
@@ -27,16 +27,17 @@ DEPRECATED_OPERATION(ShowModalDialog)
 DEPRECATED_OPERATION(SyncXMLHttpRequest)
 DEPRECATED_OPERATION(Window_Cc_ontrollers)
 DEPRECATED_OPERATION(ImportXULIntoContent)
 DEPRECATED_OPERATION(PannerNodeDoppler)
 DEPRECATED_OPERATION(NavigatorGetUserMedia)
 DEPRECATED_OPERATION(WebrtcDeprecatedPrefix)
 DEPRECATED_OPERATION(RTCPeerConnectionGetStreams)
 DEPRECATED_OPERATION(AppCache)
+DEPRECATED_OPERATION(AppCacheInsecure)
 DEPRECATED_OPERATION(PrefixedImageSmoothingEnabled)
 DEPRECATED_OPERATION(PrefixedFullscreenAPI)
 DEPRECATED_OPERATION(LenientSetter)
 DEPRECATED_OPERATION(FileLastModifiedDate)
 DEPRECATED_OPERATION(ImageBitmapRenderingContext_TransferImageBitmap)
 DEPRECATED_OPERATION(URLCreateObjectURL_MediaStream)
 DEPRECATED_OPERATION(XMLBaseAttribute)
 DEPRECATED_OPERATION(WindowContentUntrusted)
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -2966,16 +2966,23 @@ nsGlobalWindowInner::GetOwnPropertyNames
 nsGlobalWindowInner::IsPrivilegedChromeWindow(JSContext* aCx, JSObject* aObj)
 {
   // For now, have to deal with XPConnect objects here.
   return xpc::WindowOrNull(aObj)->IsChromeWindow() &&
          nsContentUtils::ObjectPrincipal(aObj) == nsContentUtils::GetSystemPrincipal();
 }
 
 /* static */ bool
+nsGlobalWindowInner::OfflineCacheAllowedForContext(JSContext* aCx, JSObject* aObj)
+{
+  return IsSecureContextOrObjectIsFromSecureContext(aCx, aObj) ||
+         Preferences::GetBool("browser.cache.offline.insecure.enable");
+}
+
+/* static */ bool
 nsGlobalWindowInner::IsRequestIdleCallbackEnabled(JSContext* aCx, JSObject* aObj)
 {
   // The requestIdleCallback should always be enabled for system code.
   return nsContentUtils::RequestIdleCallbackEnabled() ||
          nsContentUtils::IsSystemCaller(aCx);
 }
 
 nsIDOMOfflineResourceList*
--- a/dom/base/nsGlobalWindowInner.h
+++ b/dom/base/nsGlobalWindowInner.h
@@ -385,16 +385,18 @@ public:
   // nsIInterfaceRequestor
   NS_DECL_NSIINTERFACEREQUESTOR
 
   // WebIDL interface.
   already_AddRefed<nsPIDOMWindowOuter> IndexedGetter(uint32_t aIndex);
 
   static bool IsPrivilegedChromeWindow(JSContext* /* unused */, JSObject* aObj);
 
+  static bool OfflineCacheAllowedForContext(JSContext* /* unused */, JSObject* aObj);
+
   static bool IsRequestIdleCallbackEnabled(JSContext* aCx, JSObject* /* unused */);
 
   static bool IsWindowPrintEnabled(JSContext* /* unused */, JSObject* /* unused */);
 
   bool DoResolve(JSContext* aCx, JS::Handle<JSObject*> aObj,
                  JS::Handle<jsid> aId,
                  JS::MutableHandle<JS::PropertyDescriptor> aDesc);
   // The return value is whether DoResolve might end up resolving the given id.
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -182,16 +182,18 @@ IndexedDBTransactionAbortNavigation=An I
 # LOCALIZATION NOTE: Do not translate Will-change, %1$S,%2$S are numbers.
 IgnoringWillChangeOverBudgetWarning=Will-change memory consumption is too high. Budget limit is the document surface area multiplied by %1$S (%2$S px). Occurrences of will-change over the budget will be ignored.
 # LOCALIZATION NOTE: Do not translate "Worker".
 HittingMaxWorkersPerDomain2=A Worker could not be started immediately because other documents in the same origin are already using the maximum number of workers. The Worker is now queued and will be started after some of the other workers have completed.
 # LOCALIZATION NOTE: Do not translate "setVelocity", "PannerNode", "AudioListener", "speedOfSound" and "dopplerFactor"
 PannerNodeDopplerWarning=Use of setVelocity on the PannerNode and AudioListener, and speedOfSound and dopplerFactor on the AudioListener are deprecated and those members will be removed. For more help https://developer.mozilla.org/en-US/docs/Web/API/AudioListener#Deprecated_features
 # LOCALIZATION NOTE: Do not translate "Application Cache API", "AppCache" and "ServiceWorker".
 AppCacheWarning=The Application Cache API (AppCache) is deprecated and will be removed at a future date.  Please consider using ServiceWorker for offline support.
+# LOCALIZATION NOTE: Do not translate "Application Cache API", "AppCache".
+AppCacheInsecureWarning=Use of the Application Cache API (AppCache) for insecure connections will be removed in version 62.
 # LOCALIZATION NOTE: Do not translate "Worker".
 EmptyWorkerSourceWarning=Attempting to create a Worker from an empty source. This is probably unintentional.
 WebrtcDeprecatedPrefixWarning=WebRTC interfaces with the “moz” prefix (mozRTCPeerConnection, mozRTCSessionDescription, mozRTCIceCandidate) have been deprecated.
 NavigatorGetUserMediaWarning=navigator.mozGetUserMedia has been replaced by navigator.mediaDevices.getUserMedia
 # LOCALIZATION NOTE: Do not translate "RTCPeerConnection", "getLocalStreams", "getRemoteStreams", "getSenders" or "getReceivers".
 RTCPeerConnectionGetStreamsWarning=RTCPeerConnection.getLocalStreams/getRemoteStreams are deprecated. Use RTCPeerConnection.getSenders/getReceivers instead.
 # LOCALIZATION NOTE: Do not translate "ServiceWorker". %S is a URL.
 InterceptionFailedWithURL=Failed to load ‘%S’. A ServiceWorker intercepted the request and encountered an unexpected error.
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/ajax/offline/.eslintrc.js
@@ -0,0 +1,9 @@
+"use strict";
+
+module.exports = {
+  "globals": {
+    "SimpleTest": true,
+    "OfflineTest": true,
+    "SpecialPowers": true,
+  }
+};
--- a/dom/tests/mochitest/ajax/offline/445544.cacheManifest
+++ b/dom/tests/mochitest/ajax/offline/445544.cacheManifest
@@ -1,8 +1,8 @@
 CACHE MANIFEST
-http://mochi.test:8888/tests/SimpleTest/SimpleTest.js
-http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
+https://example.com/tests/SimpleTest/SimpleTest.js
+https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
 
 test_bug445544.html
 445544_part1.html
 
 # not including 445544_part2.html
--- a/dom/tests/mochitest/ajax/offline/744719-cancel.cacheManifest
+++ b/dom/tests/mochitest/ajax/offline/744719-cancel.cacheManifest
@@ -1,12 +1,12 @@
 CACHE MANIFEST
 
-http://mochi.test:8888/tests/SimpleTest/SimpleTest.js
-http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
+https://example.com/tests/SimpleTest/SimpleTest.js
+https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
 
 # more than 15 what is a number of parallel loads
 subresource744719.html?001
 subresource744719.html?002
 subresource744719.html?003
 subresource744719.html?004
 subresource744719.html?005
 subresource744719.html?006
--- a/dom/tests/mochitest/ajax/offline/744719.cacheManifest
+++ b/dom/tests/mochitest/ajax/offline/744719.cacheManifest
@@ -1,12 +1,12 @@
 CACHE MANIFEST
 
-http://mochi.test:8888/tests/SimpleTest/SimpleTest.js
-http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
+https://example.com/tests/SimpleTest/SimpleTest.js
+https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
 
 # more than 15 what is a number of parallel loads
 subresource744719.html?001
 subresource744719.html?002
 subresource744719.html?003
 subresource744719.html?004
 subresource744719.html?005
 subresource744719.html?006
--- a/dom/tests/mochitest/ajax/offline/badManifestMagic.cacheManifest
+++ b/dom/tests/mochitest/ajax/offline/badManifestMagic.cacheManifest
@@ -1,3 +1,3 @@
 # This doesn't start with the magic cache manifest line.
-http://mochi.test:8888/tests/SimpleTest/SimpleTest.js
-http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
+https://example.com/tests/SimpleTest/SimpleTest.js
+https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/ajax/offline/browser.ini
@@ -0,0 +1,8 @@
+[DEFAULT]
+support-files =
+  file_simpleManifest.html
+  file_testFile.sjs
+  file_simpleManifest.cacheManifest
+
+[browser_disableAppcache.js]
+skip-if = !e10s || (toolkit == 'android') || debug # Slow
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/ajax/offline/browser_disableAppcache.js
@@ -0,0 +1,134 @@
+const PATH =
+  "http://example.com/browser/dom/tests/mochitest/ajax/offline/";
+const URL = PATH + "file_simpleManifest.html";
+const MANIFEST = PATH + "file_simpleManifest.cacheManifest";
+const PREF_INSECURE_APPCACHE = "browser.cache.offline.insecure.enable";
+const PREF_NETWORK_PROXY = "network.proxy.type";
+
+function setSJSState(sjsPath, stateQuery) {
+  let client = new XMLHttpRequest();
+  client.open("GET", sjsPath + "?state=" + stateQuery, false);
+  let appcachechannel = SpecialPowers.wrap(client).channel.QueryInterface(Ci.nsIApplicationCacheChannel);
+
+  return new Promise((resolve, reject) => {
+    client.addEventListener("load", resolve);
+    client.addEventListener("error", reject);
+
+    appcachechannel.chooseApplicationCache = false;
+    appcachechannel.inheritApplicationCache = false;
+    appcachechannel.applicationCache = null;
+
+    client.send();
+  });
+}
+
+add_task(async function() {
+  /* This test loads "evil" content and verified it isn't loaded when appcache is disabled, which emulates loading stale cache from an untrusted network:
+     - Sets frame to load "evil" content
+     - Loads HTML file which also loads and caches content into AppCache
+     - Sets frame to load "good"
+     - Check we still have "evil" content from AppCache
+     - Disables appcache
+     - Check content is "good"
+  */
+  await SpecialPowers.pushPrefEnv({
+    set: [
+      [PREF_INSECURE_APPCACHE, true]
+    ]
+  });
+  await setSJSState(PATH + "file_testFile.sjs", "evil");
+  await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
+  await ContentTask.spawn(gBrowser.selectedBrowser, null, async () => {
+    let windowPromise = new Promise((resolve, reject) => {
+      function init() {
+        if (content.document.readyState == "complete") {
+          const frame = content.document.getElementById("childframe");
+          const state = frame.contentDocument.getElementById("state");
+          is(state.textContent, "evil", "Loaded evil content");
+          resolve();
+        }
+      }
+      content.document.onreadystatechange = init;
+      init();
+    });
+    let appcachePromise = new Promise((resolve, reject) => {
+      function appcacheInit() {
+        if (content.applicationCache.status === content.applicationCache.IDLE) {
+          ok(true, "Application cache loaded");
+          resolve();
+        } else {
+          info("State was: " + content.applicationCache.status);
+        }
+      }
+      content.applicationCache.oncached = appcacheInit;
+      content.applicationCache.onnoupdate = appcacheInit;
+      content.applicationCache.onerror = () => {
+        ok(false, "Application cache failed");
+        reject();
+      };
+      appcacheInit();
+    });
+    await Promise.all([windowPromise, appcachePromise]);
+  });
+  gBrowser.removeCurrentTab();
+
+  // Turn network and proxy off so we can check the content loads still
+  await setSJSState(PATH + "file_testFile.sjs", "good");
+  Services.cache2.clear();
+
+  // Check we still have the "evil" content despite the state change
+  await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
+  await ContentTask.spawn(gBrowser.selectedBrowser, null, async () => {
+    const frame = content.document.getElementById("childframe");
+    const state = frame.contentDocument.getElementById("state");
+    is(state.textContent, "evil", "Loaded evil content from cache");
+  });
+  gBrowser.removeCurrentTab();
+
+
+  await SpecialPowers.pushPrefEnv({
+    set: [
+      [PREF_INSECURE_APPCACHE, false]
+    ]
+  });
+  await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
+
+  // Check that the "good" content is back now appcache is disabled
+  await ContentTask.spawn(gBrowser.selectedBrowser, [URL], async (URL) => {
+    const frame = content.document.getElementById("childframe");
+    const state = frame.contentDocument.getElementById("state");
+    is(state.textContent, "good", "Loaded good content");
+    // Eval is needed to execure in child context.
+    content.window.eval("OfflineTest.clear()");
+  });
+
+  gBrowser.removeCurrentTab();
+  await setSJSState(PATH + "file_testFile.sjs", "");
+  await SpecialPowers.popPrefEnv();
+});
+
+add_task(async function test_pref_removes_api() {
+  await SpecialPowers.pushPrefEnv({
+    set: [
+      [PREF_INSECURE_APPCACHE, true]
+    ]
+  });
+  await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
+  await ContentTask.spawn(gBrowser.selectedBrowser, null, async () => {
+    // Have to use in page checking as IsSecureContextOrObjectIsFromSecureContext is true for spawn()
+    is(content.document.getElementById("hasAppcache").textContent, "yes", "Appcache is enabled");
+  });
+  gBrowser.removeCurrentTab();
+
+  await SpecialPowers.pushPrefEnv({
+    set: [
+      [PREF_INSECURE_APPCACHE, false]
+    ]
+  });
+  await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
+  await ContentTask.spawn(gBrowser.selectedBrowser, [URL], async (URL) => {
+    is(content.document.getElementById("hasAppcache").textContent, "no", "Appcache is disabled");
+    content.window.eval("OfflineTest.clear()");
+  });
+  gBrowser.removeCurrentTab();
+});
--- a/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs
+++ b/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs
@@ -9,17 +9,17 @@ function handleRequest(request, response
   }
 
   if (request.queryString == "")
   {
     switch (getState("state"))
     {
       case "": // The default value
         response.setStatusLine(request.httpVersion, 307, "Moved temporarly");
-        response.setHeader("Location", "http://example.com/non-existing-dynamic.html");
+        response.setHeader("Location", "https://example.org/non-existing-dynamic.html");
         response.setHeader("Content-Type", "text/html");
         break;
       case "on":
         response.setStatusLine(request.httpVersion, 200, "OK");
         response.setHeader("Content-Type", "text/html");
         response.write("<html><body>Dynamic page</body></html>");
         break;
     }
--- a/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs
+++ b/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs
@@ -9,17 +9,17 @@ function handleRequest(request, response
   }
 
   if (request.queryString == "")
   {
     switch (getState("state"))
     {
       case "": // The default value
         response.setStatusLine(request.httpVersion, 307, "Moved temporarly");
-        response.setHeader("Location", "http://example.com/non-existing-explicit.html");
+        response.setHeader("Location", "https://example.com/non-existing-explicit.html");
         response.setHeader("Content-Type", "text/html");
         break;
       case "on":
         response.setStatusLine(request.httpVersion, 200, "OK");
         response.setHeader("Content-Type", "text/html");
         response.write("<html><body>Explicit page</body></html>");
         break;
     }
--- a/dom/tests/mochitest/ajax/offline/fallback.cacheManifest
+++ b/dom/tests/mochitest/ajax/offline/fallback.cacheManifest
@@ -1,11 +1,11 @@
 CACHE MANIFEST
-http://mochi.test:8888/tests/SimpleTest/SimpleTest.js
-http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
+https://example.com/tests/SimpleTest/SimpleTest.js
+https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
 
 FALLBACK:
 namespace1/ fallback.html
 namespace1/sub/		fallback2.html
 namespace2/ fallbackTop.html
 
 NETWORK:
 onwhitelist.html
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/ajax/offline/file_simpleManifest.cacheManifest
@@ -0,0 +1,5 @@
+CACHE MANIFEST
+http://example.com/browser/dom/tests/mochitest/ajax/offline/file_testFile.sjs
+http://example.com/browser/dom/tests/mochitest/ajax/offline/file_simpleManifest.html
+http://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
+
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/ajax/offline/file_simpleManifest.html
@@ -0,0 +1,20 @@
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://example.com/browser/dom/tests/mochitest/ajax/offline/file_simpleManifest.cacheManifest">
+<head>
+<title>load manifest test</title>
+
+<script type="text/javascript">
+  window.addEventListener("load", () => {
+    const hasAppcache = document.getElementById("hasAppcache");
+    hasAppcache.textContent = "applicationCache" in window ? "yes" : "no";
+  });
+</script>
+<script type="text/javascript" src="http://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
+</head>
+
+<body>
+Offline testing<br />
+We have AppCache: <span id="hasAppcache"></span><br />
+
+<iframe id="childframe" src="http://example.com/browser/dom/tests/mochitest/ajax/offline/file_testFile.sjs" ></iframe>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/dom/tests/mochitest/ajax/offline/file_testFile.sjs
@@ -0,0 +1,25 @@
+function handleRequest(request, response) {
+  var match = request.queryString.match(/^state=(.*)$/);
+  if (match) {
+    response.setStatusLine(request.httpVersion, 204, "No content");
+    setState("version", match[1]);
+    return;
+  }
+  const state = getState("version");
+  let color = "green";
+  if (state === "evil") {
+    color = "red";
+  }
+  const frameContent = `
+  <!DOCTYPE html>
+  <html>
+  <head>
+  <style>body,html {background: ${color};}</style>
+  </head>
+  <body>
+  <h1>Offline file: <span id="state">${state}</span></h1>
+  `;
+  response.setHeader("Content-Type", "text/html");
+  response.setHeader("Cache-Control", "no-cache");
+  response.write(frameContent);
+}
--- a/dom/tests/mochitest/ajax/offline/foreign2.html
+++ b/dom/tests/mochitest/ajax/offline/foreign2.html
@@ -1,52 +1,52 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/foreign2.cacheManifest">
 <head>
 <title>Foreign page 2</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script class="testbody" type="text/javascript">
 
 function manifestUpdated()
 {
   var appCacheService = SpecialPowers.Cc["@mozilla.org/network/application-cache-service;1"]
     .getService(SpecialPowers.Ci.nsIApplicationCacheService);
 
   var foreign2cache = appCacheService.chooseApplicationCache(
-    "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.html", OfflineTest.loadContextInfo());
+    "https://example.com/tests/dom/tests/mochitest/ajax/offline/foreign2.html", OfflineTest.loadContextInfo());
 
   window.opener.OfflineTest.ok(foreign2cache, "Foreign 2 cache present, chosen for foreign2.html");
-  window.opener.OfflineTest.is(foreign2cache.manifestURI.asciiSpec, "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.cacheManifest")
+  window.opener.OfflineTest.is(foreign2cache.manifestURI.asciiSpec, "https://example.com/tests/dom/tests/mochitest/ajax/offline/foreign2.cacheManifest");
 
   var foreign1cache = OfflineTest.getActiveCache(
-    "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign1.cacheManifest");
+    "https://example.com/tests/dom/tests/mochitest/ajax/offline/foreign1.cacheManifest");
   window.opener.OfflineTest.ok(foreign1cache, "Foreign 1 cache loaded");
   foreign1cache.discard();
 
   window.opener.onDone();
 }
 
 function onLoaded()
 {
   var appCacheService = SpecialPowers.Cc["@mozilla.org/network/application-cache-service;1"]
     .getService(SpecialPowers.Ci.nsIApplicationCacheService);
 
   var foreign1cache = window.opener.OfflineTest.getActiveCache(
-    "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign1.cacheManifest");
+    "https://example.com/tests/dom/tests/mochitest/ajax/offline/foreign1.cacheManifest");
   window.opener.OfflineTest.ok(foreign1cache, "Foreign 1 cache loaded");
 
   var foreign2cache = window.opener.OfflineTest.getActiveCache(
-    "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.cacheManifest");
+    "https://example.com/tests/dom/tests/mochitest/ajax/offline/foreign2.cacheManifest");
   window.opener.OfflineTest.ok(!foreign2cache, "Foreign 2 cache not present");
 
   foreign1cache = appCacheService.chooseApplicationCache(
-    "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.html", window.opener.OfflineTest.loadContextInfo());
+    "https://example.com/tests/dom/tests/mochitest/ajax/offline/foreign2.html", window.opener.OfflineTest.loadContextInfo());
   window.opener.OfflineTest.ok(!foreign1cache, "foreign2.html not chosen from foreign1 cache");
 
   try
   {
     window.opener.OfflineTest.ok(applicationCache.status == SpecialPowers.Ci.nsIDOMOfflineResourceList.UNCACHED,
         "there is no associated application cache");
   }
   catch (ex)
--- a/dom/tests/mochitest/ajax/offline/manifestRedirect.sjs
+++ b/dom/tests/mochitest/ajax/offline/manifestRedirect.sjs
@@ -1,6 +1,6 @@
 function handleRequest(request, response)
 {
   response.setStatusLine(request.httpVersion, 307, "Moved temporarly");
-  response.setHeader("Location", "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updating.cacheManifest");
+  response.setHeader("Location", "https://example.com/tests/dom/tests/mochitest/ajax/offline/updating.cacheManifest");
   response.setHeader("Content-Type", "text/cache-manifest");
 }
--- a/dom/tests/mochitest/ajax/offline/missingFile.cacheManifest
+++ b/dom/tests/mochitest/ajax/offline/missingFile.cacheManifest
@@ -1,6 +1,6 @@
 CACHE MANIFEST
-http://mochi.test:8888/tests/SimpleTest/SimpleTest.js
-http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
+https://example.com/tests/SimpleTest/SimpleTest.js
+https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
 
 # The following item doesn't exist, and will cause an update error.
-http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/doesntExist.html
+https://example.com/tests/dom/tests/mochitest/ajax/offline/doesntExist.html
--- a/dom/tests/mochitest/ajax/offline/mochitest.ini
+++ b/dom/tests/mochitest/ajax/offline/mochitest.ini
@@ -1,9 +1,10 @@
 [DEFAULT]
+scheme = https
 skip-if = toolkit == 'android' || e10s #SLOW_DIRECTORY
 support-files =
   445544.cacheManifest
   445544.cacheManifest^headers^
   445544_part1.html
   445544_part2.html
   460353_iframe_nomanifest.html
   460353_iframe_ownmanifest.html
--- a/dom/tests/mochitest/ajax/offline/namespace1/redirectToDifferentOrigin.sjs
+++ b/dom/tests/mochitest/ajax/offline/namespace1/redirectToDifferentOrigin.sjs
@@ -1,6 +1,6 @@
 function handleRequest(request, response)
 {
   response.setStatusLine(request.httpVersion, 307, "Moved temporarly");
-  response.setHeader("Location", "http://example.org/tests/dom/tests/mochitest/ajax/offline/fallback2.html");
+  response.setHeader("Location", "https://example.org/tests/dom/tests/mochitest/ajax/offline/fallback2.html");
   response.setHeader("Content-Type", "text/html");
 }
--- a/dom/tests/mochitest/ajax/offline/obsolete.html
+++ b/dom/tests/mochitest/ajax/offline/obsolete.html
@@ -43,17 +43,17 @@ applicationCache.oncached = function() {
   applicationCache.oncached = fail;
   applicationCache.onupdateready = fail;
   applicationCache.onnoupdate = fail;
   applicationCache.onerror = fail;
   applicationCache.onobsolete = obsolete;
 
   // Make the obsoleting.sjs return 404 NOT FOUND code
   var req = new XMLHttpRequest();
-  req.open("GET", "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/obsoletingManifest.sjs?state=");
+  req.open("GET", "https://example.com/tests/dom/tests/mochitest/ajax/offline/obsoletingManifest.sjs?state=");
   var channel = SpecialPowers.wrap(req).channel
     .QueryInterface(SpecialPowers.Ci.nsIApplicationCacheChannel);
   channel.chooseApplicationCache = false;
   channel.inheritApplicationCache = false;
   req.send("");
   req.onreadystatechange = function() {
     if (req.readyState == 4) {
       applicationCache.update();
--- a/dom/tests/mochitest/ajax/offline/offlineTests.js
+++ b/dom/tests/mochitest/ajax/offline/offlineTests.js
@@ -318,18 +318,26 @@ loadContextInfo: function()
 },
 
 getActiveCache: function(overload)
 {
   // Note that this is the current active cache in the cache stack, not the
   // one associated with this window.
   var serv = Cc["@mozilla.org/network/application-cache-service;1"]
              .getService(Ci.nsIApplicationCacheService);
+
   var groupID = serv.buildGroupIDForInfo(this.manifestURL(overload), this.loadContextInfo());
-  return serv.getActiveCache(groupID);
+  var cache;
+  // Sometimes this throws a NS_ERROR_UNEXPECTED when cache isn't init
+  try {
+    cache = serv.getActiveCache(groupID);
+  } catch (e) {
+    cache = false;
+  }
+  return cache;
 },
 
 getActiveStorage: function()
 {
   var cache = this.getActiveCache();
   if (!cache) {
     return null;
   }
--- a/dom/tests/mochitest/ajax/offline/overlap.cacheManifest
+++ b/dom/tests/mochitest/ajax/offline/overlap.cacheManifest
@@ -1,12 +1,12 @@
 CACHE MANIFEST
 
 CACHE:
-http://mochi.test:8888/tests/SimpleTest/SimpleTest.js
-http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
+https://example.com/tests/SimpleTest/SimpleTest.js
+https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
 
 NETWORK:
 bogus/specific/
 
 FALLBACK:
 # Fall back for a bogus namespace
 bogus/ fallback.html
--- a/dom/tests/mochitest/ajax/offline/redirects.sjs
+++ b/dom/tests/mochitest/ajax/offline/redirects.sjs
@@ -1,31 +1,31 @@
 ver1manifest =
   "CACHE MANIFEST\n" +
   "# v1\n" +
   "\n" +
-  "http://mochi.test:8888/tests/SimpleTest/SimpleTest.js\n" +
-  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
-  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs";
+  "https://example.com/tests/SimpleTest/SimpleTest.js\n" +
+  "https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
+  "https://example.com/tests/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs";
 
 ver2manifest =
   "CACHE MANIFEST\n" +
   "# v2\n" +
   "\n" +
-  "http://mochi.test:8888/tests/SimpleTest/SimpleTest.js\n" +
-  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
-  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs";
+  "https://example.com/tests/SimpleTest/SimpleTest.js\n" +
+  "https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
+  "https://example.com/tests/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs";
 
 ver3manifest =
   "CACHE MANIFEST\n" +
   "# v3\n" +
   "\n" +
-  "http://mochi.test:8888/tests/SimpleTest/SimpleTest.js\n" +
-  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
-  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs";
+  "https://example.com/tests/SimpleTest/SimpleTest.js\n" +
+  "https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
+  "https://example.com/tests/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs";
 
 function handleRequest(request, response)
 {
   var match = request.queryString.match(/^state=(.*)$/);
   if (match)
   {
     response.setStatusLine(request.httpVersion, 204, "No content");
     setState("state", match[1]);
--- a/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest
+++ b/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest
@@ -1,7 +1,7 @@
 CACHE MANIFEST
-http://mochi.test:8888/tests/SimpleTest/SimpleTest.js
-http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
+https://example.com/tests/SimpleTest/SimpleTest.js
+https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
 
 # The following item is not a valid URI and will be ignored
 bad:/uri/invalid
 
--- a/dom/tests/mochitest/ajax/offline/test_badManifestMagic.html
+++ b/dom/tests/mochitest/ajax/offline/test_badManifestMagic.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/badManifestMagic.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/badManifestMagic.cacheManifest">
 <head>
 <title>bad manifest magic</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
@@ -16,18 +16,18 @@ function finishTest() {
 
 function handleError() {
   OfflineTest.ok(gGotChecking, "Expected checking event");
   OfflineTest.ok(true, "Expected error event");
 
   // These items are listed in the manifest, but the error should have
   // prevented them from being committed to the cache.
   var entries = [
-    ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", false],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", false]
+    ["https://example.com/tests/SimpleTest/SimpleTest.js", false],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", false]
   ];
   OfflineTest.checkCacheEntries(entries, finishTest);
 }
 
 
 if (OfflineTest.setup()) {
   // Don't expect a bunch of events.
   applicationCache.ondownloading = OfflineTest.failEvent;
--- a/dom/tests/mochitest/ajax/offline/test_bug460353.html
+++ b/dom/tests/mochitest/ajax/offline/test_bug460353.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
 <head>
 <title>Bug 460353</title>
 
 <!--
   This test checks that each iframe creates its own
   scope. Actually, we just check that it loads and updates
   its associated cache. There is no check that the cache is the
   expected one, there is no API to gain that information.
@@ -68,18 +68,18 @@ function finish()
   SimpleTest.is(result["diff"].cacheStatus || -1, 1, "Frame with different manifest cache status was IDLE");
 
   SimpleTest.ok(result["noman"].load || false, "Frame with no manifest loads");
   SimpleTest.ok(result["noman"].update == undefined, "Frame with no manifest cache update didn't notify");
   SimpleTest.ok(result["noman"].updateOK == undefined, "Frame with no manifest cache update didn't pass");
   SimpleTest.is(result["noman"].cacheStatus || -1, -1, "Frame with no manifest cache status was undefined");
 
   OfflineTest.waitForUpdates(function() {
-    cleanCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest");
-    cleanCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs");
+    cleanCache("https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest");
+    cleanCache("https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs");
 
     SimpleTest.finish();
   });
 }
 
 function cleanCache(manifestURL)
 {
   var cache = OfflineTest.getActiveCache(manifestURL);
--- a/dom/tests/mochitest/ajax/offline/test_bug474696.html
+++ b/dom/tests/mochitest/ajax/offline/test_bug474696.html
@@ -1,20 +1,22 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback.cacheManifest">
 <head>
 <title>Fallback on different origin redirect test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script class="testbody" type="text/javascript">
+/* globals fallbackFrame */
+
 function manifestUpdated()
 {
-  fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/redirectToDifferentOrigin.sjs";
+  fallbackFrame.location = "https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/redirectToDifferentOrigin.sjs";
   // Invokes load of fallback.html
 }
 
 function onFallbackLoad(fallbackIdentification)
 {
   OfflineTest.is(fallbackIdentification, 1, "Got correct fallback for namespace1 (2)");
 
   applicationCache.onerror = function() {}; // the update invoked by the iframe will finish after we discard the cache, ignore error
--- a/dom/tests/mochitest/ajax/offline/test_bug544462.html
+++ b/dom/tests/mochitest/ajax/offline/test_bug544462.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/wildcardManifest.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/wildcardManifest.cacheManifest">
 <head>
 <title>wildcard in network section test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <style>
@@ -42,12 +42,12 @@ if (OfflineTest.setup()) {
 
 SimpleTest.waitForExplicitFinish();
 
 </script>
 
 </head>
 
 <body>
-  <img src="http://example.com/tests/dom/tests/mochitest/ajax/offline/jupiter.jpg" onload="imageOnLoad(1)" />
+  <img src="https://example.org/tests/dom/tests/mochitest/ajax/offline/jupiter.jpg" onload="imageOnLoad(1)" />
   <img src="jupiter.jpg" onload="imageOnLoad(2)" />
 </body>
 </html>
--- a/dom/tests/mochitest/ajax/offline/test_bug744719-cancel.html
+++ b/dom/tests/mochitest/ajax/offline/test_bug744719-cancel.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/744719-cancel.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/744719-cancel.cacheManifest">
 <head>
 <title>parallel load canceled</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
@@ -16,23 +16,23 @@
 
 if (SpecialPowers.isMainProcess()) {
   ok(applicationCache.mozItems.length == 0,
      "applicationCache.mozItems should be available and empty before associating with a cache.");
 }
 
 function updateCanceled()
 {
-  OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/744719-cancel.cacheManifest", false, null);
-  OfflineTest.checkCache("http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", false, null);
-  OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", false, null);
+  OfflineTest.checkCache("https://example.com/tests/dom/tests/mochitest/ajax/offline/744719-cancel.cacheManifest", false, null);
+  OfflineTest.checkCache("https://example.com/tests/SimpleTest/SimpleTest.js", false, null);
+  OfflineTest.checkCache("https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", false, null);
 
-  OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/nonexistent744719?010", false, null);
+  OfflineTest.checkCache("https://example.com/tests/dom/tests/mochitest/ajax/offline/nonexistent744719?010", false, null);
 
-  var URL = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/subresource744719.html?";
+  var URL = "https://example.com/tests/dom/tests/mochitest/ajax/offline/subresource744719.html?";
   OfflineTest.checkCache(URL + "001", false, null);
   OfflineTest.checkCache(URL + "002", false, null);
   OfflineTest.checkCache(URL + "003", false, null);
   OfflineTest.checkCache(URL + "004", false, null);
   OfflineTest.checkCache(URL + "005", false, null);
   OfflineTest.checkCache(URL + "006", false, null);
   OfflineTest.checkCache(URL + "007", false, null);
   OfflineTest.checkCache(URL + "008", false, null);
--- a/dom/tests/mochitest/ajax/offline/test_bug744719.html
+++ b/dom/tests/mochitest/ajax/offline/test_bug744719.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/744719.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="/tests/dom/tests/mochitest/ajax/offline/744719.cacheManifest">
 <head>
 <title>parallel load</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
@@ -15,21 +15,22 @@
 
 if (SpecialPowers.isMainProcess()) {
   ok(applicationCache.mozItems.length == 0,
      "applicationCache.mozItems should be available and empty before associating with a cache.");
 }
 
 function manifestUpdated()
 {
-  OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/744719.cacheManifest", true);
-  OfflineTest.checkCache("http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true);
-  OfflineTest.checkCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true);
+ok(window.location.href, "my loc" + window.location.href);
+  OfflineTest.checkCache("https://example.com/tests/dom/tests/mochitest/ajax/offline/744719.cacheManifest", true);
+  OfflineTest.checkCache("https://example.com/tests/SimpleTest/SimpleTest.js", true);
+  OfflineTest.checkCache("https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true);
 
-  var URL = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/subresource744719.html?";
+  var URL = "https://example.com/tests/dom/tests/mochitest/ajax/offline/subresource744719.html?";
   OfflineTest.checkCache(URL + "001", true);
   OfflineTest.checkCache(URL + "002", true);
   OfflineTest.checkCache(URL + "003", true);
   OfflineTest.checkCache(URL + "004", true);
   OfflineTest.checkCache(URL + "005", true);
   OfflineTest.checkCache(URL + "006", true);
   OfflineTest.checkCache(URL + "007", true);
   OfflineTest.checkCache(URL + "008", true);
--- a/dom/tests/mochitest/ajax/offline/test_bug765203.html
+++ b/dom/tests/mochitest/ajax/offline/test_bug765203.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/unknownSection.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/unknownSection.cacheManifest">
 <head>
 <title>unknown section</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
@@ -15,27 +15,27 @@ function manifestUpdated()
 {
   OfflineTest.ok(gGotChecking, "Should get a checking event");
   OfflineTest.ok(gGotDownloading, "Should get a downloading event");
 
   OfflineTest.is(applicationCache.status, 1, "Cache status should be 1 (CACHED)");
 
   var entries = [
     // The manifest itself should be in the cache
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/unknownSection.cacheManifest", true],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/unknownSection.cacheManifest", true],
 
     // The document that requested the manifest should be in the cache
     [window.location.href, true],
 
     // The entries from the manifest should be in the cache
-    ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
+    ["https://example.com/tests/SimpleTest/SimpleTest.js", true],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
 
     // The bad entries from the manifest should not be in the cache
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/jupiter.jpg", false]
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/jupiter.jpg", false]
   ];
   OfflineTest.checkCacheEntries(
     entries,
     function() {
        OfflineTest.teardownAndFinish();
     });
 }
 
--- a/dom/tests/mochitest/ajax/offline/test_cancelOfflineCache.html
+++ b/dom/tests/mochitest/ajax/offline/test_cancelOfflineCache.html
@@ -1,19 +1,19 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
 <head>
 <title>Cancel offline cache</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
 
-var manifest = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest";
+var manifest = "https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest";
 var manifestURI = Cc["@mozilla.org/network/io-service;1"]
                   .getService(Ci.nsIIOService)
                   .newURI(manifest);
 var updateService = Cc['@mozilla.org/offlinecacheupdate-service;1']
                     .getService(Ci.nsIOfflineCacheUpdateService);
 
 function manifestCached () {
   OfflineTest.ok(false, "The update was supposed to be canceled");
--- a/dom/tests/mochitest/ajax/offline/test_changingManifest.html
+++ b/dom/tests/mochitest/ajax/offline/test_changingManifest.html
@@ -1,23 +1,23 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/changingManifest.sjs">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/changingManifest.sjs">
 <head>
 <title>changing manifest test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
 
 var gGotChecking = false;
 var gGotDownloading = false;
 
-var g1SecUrl =  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/changing1Sec.sjs";
-var g1HourUrl = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/changing1Hour.sjs";
+var g1SecUrl =  "https://example.com/tests/dom/tests/mochitest/ajax/offline/changing1Sec.sjs";
+var g1HourUrl = "https://example.com/tests/dom/tests/mochitest/ajax/offline/changing1Hour.sjs";
 
 var gCacheContents = null;
 
 function finish()
 {
   OfflineTest.teardownAndFinish();
 }
 
--- a/dom/tests/mochitest/ajax/offline/test_fallback.html
+++ b/dom/tests/mochitest/ajax/offline/test_fallback.html
@@ -1,84 +1,85 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback.cacheManifest">
 <head>
 <title>Fallback entry test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script class="testbody" type="text/javascript">
+/* globals fallbackFrame */
 
 /**
  * This tests that we fall back to the correct fallback entries when loading
  * from fallback namespaces listed in the manifest.  The test is performed twice
  * to make sure that no cache entries are created for the nonexistent items."
  * That would lead to a failure to fallback, as there would always be an entry
  * in the application cache.
  */
 
 var gStep = 1;
 var gChildLoad = false;
 var gTopWindow = null;
 
 function manifestUpdated()
 {
-  fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html";
+  fallbackFrame.location = "https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html";
   // Invokes load of fallback.html
 }
 
 function onFallbackLoad(fallbackIdentification)
 {
   switch (gStep)
   {
     case 001:
       OfflineTest.ok(!gChildLoad, "offline child not load before cache update");
       gChildLoad = true;
       // no break
     case 101:
       OfflineTest.is(fallbackIdentification, 1, "fallback for namespace1/ in step " + gStep);
 
-      fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub-non-existing.html";
+      fallbackFrame.location = "https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/sub-non-existing.html";
       // Invokes load of fallback.html
       break;
 
     case 002:
     case 102:
       OfflineTest.is(fallbackIdentification, 1, "fallback for namespace1/, sub namespace in name of the frame in step " + gStep);
 
-      fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html";
+      fallbackFrame.location = "https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html";
       // Invokes load of fallback2.html
       break;
 
     case 003:
     case 103:
       OfflineTest.is(fallbackIdentification, 2, "fallback for namespace1/sub/ in step " + gStep);
 
-      fallbackFrame.location = "HTTP://MOCHI.TEST:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html";
+      fallbackFrame.location = "HTTPS://EXAMPLE.COM/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html";
       // Invokes load of fallback2.html
       break;
 
     case 004:
     case 104:
       OfflineTest.is(fallbackIdentification, 2, "fallback for namespace1/sub/ in step " + gStep);
 
       // Try opening a non-existing page as a top level document. It must
       // fall to fallbackTop.html that identifies it self as '100'.
       // Invokes load of fallbackTop.html
-      gTopWindow = window.open("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace2/non-existing.html");
+      gTopWindow = window.open("https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace2/non-existing.html");
 
       break;
 
     case 005:
       // Try all over again. This checks there are no entries for non-existing
       // pages created/leaked. That would prevent fallback load.
       gStep = 100;
 
-      fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html";
+      fallbackFrame.location = "https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html";
       // Invokes load of fallback1.html, again, from the start
       // no break
     case 105:
       OfflineTest.is(fallbackIdentification, 100, "fallback for namespace2/, invoked by a top level document " + gStep);
 
       gTopWindow.close();
       gTopWindow = null;
 
@@ -97,20 +98,20 @@ function onFallbackLoad(fallbackIdentifi
 function finishTest()
 {
   OfflineTest.teardownAndFinish();
 }
 
 function finalize()
 {
   var entries = [
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub-non-existing.html", false],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html", false],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html", false],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace2/non-existing.html", false]
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/sub-non-existing.html", false],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html", false],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html", false],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace2/non-existing.html", false]
   ];
   OfflineTest.checkCacheEntries(entries, finishTest);
 }
 
 SimpleTest.waitForExplicitFinish();
 
 if (OfflineTest.setup()) {
   applicationCache.onerror = OfflineTest.failEvent;
--- a/dom/tests/mochitest/ajax/offline/test_foreign.html
+++ b/dom/tests/mochitest/ajax/offline/test_foreign.html
@@ -1,17 +1,18 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign1.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/foreign1.cacheManifest">
 <head>
 <title>Foreign test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script class="testbody" type="text/javascript">
+/* globals foreign1cache */
 
 /**
  * This test loads a manifest that contains as an explicit entry
  * foreign2.html page. After manifest is cached and presence of the
  * foreign2.html page is checked we redirect to foreign2.html
  * page. Then the test continues inside that page as follows:
  * On load of foreign2.html we check there is no associated cache
  * because the foreign2.html page was marked as FOREIGN in foreign1 cache.
@@ -22,22 +23,22 @@
 var win;
 
 function manifestUpdated()
 {
   var appCacheService = SpecialPowers.Cc["@mozilla.org/network/application-cache-service;1"]
     .getService(SpecialPowers.Ci.nsIApplicationCacheService);
 
   foreign1cache = appCacheService.chooseApplicationCache(
-    "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.html", OfflineTest.loadContextInfo());
+    "https://example.com/tests/dom/tests/mochitest/ajax/offline/foreign2.html", OfflineTest.loadContextInfo());
 
   OfflineTest.ok(foreign1cache, "foreign2.html chosen from foreign1 cache");
-  OfflineTest.is(foreign1cache.manifestURI.asciiSpec, "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign1.cacheManifest")
+  OfflineTest.is(foreign1cache.manifestURI.asciiSpec, "https://example.com/tests/dom/tests/mochitest/ajax/offline/foreign1.cacheManifest");
 
-  win = window.open("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/foreign2.html");
+  win = window.open("https://example.com/tests/dom/tests/mochitest/ajax/offline/foreign2.html");
 }
 
 function onDone() // called by the open window after stuff is finished
 {
   win.close();
   OfflineTest.teardownAndFinish();
 }
 
--- a/dom/tests/mochitest/ajax/offline/test_identicalManifest.html
+++ b/dom/tests/mochitest/ajax/offline/test_identicalManifest.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
 <head>
 <title>identical manifest test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
@@ -20,37 +20,37 @@ function noUpdate()
 {
   OfflineTest.ok(gGotChecking, "Should get a checking event");
   OfflineTest.ok(!gGotDownloading, "Should not get a downloading event");
 
   var entries = [
     // The document that requested the manifest should be in the cache
     [window.location.href, true],
 
-    ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true]
+    ["https://example.com/tests/SimpleTest/SimpleTest.js", true],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true]
   ];
   OfflineTest.checkCacheEntries(entries, finishTest);
 }
 
 function manifestUpdated()
 {
   OfflineTest.ok(gGotChecking, "Should get a checking event");
   OfflineTest.ok(gGotDownloading, "Should get a downloading event");
 
   var entries = [
     // The manifest itself should be in the cache
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest", true],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest", true],
 
     // The document that requested the manifest should be in the cache
     [window.location.href, true],
 
     // The entries from the manifest should be in the cache
-    ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
+    ["https://example.com/tests/SimpleTest/SimpleTest.js", true],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
 
     // The bad entries from the manifest should not be in the cache
     ["bad:/uri/invalid", false]
   ];
   OfflineTest.checkCacheEntries(entries, manifestUpdatedContinue);
 }
 
 function manifestUpdatedContinue()
--- a/dom/tests/mochitest/ajax/offline/test_lowDeviceStorage.html
+++ b/dom/tests/mochitest/ajax/offline/test_lowDeviceStorage.html
@@ -65,17 +65,17 @@ if (OfflineTest.setup()) {
           OfflineTest.ok(false, "The update was supposed to be canceled");
           finish();
           break;
       }
     },
     applicationCacheAvailable: function() {}
   });
 
-  var manifest = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest";
+  var manifest = "https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest";
   var ioService = Cc["@mozilla.org/network/io-service;1"]
                   .getService(Ci.nsIIOService);
   var manifestURI = ioService.newURI(manifest);
   var documentURI = ioService.newURI(document.documentURI);
   var update = updateService.scheduleUpdate(manifestURI, documentURI, systemPrincipal, window);
   update.addObserver(updateObserver, false);
 }
 
--- a/dom/tests/mochitest/ajax/offline/test_lowDeviceStorageDuringUpdate.html
+++ b/dom/tests/mochitest/ajax/offline/test_lowDeviceStorageDuringUpdate.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
 <head>
 <title>Low device storage during update</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
--- a/dom/tests/mochitest/ajax/offline/test_missingFile.html
+++ b/dom/tests/mochitest/ajax/offline/test_missingFile.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/missingFile.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/missingFile.cacheManifest">
 <head>
 <title>missing manifest file test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
@@ -18,18 +18,18 @@ function finishTest() {
 function handleError() {
   OfflineTest.ok(gGotChecking, "Expected checking event");
   OfflineTest.ok(gGotDownloading, "Expected downloading event");
   OfflineTest.ok(true, "Expected error event");
 
   // These items are listed in the manifest, but the error should have
   // prevented them from being committed to the cache.
   var entries = [
-    ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", false],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", false]
+    ["https://example.com/tests/SimpleTest/SimpleTest.js", false],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", false]
   ];
   OfflineTest.checkCacheEntries(entries, finishTest);
 }
 
 if (OfflineTest.setup()) {
   // Don't expect any "success" events.
   applicationCache.onupdateready = function() { OfflineTest.failEvent("updateready"); }
   applicationCache.oncached = function() { OfflineTest.failEvent("cached"); }
--- a/dom/tests/mochitest/ajax/offline/test_obsolete.html
+++ b/dom/tests/mochitest/ajax/offline/test_obsolete.html
@@ -9,17 +9,17 @@
 
 var gTestWin;
 
 SpecialPowers.pushPermissions([{'type': 'offline-app', 'allow': true, 'context': document}], startTest);
 
 function startTest() {
   // Make the obsoleting.sjs return a valid manifest
   var req = new XMLHttpRequest();
-  req.open("GET", "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/obsoletingManifest.sjs?state=manifestPresent");
+  req.open("GET", "https://example.com/tests/dom/tests/mochitest/ajax/offline/obsoletingManifest.sjs?state=manifestPresent");
   req.setRequestHeader("Content-Type", "text/cache-manifest");
   req.send("");
   req.onreadystatechange = function() {
     if (req.readyState == 4) {
       // now this will properly load the manifest.
       gTestWin = window.open("obsolete.html");
     }
   }
--- a/dom/tests/mochitest/ajax/offline/test_offlineIFrame.html
+++ b/dom/tests/mochitest/ajax/offline/test_offlineIFrame.html
@@ -1,27 +1,27 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
 <head>
 <title>offline iframe test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
 
 
 function checkEntries() {
   var entries = [
     // The manifest itself should be in the cache
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest", true],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest", true],
 
     // The entries from the manifest should be in the cache
-    ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true]
+    ["https://example.com/tests/SimpleTest/SimpleTest.js", true],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true]
   ];
   OfflineTest.checkCacheEntries(entries, function() { window.frames["offlineChild"].doneLoading(); });
 }
 
 function childFinished()
 {
   OfflineTest.teardownAndFinish();
 }
--- a/dom/tests/mochitest/ajax/offline/test_offlineMode.html
+++ b/dom/tests/mochitest/ajax/offline/test_offlineMode.html
@@ -1,17 +1,18 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs">
 <head>
 <title>Offline mode test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script class="testbody" type="text/javascript">
+/* globals aFrame */
 
 /**
  * The test loads a manifest and cache it.
  * Then tests if all works in online mode
  * as expected. Then switches firefox to offline
  * mode and tries the page load still works as
  * expected, i.e. all items from the cache load.
  */
@@ -29,46 +30,46 @@ function createURI(urispec)
                          .getService(Components.interfaces.nsIIOService);
   return ioServ.newURI(urispec);
 }
 
 // test
 
 function manifestUpdated()
 {
-  applicationCache.mozAdd("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/notonwhitelist.html");
-  OfflineTest.waitForAdd("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/notonwhitelist.html", dynamicAdded);
+  applicationCache.mozAdd("https://example.com/tests/dom/tests/mochitest/ajax/offline/notonwhitelist.html");
+  OfflineTest.waitForAdd("https://example.com/tests/dom/tests/mochitest/ajax/offline/notonwhitelist.html", dynamicAdded);
 }
 
 function dynamicAdded()
 {
-  aFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/notonwhitelist.html";
+  aFrame.location = "https://example.com/tests/dom/tests/mochitest/ajax/offline/notonwhitelist.html";
 }
 
 // Called by the dynamically added iframe on load
 function notwhitelistOnLoad()
 {
   gGotDynamicVersion = 1;
-  aFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs";
+  aFrame.location = "https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs";
 }
 
 // Called by the explicit iframe on load
 function frameLoad(version)
 {
   gGotExplicitVersion = version;
-  gImplicitWindow = window.open("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html");
+  gImplicitWindow = window.open("https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html");
 }
 
 // Called by the implicit window on load
 function implicitLoaded(aWindow, errorOccured)
 {
   aWindow.close();
 
   gGotImplicitVersion = 1;
-  OfflineTest.waitForAdd("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html", implicitAdded);
+  OfflineTest.waitForAdd("https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html", implicitAdded);
 }
 
 function implicitAdded()
 {
   OfflineTest.priv(finalize)();
 }
 
 function finalize()
@@ -84,19 +85,19 @@ function finalize()
     OfflineTest.is(gGotImplicitVersion, 1, "Implicit entry loaded");
     OfflineTest.is(gGotDynamicVersion, 1, "Dynamic entry loaded");
 
     gGotExplicitVersion = 0;
     gGotImplicitVersion = 0;
     gGotDynamicVersion = 0;
 
     var entries = [
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/notonwhitelist.html", true],
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs", true],
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html", true]
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/notonwhitelist.html", true],
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs", true],
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html", true]
     ];
     OfflineTest.checkCacheEntries(entries, goOffline);
   }
   else
   {
     gImplicitWindow.close();
 
     ioserv.offline = false;
@@ -117,35 +118,35 @@ function goOffline()
       OfflineTest.priv(goOfflineContinue)();
     }
   };
 
   // Delete HTTP cache to ensure we are going from offline cache
   var cache = Cc["@mozilla.org/network/cache-storage-service;1"]
       .getService(Ci.nsICacheStorageService);
   var storage = cache.diskCacheStorage(LoadContextInfo.default, false);
-  storage.asyncDoomURI(createURI("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/notonwhitelist.html"), "", null);
-  storage.asyncDoomURI(createURI("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs"), "", null);
-  storage.asyncDoomURI(createURI("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html"), "", listener);
+  storage.asyncDoomURI(createURI("https://example.com/tests/dom/tests/mochitest/ajax/offline/notonwhitelist.html"), "", null);
+  storage.asyncDoomURI(createURI("https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs"), "", null);
+  storage.asyncDoomURI(createURI("https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html"), "", listener);
 }
 
 function goOfflineContinue()
 {
   var ioserv = Cc["@mozilla.org/network/io-service;1"]
       .getService(Ci.nsIIOService);
 
   ioserv.offline = true;
 
   gCompleteTimeout = window.setTimeout(OfflineTest.priv(finalize), 10000);
 
   // remove error handling. in offline mode
   // is correct to get error message
   applicationCache.onerror = function() {gGotOnError = true;}
 
-  aFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/notonwhitelist.html";
+  aFrame.location = "https://example.com/tests/dom/tests/mochitest/ajax/offline/notonwhitelist.html";
   // Starts the chain all over again but in offline mode.
 }
 
 SimpleTest.waitForExplicitFinish();
 
 if (OfflineTest.setup()) {
   applicationCache.onerror = OfflineTest.failEvent;
   applicationCache.onupdateready = OfflineTest.failEvent;
--- a/dom/tests/mochitest/ajax/offline/test_overlap.html
+++ b/dom/tests/mochitest/ajax/offline/test_overlap.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/overlap.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/overlap.cacheManifest">
 <head>
 <title>overlapping namespaces test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
--- a/dom/tests/mochitest/ajax/offline/test_redirectManifest.html
+++ b/dom/tests/mochitest/ajax/offline/test_redirectManifest.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/manifestRedirect.sjs">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/manifestRedirect.sjs">
 <head>
 <title>Fail update on manifest redirection test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script class="testbody" type="text/javascript">
--- a/dom/tests/mochitest/ajax/offline/test_redirectUpdateItem.html
+++ b/dom/tests/mochitest/ajax/offline/test_redirectUpdateItem.html
@@ -1,81 +1,81 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/redirects.sjs">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/redirects.sjs">
 <head>
 <title>Entries redirection handling during update test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script class="testbody" type="text/javascript">
 
 var gCurrentManifestVersion = 1;
 
 function manifestCached()
 {
   var entries = [
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs", false],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs", true],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs", false],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs", true],
   ];
   OfflineTest.checkCacheEntries(entries, manifestCachedContinue);
 }
 
 function manifestCachedContinue()
 {
   OfflineTest.is(gCurrentManifestVersion, 1, "Cached event for manifest version one");
 
   // Now add one dynamic entry (now with content overriden redirect sjs)
   applicationCache.mozAdd(
-    "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs");
+    "https://example.com/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs");
 
   // Wait for the dynamic entry be added to the cache...
   OfflineTest.waitForAdd(
-    "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs",
+    "https://example.com/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs",
     function() {
       // ...check it is there...
       OfflineTest.checkCache(
-        "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs",
+        "https://example.com/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs",
         true,
         function() {
           // ...revert state of the dynamic entry on the server, now we get the redirect...
           OfflineTest.setSJSState(
-            "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs",
+            "https://example.com/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs",
             "");
 
           // ...update manifest to the new version on the server...
           OfflineTest.setSJSState(
-            "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/redirects.sjs",
+            "https://example.com/tests/dom/tests/mochitest/ajax/offline/redirects.sjs",
             "second");
           gCurrentManifestVersion = 2;
 
           // ...and finally invoke the cache update.
           applicationCache.update();
         });
     });
 }
 
 function manifestUpdated()
 {
   switch (gCurrentManifestVersion)
   {
     case 2:
       // Check the dynamic entry was removed from the cache (because of the redirect)...
       OfflineTest.checkCache(
-        "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs",
+        "https://example.com/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs",
         false,
         function () {
           // ...return back redirect for the explicit entry...
           OfflineTest.setSJSState(
-            "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs",
+            "https://example.com/tests/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs",
             "");
 
           // ...update the manifest to the third version...
           OfflineTest.setSJSState(
-            "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/redirects.sjs",
+            "https://example.com/tests/dom/tests/mochitest/ajax/offline/redirects.sjs",
             "third");
           gCurrentManifestVersion = 3;
 
           // ...and invoke the cache update, now we must get error.
           applicationCache.update();
         });
 
       break;
@@ -116,20 +116,20 @@ SimpleTest.requestFlakyTimeout("untriage
 
 if (OfflineTest.setup()) {
   applicationCache.onerror = OfflineTest.priv(manifestError);
   applicationCache.onupdateready = OfflineTest.priv(manifestUpdated);
   applicationCache.oncached = OfflineTest.priv(manifestCached);
 
   // Override sjs redirects on the server, it will now return 200 OK and the content
   OfflineTest.setSJSState(
-      "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs",
+      "https://example.com/tests/dom/tests/mochitest/ajax/offline/explicitRedirect.sjs",
       "on");
   OfflineTest.setSJSState(
-      "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs",
+      "https://example.com/tests/dom/tests/mochitest/ajax/offline/dynamicRedirect.sjs",
       "on");
 }
 
 </script>
 
 </head>
 
 <body>
--- a/dom/tests/mochitest/ajax/offline/test_refetchManifest.html
+++ b/dom/tests/mochitest/ajax/offline/test_refetchManifest.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/changingManifest.sjs">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/changingManifest.sjs">
 <head>
 <title>refetch manifest test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 
 <script type="text/javascript">
 
--- a/dom/tests/mochitest/ajax/offline/test_simpleManifest.html
+++ b/dom/tests/mochitest/ajax/offline/test_simpleManifest.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
 <head>
 <title>simple manifest test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
@@ -12,69 +12,69 @@ var gGotChecking = false;
 var gGotDownloading = false;
 
 ok(applicationCache.mozItems.length == 0,
    "applicationCache.mozItems should be available and empty before associating with a cache.");
 
 function addFinished()
 {
   OfflineTest.ok(applicationCache.mozLength == 1, "applicationCache should have one dynamic entry (deprecated API)");
-  OfflineTest.ok(applicationCache.mozItem(0) == "http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
+  OfflineTest.ok(applicationCache.mozItem(0) == "https://example.com/tests/SimpleTest/EventUtils.js",
     "applicationCache's dynamic entry should be the one we expect (deprecated API)");
 
   OfflineTest.ok(applicationCache.mozItems.length == 1, "applicationCache should have one dynamic entry");
-  OfflineTest.ok(applicationCache.mozItems[0] == "http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
+  OfflineTest.ok(applicationCache.mozItems[0] == "https://example.com/tests/SimpleTest/EventUtils.js",
     "applicationCache's dynamic entry should be the one we expect");
 
-  OfflineTest.ok(applicationCache.mozHasItem("http://mochi.test:8888/tests/SimpleTest/EventUtils.js"),
+  OfflineTest.ok(applicationCache.mozHasItem("https://example.com/tests/SimpleTest/EventUtils.js"),
                  "applicationCache.mozHasItem() should see the dynamic entry");
 
   // Check that the entry was added successfully
-  OfflineTest.checkCache("http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
+  OfflineTest.checkCache("https://example.com/tests/SimpleTest/EventUtils.js",
                          true,
                          removeItem);
 }
 
 function removeItem()
 {
   // Now test that removes work
-  applicationCache.mozRemove("http://mochi.test:8888/tests/SimpleTest/EventUtils.js");
+  applicationCache.mozRemove("https://example.com/tests/SimpleTest/EventUtils.js");
 
   OfflineTest.ok(applicationCache.mozLength == 0,
                  "applicationCache should have no dynamic entries (deprecated API)");
   OfflineTest.ok(applicationCache.mozItems.length == 0,
                  "applicationCache should have no dynamic entries");
-  OfflineTest.ok(!applicationCache.mozHasItem("http://mochi.test:8888/tests/SimpleTest/EventUtils.js"),
+  OfflineTest.ok(!applicationCache.mozHasItem("https://example.com/tests/SimpleTest/EventUtils.js"),
                  "applicationCache.mozHasItem() should not see the removed dynamic entry");
 
-  OfflineTest.checkCache("http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
+  OfflineTest.checkCache("https://example.com/tests/SimpleTest/EventUtils.js",
                          false,
                          function() {
                            // We're done
                            OfflineTest.teardownAndFinish();
                          });
 }
 
 function manifestUpdated()
 {
   OfflineTest.ok(gGotChecking, "Should get a checking event");
   OfflineTest.ok(gGotDownloading, "Should get a downloading event");
 
   OfflineTest.is(applicationCache.status, 1, "Cache status should be 1 (CACHED)");
 
   var entries = [
     // The manifest itself should be in the cache
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest", true],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest", true],
 
     // The document that requested the manifest should be in the cache
     [window.location.href, true],
 
     // The entries from the manifest should be in the cache
-    ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
+    ["https://example.com/tests/SimpleTest/SimpleTest.js", true],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
 
     // The bad entries from the manifest should not be in the cache
     ["bad:/uri/invalid", false]
   ];
   OfflineTest.checkCacheEntries(
     entries,
     function() {
       try {
@@ -82,20 +82,20 @@ function manifestUpdated()
         OfflineTest.ok(false, "application.swapCache() should fail after initial update.");
       } catch(ex) {
         OfflineTest.ok(true, "application.swapCache() should fail after initial update.");
       }
 
       // XXX: make sure that the previous version went away after the swapCache().
 
       // Now add a file using the applicationCache API
-      applicationCache.mozAdd("http://mochi.test:8888/tests/SimpleTest/EventUtils.js");
+      applicationCache.mozAdd("https://example.com/tests/SimpleTest/EventUtils.js");
 
       // Wait for the add() to be downloaded
-      OfflineTest.waitForAdd("http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
+      OfflineTest.waitForAdd("https://example.com/tests/SimpleTest/EventUtils.js",
                              OfflineTest.priv(addFinished));
     });
 }
 
 if (OfflineTest.setup()) {
   OfflineTest.ok(applicationCache instanceof EventTarget,
                  "applicationCache should be an event target");
 
--- a/dom/tests/mochitest/ajax/offline/test_updateCheck.html
+++ b/dom/tests/mochitest/ajax/offline/test_updateCheck.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs">
 <head>
 <title>Cache update test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script class="testbody" type="text/javascript">
@@ -17,17 +17,17 @@
  * - check for an update ones again, expected is "update avail" (secondary check to probe
  *   we didn't screw state of the manifest in the current cache with the first check)
  * - cache the modified manifest, new version is now in the cache
  * - last check for an update, expected is "no update avail" again
  */
 
 SimpleTest.waitForExplicitFinish();
 
-var manifest = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs";
+var manifest = "https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs";
 var manifestURI = Cc["@mozilla.org/network/io-service;1"]
                   .getService(Ci.nsIIOService)
                   .newURI(manifest);
 var updateService = Cc['@mozilla.org/offlinecacheupdate-service;1']
                     .getService(Ci.nsIOfflineCacheUpdateService);
 
 var systemPrincipal = SpecialPowers.Services.scriptSecurityManager.getSystemPrincipal();
 
--- a/dom/tests/mochitest/ajax/offline/test_updatingManifest.html
+++ b/dom/tests/mochitest/ajax/offline/test_updatingManifest.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs">
 <head>
 <title>Cache update test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script class="testbody" type="text/javascript">
@@ -108,184 +108,184 @@ function whitelistOnLoad(version)
 // ================================
 
 function manifestCached()
 {
   OfflineTest.is(gStep, 0, "Got manifestCached in step 0, gStep=" + gStep);
 
   reloadLocations([fallbackFrame1, fallbackFrame2]);
   waitForLocations(
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback.html"],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback.html"],
     fallbackLoaded
   );
 }
 
 function fallbackLoaded()
 {
   dump("in fallbackLoaded\n");
-  applicationCache.mozAdd("http://mochi.test:8888/tests/SimpleTest/EventUtils.js");
-  OfflineTest.waitForAdd("http://mochi.test:8888/tests/SimpleTest/EventUtils.js",
+  applicationCache.mozAdd("https://example.com/tests/SimpleTest/EventUtils.js");
+  OfflineTest.waitForAdd("https://example.com/tests/SimpleTest/EventUtils.js",
       dynamicLoaded);
 }
 
 function dynamicLoaded()
 {
-  window.open("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html");
+  window.open("https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html");
   // window.applicationCache.noupdate invokes implicitLoaded()
 }
 
 function implicitLoaded(aWindow, errorOccured)
 {
   aWindow.close();
 
   OfflineTest.ok(!errorOccured, "No error on new implicit page manifest update");
 
-  OfflineTest.waitForAdd("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html",
+  OfflineTest.waitForAdd("https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html",
       implicitCached);
 }
 
 function implicitCached()
 {
   // Checking first version of the manifest + another implict page caching
 
   // Whitelist entries
-  checkFallbackAndWhitelisting("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html", "", true);
+  checkFallbackAndWhitelisting("https://example.com/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html", "", true);
 
   // Fallback URI selection check
-  checkFallbackAndWhitelisting("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/opp.html",
-      "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback.html", false);
-  checkFallbackAndWhitelisting("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/opp.html",
-      "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback.html", false);
+  checkFallbackAndWhitelisting("https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/opp.html",
+      "https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback.html", false);
+  checkFallbackAndWhitelisting("https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/opp.html",
+      "https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback.html", false);
 
   // Cache object status
   OfflineTest.is(applicationCache.status, SpecialPowers.Ci.nsIDOMOfflineResourceList.IDLE,
       "we have associated application cache (1)");
 
   OfflineTest.is(gGotFrameVersion, 1, "IFrame version 1");
 
   var entries = [
     // Explicit entries
-    ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", false],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
+    ["https://example.com/tests/SimpleTest/SimpleTest.js", false],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
 
     // Fallback entries
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback.html", true],
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback2.html", false],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback.html", true],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback2.html", false],
 
     // Whitelist entries
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html", false],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html", false],
 
     // Implicit entries
-    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html", true],
+    ["https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html", true],
 
     // Dynamic entries
-    ["http://mochi.test:8888/tests/SimpleTest/EventUtils.js", true]
+    ["https://example.com/tests/SimpleTest/EventUtils.js", true]
   ];
   OfflineTest.checkCacheEntries(
     entries,
     function() {
       ++gStep;
 
-      OfflineTest.setSJSState("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs", "second");
+      OfflineTest.setSJSState("https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs", "second");
 
       applicationCache.update();
       // Invokes manifestUpdated()
     });
 }
 
 function manifestUpdated()
 {
   OfflineTest.ok(gStep == 1 || gStep == 2, "Got manifestUpdated in step 1 or 2, gStep=" + gStep);
 
   switch (gStep)
   {
   case 1:
     // Processing second version of the manifest.
 
     // Whitelist entries
-    checkFallbackAndWhitelisting("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html", "", false);
+    checkFallbackAndWhitelisting("https://example.com/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html", "", false);
 
     // Fallback URI selection check
-    checkFallbackAndWhitelisting("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/opp.html",
-        "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback.html", false);
-    checkFallbackAndWhitelisting("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/opp.html",
-        "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback2.html", false);
+    checkFallbackAndWhitelisting("https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/opp.html",
+        "https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback.html", false);
+    checkFallbackAndWhitelisting("https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/opp.html",
+        "https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback2.html", false);
 
     // Cache object status
     OfflineTest.is(applicationCache.status, SpecialPowers.Ci.nsIDOMOfflineResourceList.UPDATEREADY,
         "we have associated application cache and update is pending (2)");
 
     var entries = [
       // Explicit entries
-      ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true],
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
+      ["https://example.com/tests/SimpleTest/SimpleTest.js", true],
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
 
       // Fallback entries
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback.html", true],
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback2.html", true],
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback.html", true],
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback2.html", true],
 
       // Whitelist entries
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html", false],
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html", false],
 
       // Implicit entries
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html", true],
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html", true],
 
       // Dynamic entries
-      ["http://mochi.test:8888/tests/SimpleTest/EventUtils.js", true]
+      ["https://example.com/tests/SimpleTest/EventUtils.js", true]
     ];
     OfflineTest.checkCacheEntries(
       entries,
       function() {
         ++gStep;
 
-        OfflineTest.setSJSState("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs", "third");
-        OfflineTest.setSJSState("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs", "second");
+        OfflineTest.setSJSState("https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs", "third");
+        OfflineTest.setSJSState("https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs", "second");
 
         gGotFrameVersion = 0;
         updatingFrame.location.reload();
         // Since the frame is offline-cached, reload of it invokes update
       });
 
     break;
 
   case 2:
     // Processing third version of the manifest.
 
     // Whitelist entries
-    checkFallbackAndWhitelisting("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html", "", true);
+    checkFallbackAndWhitelisting("https://example.com/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html", "", true);
 
     // Fallback URI selection check
-    checkFallbackAndWhitelisting("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/opp.html",
+    checkFallbackAndWhitelisting("https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/opp.html",
         "", false);
-    checkFallbackAndWhitelisting("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/opp.html",
-        "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback2.html", false);
+    checkFallbackAndWhitelisting("https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/opp.html",
+        "https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback2.html", false);
 
     // Cache object status
     OfflineTest.is(applicationCache.status, SpecialPowers.Ci.nsIDOMOfflineResourceList.UPDATEREADY,
         "we have associated application cache and update is pending (3)");
 
     OfflineTest.is(gGotFrameVersion, 1, "IFrame version 1 because cache was not swapped");
 
     var entries = [
       // Explicit entries
-      ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", false],
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
+      ["https://example.com/tests/SimpleTest/SimpleTest.js", false],
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
 
       // Fallback entries
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback.html", false],
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/fallback2.html", true],
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback.html", false],
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/fallback2.html", true],
 
       // Whitelist entries
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html", false],
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html", false],
 
       // Implicit entries
-      ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html", true],
+      ["https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html", true],
 
       // Dynamic entries
-      ["http://mochi.test:8888/tests/SimpleTest/EventUtils.js", true]
+      ["https://example.com/tests/SimpleTest/EventUtils.js", true]
     ];
     OfflineTest.checkCacheEntries(
       entries,
       function() {
         ++gStep;
 
         applicationCache.onnoupdate = OfflineTest.priv(manifestNoUpdate);
         applicationCache.update();
@@ -333,14 +333,14 @@ if (OfflineTest.setup()) {
   applicationCache.oncached = OfflineTest.priv(manifestCached);
 }
 
 </script>
 
 </head>
 
 <body>
-  <iframe name="updatingFrame" src="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs"></iframe>
-  <iframe name="fallbackFrame1" src="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/opp.html"></iframe>
-  <iframe name="fallbackFrame2" src="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/opp.html"></iframe>
-  <iframe name="whitelistFrame" src="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html"></iframe>
+  <iframe name="updatingFrame" src="https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs"></iframe>
+  <iframe name="fallbackFrame1" src="https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/opp.html"></iframe>
+  <iframe name="fallbackFrame2" src="https://example.com/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/opp.html"></iframe>
+  <iframe name="whitelistFrame" src="https://example.com/tests/dom/tests/mochitest/ajax/offline/onwhitelist.html"></iframe>
 </body>
 </html>
--- a/dom/tests/mochitest/ajax/offline/test_xhtmlManifest.xhtml
+++ b/dom/tests/mochitest/ajax/offline/test_xhtmlManifest.xhtml
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest">
 <head>
 <title>xhtml manifest test</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 
 <script type="text/javascript">
--- a/dom/tests/mochitest/ajax/offline/unknownSection.cacheManifest
+++ b/dom/tests/mochitest/ajax/offline/unknownSection.cacheManifest
@@ -1,10 +1,10 @@
 CACHE MANIFEST
-http://mochi.test:8888/tests/SimpleTest/SimpleTest.js
+https://example.com/tests/SimpleTest/SimpleTest.js
 
 UNKNOWN-SECTION:
-http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/jupiter.jpg
+https://example.com/tests/dom/tests/mochitest/ajax/offline/jupiter.jpg
 here can be anything the current implementaion
 is not able to parse at all and is just silently ignored
 
 CACHE:
-http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
+https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
--- a/dom/tests/mochitest/ajax/offline/updatingImplicit.html
+++ b/dom/tests/mochitest/ajax/offline/updatingImplicit.html
@@ -1,9 +1,9 @@
-<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs">
+<html xmlns="http://www.w3.org/1999/xhtml" manifest="https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs">
 <head>
 <title>Updating implicit</title>
 
 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
 
 <script type="text/javascript">
 
--- a/dom/tests/mochitest/ajax/offline/updatingManifest.sjs
+++ b/dom/tests/mochitest/ajax/offline/updatingManifest.sjs
@@ -1,39 +1,39 @@
 ver1manifest =
   "CACHE MANIFEST\n" +
   "# v1\n" +
   "\n" +
-  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
-  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs\n" +
+  "https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
+  "https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs\n" +
   "\n" +
   "FALLBACK:\n" +
   "namespace1/ fallback.html\n" +
   "\n" +
   "NETWORK:\n" +
   "onwhitelist.html\n";
 
 ver2manifest =
   "CACHE MANIFEST\n" +
   "# v2\n" +
   "\n" +
-  "http://mochi.test:8888/tests/SimpleTest/SimpleTest.js\n" +
-  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
-  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs" +
+  "https://example.com/tests/SimpleTest/SimpleTest.js\n" +
+  "https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
+  "https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs" +
   "\n" +
   "FALLBACK:\n" +
   "namespace1/ fallback.html\n" +
   "namespace1/sub/ fallback2.html\n";
 
 ver3manifest =
   "CACHE MANIFEST\n" +
   "# v3\n" +
   "\n" +
-  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
-  "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs" +
+  "https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js\n" +
+  "https://example.com/tests/dom/tests/mochitest/ajax/offline/updatingIframe.sjs" +
   "\n" +
   "FALLBACK:\n" +
   "namespace1/sub fallback2.html\n" +
   "\n" +
   "NETWORK:\n" +
   "onwhitelist.html\n";
 
 function handleRequest(request, response)
--- a/dom/tests/mochitest/ajax/offline/wildcardManifest.cacheManifest
+++ b/dom/tests/mochitest/ajax/offline/wildcardManifest.cacheManifest
@@ -1,7 +1,7 @@
 CACHE MANIFEST
 
-http://mochi.test:8888/tests/SimpleTest/SimpleTest.js
-http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
+https://example.com/tests/SimpleTest/SimpleTest.js
+https://example.com/tests/dom/tests/mochitest/ajax/offline/offlineTests.js
 
 NETWORK:
 *
--- a/dom/tests/moz.build
+++ b/dom/tests/moz.build
@@ -179,17 +179,17 @@ MOCHITEST_CHROME_MANIFESTS += [
     'mochitest/geolocation/chrome.ini',
     'mochitest/localstorage/chrome.ini',
     'mochitest/sessionstorage/chrome.ini',
     'mochitest/webcomponents/chrome.ini',
     'mochitest/whatwg/chrome.ini',
 ]
 
 XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
-BROWSER_CHROME_MANIFESTS += ['browser/browser.ini']
+BROWSER_CHROME_MANIFESTS += ['browser/browser.ini', 'mochitest/ajax/offline/browser.ini']
 
 TEST_HARNESS_FILES.testing.mochitest.tests.dom.tests.mochitest.ajax.lib += [
     'mochitest/ajax/lib/AJAX_setup.js',
     'mochitest/ajax/lib/test.css',
 ]
 
 TEST_HARNESS_FILES.testing.mochitest.tests.dom.tests.mochitest.ajax.mochikit.tests += [
     'mochitest/ajax/mochikit/tests/cli.js',
--- a/dom/webidl/Window.webidl
+++ b/dom/webidl/Window.webidl
@@ -67,17 +67,17 @@ interface XULControllers;
   [Throws] WindowProxy? open(optional DOMString url = "", optional DOMString target = "", [TreatNullAs=EmptyString] optional DOMString features = "");
   getter object (DOMString name);
 
   // the user agent
   readonly attribute Navigator navigator;
 #ifdef HAVE_SIDEBAR
   [Replaceable, Throws] readonly attribute External external;
 #endif
-  [Throws, Pref="browser.cache.offline.enable"] readonly attribute ApplicationCache applicationCache;
+  [Throws, Pref="browser.cache.offline.enable", Func="nsGlobalWindowInner::OfflineCacheAllowedForContext"] readonly attribute ApplicationCache applicationCache;
 
   // user prompts
   [Throws, NeedsSubjectPrincipal] void alert();
   [Throws, NeedsSubjectPrincipal] void alert(DOMString message);
   [Throws, NeedsSubjectPrincipal] boolean confirm(optional DOMString message = "");
   [Throws, NeedsSubjectPrincipal] DOMString? prompt(optional DOMString message = "", optional DOMString default = "");
   [Throws, Func="nsGlobalWindowInner::IsWindowPrintEnabled"]
   void print();
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -83,16 +83,25 @@ pref("browser.cache.disk.preload_chunk_c
 pref("browser.cache.frecency_half_life_hours", 6);
 
 // Number of seconds the cache spends writting pending data and closing files
 // after the shutdown has been signalled.  Past that time data are never written
 // and files are left open given up to the OS to do the cleanup.
 pref("browser.cache.max_shutdown_io_lag", 2);
 
 pref("browser.cache.offline.enable",           true);
+
+// Nightly and Early Beta will have AppCache disabled by default
+// Stable will remain enabled until Firefox 62.
+#ifdef EARLY_BETA_OR_EARLIER
+pref("browser.cache.offline.insecure.enable",  false);
+#else
+pref("browser.cache.offline.insecure.enable",  true);
+#endif
+
 // enable offline apps by default, disable prompt
 pref("offline-apps.allow_by_default",          true);
 
 // offline cache capacity in kilobytes
 pref("browser.cache.offline.capacity",         512000);
 
 // the user should be warned if offline app disk usage exceeds this amount
 // (in kilobytes)
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -8677,16 +8677,22 @@ nsHttpChannel::MaybeWarnAboutAppCache()
     Telemetry::Accumulate(Telemetry::HTTP_OFFLINE_CACHE_DOCUMENT_LOAD,
                           true);
 
     // Then, issue a deprecation warning.
     nsCOMPtr<nsIDeprecationWarner> warner;
     GetCallback(warner);
     if (warner) {
         warner->IssueWarning(nsIDocument::eAppCache, false);
+        // When the page is insecure and the API is still enabled
+        // provide an additional warning for developers of removal
+        if (!IsHTTPS() &&
+            Preferences::GetBool("browser.cache.offline.insecure.enable")) {
+            warner->IssueWarning(nsIDocument::eAppCacheInsecure, true);
+        }
     }
 }
 
 void
 nsHttpChannel::SetLoadGroupUserAgentOverride()
 {
     nsCOMPtr<nsIURI> uri;
     GetURI(getter_AddRefs(uri));
--- a/testing/web-platform/meta/html/browsers/offline/appcache/workers/appcache-worker.html.ini
+++ b/testing/web-platform/meta/html/browsers/offline/appcache/workers/appcache-worker.html.ini
@@ -1,9 +1,10 @@
 [appcache-worker.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
   expected: TIMEOUT
   [Dedicated worker of the cached script]
     expected: FAIL
 
   [Dedicated worker of the fallbacked script]
     expected: FAIL
 
   [Shared worker of the cached script]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/html/browsers/offline/application-cache-api/api_status_idle.html.ini
@@ -0,0 +1,2 @@
+[api_status_idle.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/html/browsers/offline/application-cache-api/api_status_uncached.html.ini
@@ -0,0 +1,2 @@
+[api_status_uncached.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/html/browsers/offline/application-cache-api/api_swapcache_error.html.ini
@@ -0,0 +1,2 @@
+[api_swapcache_error.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/html/browsers/offline/application-cache-api/api_update.html.ini
@@ -0,0 +1,2 @@
+[api_update.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
--- a/testing/web-platform/meta/html/browsers/offline/application-cache-api/api_update_error.html.ini
+++ b/testing/web-platform/meta/html/browsers/offline/application-cache-api/api_update_error.html.ini
@@ -1,4 +1,5 @@
 [api_update_error.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
   [INVALID_STATE_ERR error test]
     expected: FAIL
 
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/html/browsers/offline/introduction-4/event_cached.html.ini
@@ -0,0 +1,2 @@
+[event_cached.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/html/browsers/offline/introduction-4/event_checking.html.ini
@@ -0,0 +1,2 @@
+[event_checking.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/html/browsers/offline/introduction-4/event_noupdate.html.ini
@@ -0,0 +1,2 @@
+[event_noupdate.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/html/browsers/offline/introduction-4/event_progress.html.ini
@@ -0,0 +1,2 @@
+[event_progress.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/html/browsers/offline/manifest_url_check.html.ini
@@ -0,0 +1,2 @@
+[manifest_url_check.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
--- a/testing/web-platform/meta/html/browsers/the-window-object/security-window/window-security.html.ini
+++ b/testing/web-platform/meta/html/browsers/the-window-object/security-window/window-security.html.ini
@@ -1,9 +1,10 @@
 [window-security.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
   [A SecurityError exception must be thrown when window.oncancel is accessed from a different origin.]
     expected: FAIL
 
   [A SecurityError exception must be thrown when window.oncuechange is accessed from a different origin.]
     expected: FAIL
 
   [A SecurityError exception must be thrown when window.onmousewheel is accessed from a different origin.]
     expected: FAIL
--- a/testing/web-platform/meta/html/browsers/the-window-object/window-properties.html.ini
+++ b/testing/web-platform/meta/html/browsers/the-window-object/window-properties.html.ini
@@ -1,9 +1,10 @@
 [window-properties.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
   [Window attribute: oncancel]
     expected: FAIL
 
   [Window attribute: oncuechange]
     expected: FAIL
 
   [Window attribute: onmousewheel]
     expected: FAIL
--- a/testing/web-platform/meta/html/dom/dynamic-markup-insertion/opening-the-input-stream/009.html.ini
+++ b/testing/web-platform/meta/html/dom/dynamic-markup-insertion/opening-the-input-stream/009.html.ini
@@ -1,7 +1,8 @@
 [009.html]
+  prefs: [browser.cache.offline.insecure.enable:true]
   [document.open replacing singleton sessionStorage]
     expected: FAIL
 
   [document.open replacing singleton localStorage]
     expected: FAIL
 
--- a/testing/web-platform/meta/html/dom/interfaces.html.ini
+++ b/testing/web-platform/meta/html/dom/interfaces.html.ini
@@ -1,10 +1,10 @@
 [interfaces.html]
-  prefs: [dom.forms.inputmode:true, dom.dialog_element.enabled:true, dom.forms.autocomplete.formautofill:true, dom.webcomponents.shadowdom.enabled:true, dom.moduleScripts.enabled:true]
+  prefs: [dom.forms.inputmode:true, dom.dialog_element.enabled:true, dom.forms.autocomplete.formautofill:true, dom.webcomponents.shadowdom.enabled:true, dom.moduleScripts.enabled:true, browser.cache.offline.insecure.enable:true]
   [Document interface: attribute domain]
     expected: FAIL
 
   [Document interface: attribute cookie]
     expected: FAIL
 
   [Document interface: attribute head]
     expected: FAIL
--- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
@@ -48,16 +48,17 @@
 #include "nsContentUtils.h"
 #include "mozilla/Unused.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 static nsOfflineCacheUpdateService *gOfflineCacheUpdateService = nullptr;
 static bool sAllowOfflineCache = true;
+static bool sAllowInsecureOfflineCache = true;
 
 nsTHashtable<nsCStringHashKey>* nsOfflineCacheUpdateService::mAllowedDomains = nullptr;
 
 nsTHashtable<nsCStringHashKey>* nsOfflineCacheUpdateService::AllowedDomains()
 {
     if (!mAllowedDomains)
         mAllowedDomains = new nsTHashtable<nsCStringHashKey>();
 
@@ -247,16 +248,19 @@ nsOfflineCacheUpdateService::nsOfflineCa
     : mDisabled(false)
     , mUpdateRunning(false)
     , mLowFreeSpace(false)
 {
     MOZ_ASSERT(NS_IsMainThread());
     Preferences::AddBoolVarCache(&sAllowOfflineCache,
                                  "browser.cache.offline.enable",
                                  true);
+    Preferences::AddBoolVarCache(&sAllowInsecureOfflineCache,
+                                 "browser.cache.offline.insecure.enable",
+                                 true);
 }
 
 nsOfflineCacheUpdateService::~nsOfflineCacheUpdateService()
 {
     MOZ_ASSERT(gOfflineCacheUpdateService == this);
     gOfflineCacheUpdateService = nullptr;
 
     delete mAllowedDomains;
@@ -628,16 +632,20 @@ OfflineAppPermForPrincipal(nsIPrincipal 
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (!match) {
         rv = innerURI->SchemeIs("https", &match);
         NS_ENSURE_SUCCESS(rv, rv);
         if (!match) {
             return NS_OK;
         }
+    } else {
+        if (!sAllowInsecureOfflineCache) {
+            return NS_OK;
+        }
     }
 
     nsAutoCString domain;
     rv = innerURI->GetAsciiHost(domain);
     NS_ENSURE_SUCCESS(rv, rv);
 
     if (nsOfflineCacheUpdateService::AllowedDomains()->Contains(domain)) {
         *aAllowed = true;
@@ -699,16 +707,39 @@ NS_IMETHODIMP
 nsOfflineCacheUpdateService::AllowOfflineApp(nsIPrincipal *aPrincipal)
 {
     nsresult rv;
 
     if (!sAllowOfflineCache) {
         return NS_ERROR_NOT_AVAILABLE;
     }
 
+    if (!sAllowInsecureOfflineCache) {
+        nsCOMPtr<nsIURI> uri;
+        aPrincipal->GetURI(getter_AddRefs(uri));
+
+        if (!uri) {
+            return NS_ERROR_NOT_AVAILABLE;
+        }
+
+        nsCOMPtr<nsIURI> innerURI = NS_GetInnermostURI(uri);
+        if (!innerURI) {
+            return NS_ERROR_NOT_AVAILABLE;
+        }
+
+        // if http then we should prevent this cache
+        bool match;
+        rv = innerURI->SchemeIs("http", &match);
+        NS_ENSURE_SUCCESS(rv, rv);
+
+        if (match) {
+            return NS_ERROR_NOT_AVAILABLE;
+        }
+    }
+
     if (GeckoProcessType_Default != XRE_GetProcessType()) {
         ContentChild* child = ContentChild::GetSingleton();
 
         if (!child->SendSetOfflinePermission(IPC::Principal(aPrincipal))) {
             return NS_ERROR_FAILURE;
         }
 
         nsAutoCString domain;