Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / appcache / multi-fallback.html
blob44dfff0b0ac7a07d9aeaa8b7ab7f54eb8a5cc379
1 <html manifest="resources/multi-fallback.manifest">
2 <body>
3 <p>Test application cache fallback entries with multiple candidates.</p>
4 <p>Should say SUCCESS:</p>
5 <div id=result></div>
7 <script>
8 if (window.testRunner) {
9 testRunner.dumpAsText();
10 testRunner.waitUntilDone();
13 var hadError = false;
15 function log(message)
17 document.getElementById("result").innerHTML += message + "<br>";
20 function setNetworkEnabled(state)
22 try {
23 var req = new XMLHttpRequest;
24 req.open("GET", "/resources/network-simulator.php?command=" + (state ? "connect" : "disconnect"), false);
25 req.send("");
26 } catch (ex) {
27 log("Cannot access network simulator URL, ex = " + ex);
28 hadError = true;
32 function load(url)
34 try {
35 var req = new XMLHttpRequest();
36 req.open("GET", url, false);
37 req.send("");
38 return req.responseText;
39 } catch (ex) {
40 log("FAIL: Cannot load " + url + ", ex = " + ex);
41 hadError = true;
42 return ""; // This value should not be expected as the responseText for a url presented to this function.
46 var nonexistentURL = "resources/does-not-exist";
48 function test()
50 applicationCache.onnoupdate = function() { log("FAIL: received unexpected noupdate event") }
51 applicationCache.oncached = function() { log("FAIL: received unexpected cached event") }
53 setNetworkEnabled(true);
55 if (load(nonexistentURL) != "Hello, World!") {
56 log("FAIL: The longest fallback namespace wasn't used for a 404 response");
57 hadError = true;
60 log(hadError ? "FAILURE" : "SUCCESS");
61 if (window.testRunner)
62 testRunner.notifyDone();
65 applicationCache.onnoupdate = function() { test() }
66 applicationCache.oncached = function() { test() }
68 applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
69 applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
71 </script>
72 </body>
73 </html>