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

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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>identical manifest test</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 finishTest()
    15 {
    16   OfflineTest.teardownAndFinish();
    17 }
    19 function noUpdate()
    20 {
    21   OfflineTest.ok(gGotChecking, "Should get a checking event");
    22   OfflineTest.ok(!gGotDownloading, "Should not get a downloading event");
    24   var entries = [
    25     // The document that requested the manifest should be in the cache
    26     [window.location.href, true],
    28     ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true],
    29     ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true]
    30   ];
    31   OfflineTest.checkCacheEntries(entries, finishTest);
    32 }
    34 function manifestUpdated()
    35 {
    36   OfflineTest.ok(gGotChecking, "Should get a checking event");
    37   OfflineTest.ok(gGotDownloading, "Should get a downloading event");
    39   var entries = [
    40     // The manifest itself should be in the cache
    41     ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/simpleManifest.cacheManifest", true],
    43     // The document that requested the manifest should be in the cache
    44     [window.location.href, true],
    46     // The entries from the manifest should be in the cache
    47     ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true],
    48     ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
    50     // The bad entries from the manifest should not be in the cache
    51     ["bad:/uri/invalid", false]
    52   ];
    53   OfflineTest.checkCacheEntries(entries, manifestUpdatedContinue);
    54 }
    56 function manifestUpdatedContinue()
    57 {
    58   // Now make sure applicationCache.update() does what we expect.
    59   applicationCache.oncached = OfflineTest.failEvent;
    60   applicationCache.onnoupdate = OfflineTest.priv(noUpdate);
    62   gGotChecking = false;
    63   gGotDownloading = false;
    64   applicationCache.update();
    65 }
    67 if (OfflineTest.setup()) {
    68   applicationCache.onerror = OfflineTest.failEvent;
    69   applicationCache.onnoupdate = OfflineTest.failEvent;
    70   applicationCache.onudpateready = OfflineTest.failEvent;
    72   applicationCache.onchecking = function() { gGotChecking = true; };
    73   applicationCache.ondownloading = function() { gGotDownloading = true; };
    74   applicationCache.oncached = OfflineTest.priv(manifestUpdated);
    75 }
    77 SimpleTest.waitForExplicitFinish();
    79 </script>
    81 </head>
    83 <body>
    85 </body>
    86 </html>

mercurial