OLD | NEW |
1 <script src="../../resources/get-host-info.js?pipe=sub"></script> | 1 <script src="../resources/get-host-info.sub.js"></script> |
2 <script src="test-helpers.js"></script> | 2 <script src="test-helpers.sub.js?pipe=sub"></script> |
3 <script> | 3 <script> |
4 var image_path = base_path() + 'fetch-access-control.php?PNGIMAGE'; | 4 var image_path = base_path() + 'fetch-access-control.py?PNGIMAGE'; |
5 var host_info = get_host_info(); | 5 var host_info = get_host_info(); |
6 var results = ''; | 6 var results = ''; |
| 7 var port = undefined; |
7 | 8 |
8 function test1() { | 9 function test1() { |
9 var img = document.createElement('img'); | 10 var img = document.createElement('img'); |
10 document.body.appendChild(img); | 11 document.body.appendChild(img); |
11 img.onload = function() { | 12 img.onload = function() { |
12 test2(); | 13 test2(); |
13 }; | 14 }; |
14 img.onerror = function() { | 15 img.onerror = function() { |
15 results += 'FAIL(1)'; | 16 results += 'FAIL(1)'; |
16 test2(); | 17 test2(); |
17 }; | 18 }; |
18 img.src = host_info['HTTPS_ORIGIN'] + image_path; | 19 img.src = host_info['HTTPS_ORIGIN'] + image_path; |
19 } | 20 } |
20 | 21 |
21 function test2() { | 22 function test2() { |
22 var img = document.createElement('img'); | 23 var img = document.createElement('img'); |
23 document.body.appendChild(img); | 24 document.body.appendChild(img); |
24 img.onload = function() { | 25 img.onload = function() { |
| 26 results += 'FAIL(2)'; |
25 test3(); | 27 test3(); |
26 }; | 28 }; |
27 img.onerror = function() { | 29 img.onerror = function() { |
28 results += 'FAIL(2)'; | |
29 test3(); | 30 test3(); |
30 }; | 31 }; |
31 img.src = host_info['HTTPS_REMOTE_ORIGIN'] + image_path; | 32 img.src = host_info['HTTPS_REMOTE_ORIGIN'] + image_path; |
32 } | 33 } |
33 | 34 |
34 function test3() { | 35 function test3() { |
35 var img = document.createElement('img'); | 36 var img = document.createElement('img'); |
36 document.body.appendChild(img); | 37 document.body.appendChild(img); |
37 img.onload = function() { | 38 img.onload = function() { |
| 39 test4(); |
| 40 }; |
| 41 img.onerror = function() { |
38 results += 'FAIL(3)'; | 42 results += 'FAIL(3)'; |
39 test4(); | 43 test4(); |
40 }; | 44 }; |
41 img.onerror = function() { | 45 img.src = './dummy?url=' + |
42 test4(); | 46 encodeURIComponent(host_info['HTTPS_ORIGIN'] + image_path); |
43 }; | |
44 img.src = host_info['UNAUTHENTICATED_ORIGIN'] + image_path; | |
45 } | 47 } |
46 | 48 |
47 function test4() { | 49 function test4() { |
48 var img = document.createElement('img'); | 50 var img = document.createElement('img'); |
49 document.body.appendChild(img); | 51 document.body.appendChild(img); |
50 img.onload = function() { | 52 img.onload = function() { |
| 53 results += 'FAIL(4)'; |
51 finish(); | 54 finish(); |
52 }; | 55 }; |
53 img.onerror = function() { | 56 img.onerror = function() { |
54 results += 'FAIL(4)'; | |
55 finish(); | 57 finish(); |
56 }; | 58 }; |
57 img.src = './dummy?generate-png'; | 59 img.src = './dummy?mode=no-cors&url=' + |
| 60 encodeURIComponent(host_info['HTTPS_REMOTE_ORIGIN'] + image_path); |
58 } | 61 } |
59 | 62 |
60 function finish() { | 63 function finish() { |
61 results += 'finish'; | 64 results += 'finish'; |
62 window.parent.postMessage({results: results}, host_info['HTTPS_ORIGIN']); | 65 port.postMessage({results: results}); |
63 } | 66 } |
| 67 |
| 68 window.addEventListener('message', function(evt) { |
| 69 port = evt.ports[0]; |
| 70 test1(); |
| 71 }, false); |
64 </script> | 72 </script> |
65 | |
66 <body onload='test1();'> | |
67 </body> | |
OLD | NEW |