Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / loading / preload-img-test.html
blob96c9ee361c6d65bf985b7ed6177fa981f21823b4
1 <script src="/js-test-resources/js-test.js"></script>
2 <iframe id='iframe'></iframe>
3 <script>
4 description("This test is to test whether preload image will require 2 more requests or not.");
6 window.jsTestIsAsync = true;
8 function CallCommand(cmd)
10 try {
11 var req = new XMLHttpRequest;
12 req.open("GET", "/resources/network-simulator.php?command=" + cmd, false);
13 req.send(null);
14 return req.responseText;
15 } catch (ex) {
16 return "";
20 var count;
21 function checkAccessCount()
23 // Get the access count of resource:/loading/resources/preload-test.jpg. Should be 1.
24 count = CallCommand("get-resource-count&path=/loading/resources/preload-test.jpg");
25 shouldBeEqualToString('count', '1');
26 finishJSTest();
29 // Reset resource count
30 CallCommand("reset-resource-count");
32 window.addEventListener("message", function(event) {
33 if (event.data == 'imgerror') {
34 testFailed("test img load failed");
35 finishJSTest();
36 } else if (event.data == 'imgload') {
37 setTimeout(checkAccessCount, 1000);
38 } else {
39 debug(event.data);
41 });
43 var iframe = document.getElementById("iframe");
44 iframe.src = 'resources/preload-img-test-iframe.html';
45 </script>