| OLD | NEW |
| 1 <html manifest="does-not-exist.manifest"> | 1 <html manifest="does-not-exist.manifest"> |
| 2 <script src="/js-test-resources/js-test.js"></script> |
| 2 <script> | 3 <script> |
| 3 if (window.testRunner) { | 4 var jsTestIsAsync = true; |
| 4 testRunner.dumpAsText() | 5 description("Test that subresources can be loaded if manifest is not available."
); |
| 5 testRunner.waitUntilDone(); | |
| 6 } | |
| 7 | |
| 8 function log(message) | |
| 9 { | |
| 10 document.getElementById("result").innerHTML += message + "<br>"; | |
| 11 } | |
| 12 | 6 |
| 13 function unexpectedEvent(name) | 7 function unexpectedEvent(name) |
| 14 { | 8 { |
| 15 log("FAILURE: Unexpected " + name + " event."); | 9 testFailed("Unexpected " + name + " event."); |
| 10 finishJSTest(); |
| 16 } | 11 } |
| 17 | 12 |
| 18 applicationCache.addEventListener('noupdate', function() { unexpectedEvent("noup
date") }, false); | 13 applicationCache.addEventListener('noupdate', function() { unexpectedEvent("noup
date") }, false); |
| 19 applicationCache.addEventListener('downloading', function() { unexpectedEvent("d
ownloading") }, false); | 14 applicationCache.addEventListener('downloading', function() { unexpectedEvent("d
ownloading") }, false); |
| 20 applicationCache.addEventListener('progress', function() { unexpectedEvent("prog
ress") }, false); | 15 applicationCache.addEventListener('progress', function() { unexpectedEvent("prog
ress") }, false); |
| 21 applicationCache.addEventListener('updateready', function() { unexpectedEvent("u
pdateready") }, false); | 16 applicationCache.addEventListener('updateready', function() { unexpectedEvent("u
pdateready") }, false); |
| 22 applicationCache.addEventListener('cached', function() { unexpectedEvent("cached
") }, false); | 17 applicationCache.addEventListener('cached', function() { unexpectedEvent("cached
") }, false); |
| 23 applicationCache.addEventListener('obsolete', function() { unexpectedEvent("obso
lete") }, false); | 18 applicationCache.addEventListener('obsolete', function() { unexpectedEvent("obso
lete") }, false); |
| 24 | 19 |
| 25 function test() | 20 function test(e) |
| 26 { | 21 { |
| 27 if (!gotCheckingEvent) | 22 shouldBeTrue("gotCheckingEvent"); |
| 28 log("FAILURE: Did not get a checking event"); | 23 shouldBe("window.applicationCache.status", "applicationCache.UNCACHED"); |
| 29 if (window.applicationCache.status) | 24 |
| 30 log("FAILURE: Cache status is not UNCACHED, " + window.applicationCache.
status); | 25 event = e; |
| 26 shouldBeEqualToString("event.reason", "manifest"); |
| 27 shouldBeEqualToString("event.url", "http://127.0.0.1:8000/appcache/does-not-
exist.manifest"); |
| 28 shouldBe("event.status", "404"); |
| 29 shouldBeTrue("'message' in event"); |
| 31 | 30 |
| 32 // The manifest failed to load, so there should be no cache, and subresource
s should be loaded normally. | 31 // The manifest failed to load, so there should be no cache, and subresource
s should be loaded normally. |
| 33 try { | 32 try { |
| 34 var req = new XMLHttpRequest(); | 33 req = new XMLHttpRequest(); |
| 35 req.open("GET", "resources/simple.txt", false); | 34 req.open("GET", "resources/simple.txt", false); |
| 36 req.send(); | 35 req.send(); |
| 37 | 36 |
| 38 if (req.responseText == 'Hello, World!') | 37 shouldBeEqualToString("req.responseText", 'Hello, World!'); |
| 39 log("SUCCESS"); | |
| 40 else | |
| 41 log("FAILURE: Did not get expected response data."); | |
| 42 } catch (e) { | 38 } catch (e) { |
| 43 log("FAILURE: Could not load data."); | 39 testFailed("Could not load data."); |
| 44 } | 40 } |
| 45 | 41 |
| 46 if (window.testRunner) | 42 finishJSTest(); |
| 47 testRunner.notifyDone(); | |
| 48 } | 43 } |
| 49 | 44 |
| 50 var gotCheckingEvent = false; | 45 var gotCheckingEvent = false; |
| 51 applicationCache.addEventListener('checking', function() { gotCheckingEvent = tr
ue; }, false); | 46 applicationCache.addEventListener('checking', function() { gotCheckingEvent = tr
ue; }, false); |
| 52 | 47 applicationCache.addEventListener('error', test, false); |
| 53 applicationCache.addEventListener('error', function() { test() }, false); | |
| 54 | 48 |
| 55 </script> | 49 </script> |
| 56 <p>Test that subresources can be loaded if manifest is not available. Should say
SUCCESS.</p> | |
| 57 | |
| 58 <div id=result></div> | |
| 59 </html> | 50 </html> |
| OLD | NEW |