1 <html xmlns=
"http://www.w3.org/1999/xhtml"
2 manifest=
"/resources/network-simulator.php?path=/appcache/resources/non-html.manifest">
5 <p>Test that non-HTML main resources work with application cache correctly.
</p>
6 <p>Should say SUCCESS:
</p>
7 <div id=
"result"></div>
8 <script type=
"text/javascript">
9 if (window
.testRunner
) {
10 testRunner
.dumpAsText()
11 testRunner
.waitUntilDone();
16 document
.getElementById("result").innerHTML
+= message
+ "<br/>";
19 function setNetworkEnabled(state
)
21 var req
= new XMLHttpRequest
;
22 req
.open("GET", "/resources/network-simulator.php?command=" + (state
? "connect" : "disconnect"), false);
26 function createFrame()
28 var ifr
= document
.createElement("iframe");
29 ifr
.setAttribute("src", "/resources/network-simulator.php?path=/appcache/resources/abe.png");
30 ifr
.onload
= frameCreated
;
31 document
.body
.appendChild(ifr
);
38 applicationCache
.removeEventListener('noupdate', cached
, false);
39 applicationCache
.removeEventListener('cached', cached
, false);
41 setNetworkEnabled(false);
43 // Load a resource that does not exist in the cache.
45 var req
= new XMLHttpRequest();
46 req
.open("GET", "/resources/network-simulator.php?path=/appcache/resources/not-in-cache.txt", false);
49 if (e
.code
== DOMException
.NETWORK_ERR
)
54 document
.getElementById('result').innerHTML
= "FAILURE: Did not get the right exception"
58 // Load a resource that exists in the cache.
60 var req
= new XMLHttpRequest();
61 req
.open("GET", "/resources/network-simulator.php?path=/appcache/resources/simple.txt", false);
64 document
.getElementById('result').innerHTML
= "FAILURE: Could not load data from cache"
68 if (req
.responseText
!= 'Hello, World!') {
69 document
.getElementById('result').innerHTML
= "FAILURE: Did not get correct data from cached resource"
76 function frameCreated()
78 setNetworkEnabled(true);
80 if (frames
[0].document
.documentElement
.innerHTML
.match(/abe\.png/))
83 log("FAIL: Frame.onload was called, but the image doesn't seem to be loaded.");
85 if (window
.testRunner
) {
86 applicationCache
.onerror
= null;
87 testRunner
.notifyDone();
93 // The simulator was in a wrong state, reset it.
94 setNetworkEnabled(true);
95 window
.location
.reload();
98 applicationCache
.addEventListener('cached', cached
, false);
99 applicationCache
.addEventListener('noupdate', cached
, false);
101 applicationCache
.onerror
= error
;