Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / appcache / fallback.html
blob663ba9fae9f329926fbbfa239ec9e4d1bc6e4d6f
1 <html manifest="resources/fallback.manifest">
2 <body>
3 <p>Test application cache fallback entries.</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");
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 testURL = "/resources/network-simulator.php?path=/appcache/resources/not-in-cache.txt";
47 var nonexistentURL = "resources/does-not-exist";
48 var redirectURL = "resources/fallback-redirect.php";
50 function test()
52 applicationCache.onnoupdate = function() { log("FAIL: received unexpected noupdate event") }
53 applicationCache.oncached = function() { log("FAIL: received unexpected cached event") }
55 setNetworkEnabled(true);
57 if (!/not in the cache/.test(load(testURL))) {
58 log("FAIL: Cannot load an URL from fallback namespace when network is enabled");
59 hadError = true;
62 if (load(nonexistentURL) != "Hello, World!") {
63 log("FAIL: Fallback resource wasn't used for a 404 response");
64 hadError = true;
67 if (load(redirectURL) != "Hello, World!") {
68 log("FAIL: Fallback resource wasn't used for a redirect to a resource with another origin");
69 hadError = true;
72 test2();
75 function test2()
77 var req = new XMLHttpRequest;
78 req.open("GET", nonexistentURL);
79 req.onerror = function() {
80 log("FAIL: Fallback resource wasn't used for a 404 response (async)");
81 hadError = true;
82 test3();
84 req.onload = function() {
85 if (req.responseText != "Hello, World!") {
86 log("FAIL: Unexpected result for a 404 response (async)");
87 hadError = true;
89 test3();
92 req.send("");
95 function test3()
97 var req = new XMLHttpRequest;
98 req.open("GET", redirectURL);
99 req.onerror = function() {
100 log("FAIL: Fallback resource wasn't used for a redirect to a resource with another origin (async)");
101 hadError = true;
102 test4();
104 req.onload = function() {
105 if (req.responseText != "Hello, World!") {
106 log("FAIL: Unexpected result for a redirect response (async)");
107 hadError = true;
109 test4();
112 req.send("");
115 function test4()
117 // Try loading a fallback resource as main one.
119 applicationCache.onnoupdate = test5;
121 var ifr = document.createElement("iframe");
122 ifr.setAttribute("src", nonexistentURL);
123 ifr.setAttribute("onload", "test5()");
124 document.body.appendChild(ifr);
127 var test5_calls = 0;
129 function test5()
131 test5_calls++;
132 if (test5_calls == 1) {
133 return;
135 if (!/Hello, World/.test(window.frames[0].document.documentElement.innerHTML)) {
136 log("FAIL: Fallback URL was not honored for main resource");
137 hadError = true;
139 test6();
142 function test6()
144 setNetworkEnabled(false);
146 if (load(testURL) != load("resources/simple.txt")) {
147 log("FAIL: Loading an URL from fallback namespace when network is disabled returned unexpected response");
148 hadError = true;
151 log(hadError ? "FAILURE" : "SUCCESS");
152 if (window.testRunner)
153 testRunner.notifyDone();
156 applicationCache.onnoupdate = function() { test() }
157 applicationCache.oncached = function() { test() }
159 applicationCache.onupdateready = function() { log("FAIL: received unexpected updateready event") }
160 applicationCache.onerror = function() { log("FAIL: received unexpected error event") }
162 </script>
163 </body>
164 </html>