Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / serviceworker / resources / fetch-mixed-content-iframe-inscope.html
1 <script src="test-helpers.js?pipe=sub"></script>
2 <script>
3 var image_path = base_path() + 'fetch-access-control.php?PNGIMAGE';
4 var host_info = get_host_info();
5 var results = '';
6
7 function test1() {
8   var img = document.createElement('img');
9   document.body.appendChild(img);
10   img.onload = function() {
11     test2();
12   };
13   img.onerror = function() {
14     results += 'FAIL(1)';
15     test2();
16   };
17   img.src = host_info['HTTPS_ORIGIN'] + image_path;
18 }
19
20 function test2() {
21   var img = document.createElement('img');
22   document.body.appendChild(img);
23   img.onload = function() {
24     test3();
25   };
26   img.onerror = function() {
27     results += 'FAIL(2)';
28     test3();
29   };
30   img.src = host_info['HTTPS_REMOTE_ORIGIN'] + image_path;
31 }
32
33 function test3() {
34   var img = document.createElement('img');
35   document.body.appendChild(img);
36   img.onload = function() {
37     results += 'FAIL(3)';
38     test4();
39   };
40   img.onerror = function() {
41     test4();
42   };
43   img.src = host_info['HTTP_ORIGIN'] + image_path;
44 }
45
46 function test4() {
47   var img = document.createElement('img');
48   document.body.appendChild(img);
49   img.onload = function() {
50     results += 'FAIL(4)';
51     test5();
52   };
53   img.onerror = function() {
54     test5();
55   };
56   img.src = host_info['HTTP_REMOTE_ORIGIN'] + image_path;
57 }
58
59 function test5() {
60   var img = document.createElement('img');
61   document.body.appendChild(img);
62   img.onload = function() {
63     test6();
64   };
65   img.onerror = function() {
66     results += 'FAIL(5)';
67     test6();
68   };
69   img.src = './dummy?url=' +
70             encodeURIComponent(host_info['HTTPS_ORIGIN'] + image_path);
71 }
72
73 function test6() {
74   var img = document.createElement('img');
75   document.body.appendChild(img);
76   img.onload = function() {
77     test7();
78   };
79   img.onerror = function() {
80     results += 'FAIL(6)';
81     test7();
82   };
83   img.src = './dummy?mode=no-cors&url=' +
84             encodeURIComponent(host_info['HTTPS_REMOTE_ORIGIN'] + image_path);
85 }
86
87 function test7() {
88   var img = document.createElement('img');
89   document.body.appendChild(img);
90   img.onload = function() {
91     results += 'FAIL(7)';
92     test8();
93   };
94   img.onerror = function() {
95     test8();
96   };
97   img.src = './dummy?mode=no-cors&url=' +
98             encodeURIComponent(host_info['HTTP_ORIGIN'] + image_path);
99 }
100
101 function test8() {
102   var img = document.createElement('img');
103   document.body.appendChild(img);
104   img.onload = function() {
105     results += 'FAIL(8)';
106     finish();
107   };
108   img.onerror = function() {
109     finish();
110   };
111   img.src = './dummy?mode=no-cors&url=' +
112             encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + image_path);
113 }
114
115 function finish() {
116   results += 'finish';
117   window.parent.postMessage({results: results}, host_info['HTTPS_ORIGIN']);
118 }
119 </script>
120
121 <body onload='test1();'>
122 </body>