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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/ajax/offline/test_bug765203.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +<html xmlns="http://www.w3.org/1999/xhtml" manifest="http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/unknownSection.cacheManifest">
     1.5 +<head>
     1.6 +<title>unknown section</title>
     1.7 +
     1.8 +<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     1.9 +<script type="text/javascript" src="/tests/dom/tests/mochitest/ajax/offline/offlineTests.js"></script>
    1.10 +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.11 +
    1.12 +<script type="text/javascript">
    1.13 +
    1.14 +var gGotChecking = false;
    1.15 +var gGotDownloading = false;
    1.16 +
    1.17 +function manifestUpdated()
    1.18 +{
    1.19 +  OfflineTest.ok(gGotChecking, "Should get a checking event");
    1.20 +  OfflineTest.ok(gGotDownloading, "Should get a downloading event");
    1.21 +
    1.22 +  OfflineTest.is(applicationCache.status, 1, "Cache status should be 1 (CACHED)");
    1.23 +
    1.24 +  var entries = [
    1.25 +    // The manifest itself should be in the cache
    1.26 +    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/unknownSection.cacheManifest", true],
    1.27 +
    1.28 +    // The document that requested the manifest should be in the cache
    1.29 +    [window.location.href, true],
    1.30 +
    1.31 +    // The entries from the manifest should be in the cache
    1.32 +    ["http://mochi.test:8888/tests/SimpleTest/SimpleTest.js", true],
    1.33 +    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/offlineTests.js", true],
    1.34 +
    1.35 +    // The bad entries from the manifest should not be in the cache
    1.36 +    ["http://mochi.test:8888/tests/dom/tests/mochitest/ajax/offline/jupiter.jpg", false]
    1.37 +  ];
    1.38 +  OfflineTest.checkCacheEntries(
    1.39 +    entries,
    1.40 +    function() {
    1.41 +       OfflineTest.teardownAndFinish();
    1.42 +    });
    1.43 +}
    1.44 +
    1.45 +if (OfflineTest.setup()) {
    1.46 +  OfflineTest.ok(applicationCache instanceof EventTarget,
    1.47 +                 "applicationCache should be an event target");
    1.48 +
    1.49 +  applicationCache.onerror = OfflineTest.failEvent;
    1.50 +
    1.51 +  applicationCache.addEventListener("checking", function() {
    1.52 +    // We should get the "checking" event during an initial update,
    1.53 +    // but until we are associated it will not affect applicationCache.status
    1.54 +    OfflineTest.is(applicationCache.status, applicationCache.UNCACHED,
    1.55 +                   "CHECKING state during initial update");
    1.56 +    gGotChecking = true;
    1.57 +    }, true);
    1.58 +  applicationCache.ondownloading = function() {
    1.59 +    // We should get the "downloading" event during an initial update,
    1.60 +    // but until we are associated it will not affect applicationCache.status
    1.61 +    OfflineTest.is(applicationCache.status, applicationCache.UNCACHED,
    1.62 +                   "DOWNLOADING state during initial update")
    1.63 +    gGotDownloading = true; };
    1.64 +  applicationCache.oncached = OfflineTest.priv(manifestUpdated);
    1.65 +}
    1.66 +
    1.67 +SimpleTest.waitForExplicitFinish();
    1.68 +
    1.69 +</script>
    1.70 +
    1.71 +</head>
    1.72 +
    1.73 +<body>
    1.74 +
    1.75 +</body>
    1.76 +</html>

mercurial