dom/tests/mochitest/ajax/offline/test_bug460353.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/simpleManifest.cacheManifest">
     2 <head>
     3 <title>Bug 460353</title>
     5 <!--
     6   This test checks that each iframe creates its own
     7   scope. Actually, we just check that it loads and updates
     8   its associated cache. There is no check that the cache is the
     9   expected one, there is no API to gain that information.
    10 -->
    12 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    13 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    14 <script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
    16 <script class="testbody" type="text/javascript">
    18 var result = new Array();
    19 var expectedUpdates = 3; // 2 iframes and our self
    21 applicationCache.oncached = onUpdatePassed;
    22 applicationCache.onnoupdate = onUpdatePassed;
    24 SpecialPowers.pushPermissions([{'type': 'offline-app', 'allow': true, 'context': document}], init);
    26 function onUpdatePassed()
    27 {
    28   if (!(--expectedUpdates))
    29     SimpleTest.executeSoon(finish);
    30 }
    32 function init()
    33 {
    34   var iframes = document.getElementsByTagName('iframe');
    35   iframes[0].src = "460353_iframe_nomanifest.html";
    36   iframes[1].src = "460353_iframe_ownmanifest.html";
    37   iframes[2].src = "460353_iframe_samemanifest.html";
    38 }
    40 function frameOnLoad(frameid, status)
    41 {
    42   var obj = new Object();
    43   result[frameid] = obj;
    45   result[frameid].load = true;
    46   result[frameid].cacheStatus = status;
    47 }
    49 function frameOnUpdate(frameid, ok, status)
    50 {
    51   result[frameid].update = true;
    52   result[frameid].updateOK = ok;
    53   result[frameid].cacheStatus = status;
    55   onUpdatePassed();
    56 }
    58 function finish()
    59 {
    60   SimpleTest.ok(result["same"].load || false, "Frame with the same manifest loads");
    61   SimpleTest.ok(result["same"].update || false, "Frame with the same manifest cache update notification");
    62   SimpleTest.ok(result["same"].updateOK || false, "Frame with the same manifest cache update passed OK");
    63   SimpleTest.is(result["same"].cacheStatus || -1, 1, "Frame with the same manifest cache status was IDLE");
    65   SimpleTest.ok(result["diff"].load || false, "Frame with different manifest loads");
    66   SimpleTest.ok(result["diff"].update || false, "Frame with different manifest cache update notification");
    67   SimpleTest.ok(result["diff"].updateOK || false, "Frame with different manifest cache update passed OK");
    68   SimpleTest.is(result["diff"].cacheStatus || -1, 1, "Frame with different manifest cache status was IDLE");
    70   SimpleTest.ok(result["noman"].load || false, "Frame with no manifest loads");
    71   SimpleTest.ok(result["noman"].update == undefined, "Frame with no manifest cache update didn't notify");
    72   SimpleTest.ok(result["noman"].updateOK == undefined, "Frame with no manifest cache update didn't pass");
    73   SimpleTest.is(result["noman"].cacheStatus || -1, -1, "Frame with no manifest cache status was undefined");
    75   OfflineTest.waitForUpdates(function() {
    76     cleanCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest");
    77     cleanCache("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/updatingManifest.sjs");
    79     SimpleTest.finish();
    80   });
    81 }
    83 function cleanCache(manifestURL)
    84 {
    85   var cache = OfflineTest.getActiveCache(manifestURL);
    86   dump("Discarding cache for " + manifestURL + " cache=" + cache + "\n");
    87   if (cache)
    88     cache.discard();
    89 }
    91 SimpleTest.waitForExplicitFinish();
    93 </script>
    95 <body>
    96   <iframe></iframe>
    97   <iframe></iframe>
    98   <iframe></iframe>
    99 </body>
   100 </html>

mercurial