dom/tests/mochitest/ajax/offline/test_fallback.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/fallback.cacheManifest">
     2 <head>
     3 <title>Fallback entry 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 class="testbody" type="text/javascript">
    11 /**
    12  * This tests that we fall back to the correct fallback entries when loading
    13  * from fallback namespaces listed in the manifest.  The test is performed twice
    14  * to make sure that no cache entries are created for the nonexistent items."
    15  * That would lead to a failure to fallback, as there would always be an entry
    16  * in the application cache.
    17  */
    19 var gStep = 1;
    20 var gChildLoad = false;
    21 var gTopWindow = null;
    23 function manifestUpdated()
    24 {
    25   fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html";
    26   // Invokes load of fallback.html
    27 }
    29 function onFallbackLoad(fallbackIdentification)
    30 {
    31   switch (gStep)
    32   {
    33     case 001:
    34       OfflineTest.ok(!gChildLoad, "offline child not load before cache update");
    35       gChildLoad = true;
    36       // no break
    37     case 101:
    38       OfflineTest.is(fallbackIdentification, 1, "fallback for namespace1/ in step " + gStep);
    40       fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub-non-existing.html";
    41       // Invokes load of fallback.html
    42       break;
    44     case 002:
    45     case 102:
    46       OfflineTest.is(fallbackIdentification, 1, "fallback for namespace1/, sub namespace in name of the frame in step " + gStep);
    48       fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html";
    49       // Invokes load of fallback2.html
    50       break;
    52     case 003:
    53     case 103:
    54       OfflineTest.is(fallbackIdentification, 2, "fallback for namespace1/sub/ in step " + gStep);
    56       fallbackFrame.location = "HTTP://MOCHI.TEST:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html";
    57       // Invokes load of fallback2.html
    58       break;
    60     case 004:
    61     case 104:
    62       OfflineTest.is(fallbackIdentification, 2, "fallback for namespace1/sub/ in step " + gStep);
    64       // Try opening a non-existing page as a top level document. It must
    65       // fall to fallbackTop.html that identifies it self as '100'.
    66       // Invokes load of fallbackTop.html
    67       gTopWindow = window.open("http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace2/non-existing.html");
    69       break;
    71     case 005:
    72       // Try all over again. This checks there are no entries for non-existing
    73       // pages created/leaked. That would prevent fallback load.
    74       gStep = 100;
    76       fallbackFrame.location = "http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html";
    77       // Invokes load of fallback1.html, again, from the start
    78       // no break
    79     case 105:
    80       OfflineTest.is(fallbackIdentification, 100, "fallback for namespace2/, invoked by a top level document " + gStep);
    82       gTopWindow.close();
    83       gTopWindow = null;
    85       break;
    86   }
    88   if (gStep == 105) {
    89     finalize();
    90     return;
    91   }
    93   ++gStep;
    94 }
    97 function finishTest()
    98 {
    99   OfflineTest.teardownAndFinish();
   100 }
   102 function finalize()
   103 {
   104   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
   106   var entries = [
   107     ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub-non-existing.html", false],
   108     ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/sub/non-existing.html", false],
   109     ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace1/non-existing.html", false],
   110     ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/namespace2/non-existing.html", false]
   111   ];
   112   OfflineTest.checkCacheEntries(entries, finishTest);
   113 }
   115 SimpleTest.waitForExplicitFinish();
   117 if (OfflineTest.setup()) {
   118   applicationCache.onerror = OfflineTest.failEvent;
   119   applicationCache.onupdateready = OfflineTest.failEvent;
   120   applicationCache.oncached = OfflineTest.priv(manifestUpdated);
   121 }
   123 </script>
   125 </head>
   127 <body>
   128 <iframe name="fallbackFrame" src=""></iframe>
   129 </body>
   130 </html>

mercurial