dom/tests/mochitest/ajax/offline/test_bug765203.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/unknownSection.cacheManifest">
     2 <head>
     3 <title>unknown section</title>
     5 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     6 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
     7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     9 <script type="text/javascript">
    11 var gGotChecking = false;
    12 var gGotDownloading = false;
    14 function manifestUpdated()
    15 {
    16   OfflineTest.ok(gGotChecking, "Should get a checking event");
    17   OfflineTest.ok(gGotDownloading, "Should get a downloading event");
    19   OfflineTest.is(applicationCache.status, 1, "Cache status should be 1 (CACHED)");
    21   var entries = [
    22     // The manifest itself should be in the cache
    23     ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/unknownSection.cacheManifest", true],
    25     // The document that requested the manifest should be in the cache
    26     [window.location.href, true],
    28     // The entries from the manifest should be in the cache
    29     ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true],
    30     ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
    32     // The bad entries from the manifest should not be in the cache
    33     ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/jupiter.jpg", false]
    34   ];
    35   OfflineTest.checkCacheEntries(
    36     entries,
    37     function() {
    38        OfflineTest.teardownAndFinish();
    39     });
    40 }
    42 if (OfflineTest.setup()) {
    43   OfflineTest.ok(applicationCache instanceof EventTarget,
    44                  "applicationCache should be an event target");
    46   applicationCache.onerror = OfflineTest.failEvent;
    48   applicationCache.addEventListener("checking", function() {
    49     // We should get the "checking" event during an initial update,
    50     // but until we are associated it will not affect applicationCache.status
    51     OfflineTest.is(applicationCache.status, applicationCache.UNCACHED,
    52                    "CHECKING state during initial update");
    53     gGotChecking = true;
    54     }, true);
    55   applicationCache.ondownloading = function() {
    56     // We should get the "downloading" event during an initial update,
    57     // but until we are associated it will not affect applicationCache.status
    58     OfflineTest.is(applicationCache.status, applicationCache.UNCACHED,
    59                    "DOWNLOADING state during initial update")
    60     gGotDownloading = true; };
    61   applicationCache.oncached = OfflineTest.priv(manifestUpdated);
    62 }
    64 SimpleTest.waitForExplicitFinish();
    66 </script>
    68 </head>
    70 <body>
    72 </body>
    73 </html>

mercurial