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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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