dom/tests/mochitest/ajax/offline/test_lowDeviceStorageDuringUpdate.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>Low device storage during update</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 /**
    12  * This test checks that an offline cache update is canceled when a low device
    13  * storage condition is detected during the update.
    14  */
    16 var updateService = Cc['@mozilla.org/offlinecacheupdate-service;1']
    17                     .getService(Ci.nsIOfflineCacheUpdateService);
    19 var obs = SpecialPowers.Cc["@mozilla.org/observer-service;1"]
    20                        .getService(SpecialPowers.Ci.nsIObserverService);
    22 function finish() {
    23   obs.notifyObservers(updateService, "disk-space-watcher", "free");
    25   OfflineTest.teardownAndFinish();
    26 }
    28 function onError() {
    29   OfflineTest.ok(true, "Expected error: Update canceled");
    30   finish();
    31 }
    33 function onUnexpectedEvent() {
    34   OfflineTest.ok(false, "The update was supposed to be canceled");
    35   finish();
    36 }
    38 function onChecking() {
    39   obs.notifyObservers(updateService, "disk-space-watcher", "full");
    40 }
    42 if (OfflineTest.setup()) {
    43   applicationCache.onerror = OfflineTest.priv(onError);
    44   applicationCache.onprogress = OfflineTest.priv(onUnexpectedEvent);
    45   applicationCache.oncached = OfflineTest.priv(onUnexpectedEvent);
    46   applicationCache.onchecking = OfflineTest.priv(onChecking);
    47 }
    49 SimpleTest.waitForExplicitFinish();
    51 </script>
    53 </head>
    55 <body>
    57 </body>
    58 </html>

mercurial