1 <html manifest=
"resources/xhr-foreign-resource.manifest">
3 <p>Test that a resource marked as foreign can still be loaded via XHR.
</p>
4 <p>Should say SUCCESS:
</p>
8 if (window
.testRunner
) {
9 testRunner
.dumpAsText();
10 testRunner
.waitUntilDone();
15 document
.getElementById("result").innerHTML
+= message
+ "<br>";
18 function createFrame1()
20 applicationCache
.onnoupdate = function() { log("FAIL: Unexpected noupdate event") }
21 applicationCache
.oncached = function() { log("FAIL: Unexpected cached event") }
23 var ifr
= document
.createElement("iframe");
24 ifr
.setAttribute("src", "resources/xhr-foreign-resource-frame.html");
25 document
.body
.appendChild(ifr
);
28 function createFrame2()
30 // A copy that doesn't have its main resource in cache manifest.
31 var ifr
= document
.createElement("iframe");
32 ifr
.setAttribute("src", "resources/xhr-foreign-resource-frame.html?");
33 document
.body
.appendChild(ifr
);
36 applicationCache
.onnoupdate = function() { createFrame1() }
37 applicationCache
.oncached = function() { createFrame1() }
39 applicationCache
.onupdateready = function() { log("FAIL: received unexpected updateready event") }
40 applicationCache
.onerror = function() { log("FAIL: received unexpected error event") }
42 var hadErrorFromSubframe
= false;
43 var subframeMessagesReceived
= 0;
44 function frameMessageReceived(evt
)
46 ++subframeMessagesReceived
;
47 if (evt
.data
!= "SUCCESS")
48 hadErrorFromSubframe
= true;
49 if (subframeMessagesReceived
== 1)
50 setTimeout(createFrame2
, 0);
51 else if (subframeMessagesReceived
== 2)
57 if (!hadErrorFromSubframe
) {
58 // The subframe has a different cache, but it is also listed as a resource in main frame's
59 // manifest, so it should be loaded successfully despite being marked as foreign now.
61 var req
= new XMLHttpRequest
;
62 req
.open("GET", "resources/xhr-foreign-resource-frame.html", false);
69 log("FAIL: subframe didn't get a correct cache");
71 if (window
.testRunner
)
72 testRunner
.notifyDone();
75 window
.addEventListener("message", frameMessageReceived
, false);