OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 <title>Service Worker: Fetch for the frame loading.</title> | |
3 <script src="../resources/testharness.js"></script> | |
4 <script src="../resources/testharnessreport.js"></script> | |
5 <script src="resources/test-helpers.js"></script> | |
6 <body> | |
7 <script> | |
8 var worker = 'resources/fetch-rewrite-worker.js'; | |
9 var path = base_path() + 'resources/fetch-access-control.php'; | |
10 var host_info = get_host_info(); | |
11 | |
12 if (window.testRunner) { | |
13 testRunner.setCanOpenWindows(); | |
14 } | |
15 | |
16 async_test(function(t) { | |
falken
2014/10/03 03:43:47
It's burdensome, but can you put each test in its
horo
2014/10/03 04:14:26
I think we don't need to split.
Because async_test
falken
2014/10/03 06:06:39
Acknowledged.
| |
17 var scope = 'resources/fetch-frame-resource/frame-basic'; | |
18 service_worker_unregister_and_register(t, worker, scope) | |
19 .then(function(reg) { return wait_for_activated(t, reg); }) | |
20 .then(function() { | |
21 return with_iframe( | |
22 scope + '?url=' + | |
23 encodeURIComponent(host_info['HTTP_ORIGIN'] + path)); | |
24 }) | |
25 .then(function(frame) { | |
26 assert_not_equals( | |
27 frame.contentDocument.body.textContent, | |
28 '', | |
29 'Basic type response could be loaded in the iframe.'); | |
30 unload_iframe(frame); | |
31 return service_worker_unregister_and_done(t, scope); | |
32 }) | |
33 .catch(unreached_rejection(t)); | |
34 }, 'Basic type response could be loaded in the iframe.'); | |
35 | |
36 async_test(function(t) { | |
37 var scope = 'resources/fetch-frame-resource/frame-cors'; | |
38 service_worker_unregister_and_register(t, worker, scope) | |
39 .then(function(reg) { return wait_for_activated(t, reg); }) | |
40 .then(function() { | |
41 return with_iframe( | |
42 scope + '?mode=cors&url=' + | |
43 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path + | |
44 '?ACAOrigin=' + host_info['HTTP_ORIGIN'])); | |
45 }) | |
46 .then(function(frame) { | |
47 assert_not_equals( | |
48 frame.contentDocument.body.textContent, | |
49 '', | |
50 'CORS type response could be loaded in the iframe.'); | |
51 unload_iframe(frame); | |
52 return service_worker_unregister_and_done(t, scope); | |
53 }) | |
54 .catch(unreached_rejection(t)); | |
55 }, 'CORS type response could be loaded in the iframe.'); | |
56 | |
57 async_test(function(t) { | |
58 var scope = 'resources/fetch-frame-resource/frame-opaque'; | |
59 service_worker_unregister_and_register(t, worker, scope) | |
60 .then(function(reg) { return wait_for_activated(t, reg); }) | |
61 .then(function() { | |
62 var frame = document.createElement('iframe'); | |
63 frame.src = | |
64 scope + '?mode=no-cors&url=' + | |
65 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path); | |
66 document.body.appendChild(frame); | |
67 // We can't catch the network error on iframe. So we use the timer. | |
68 return new Promise(function(resolve) { | |
69 setTimeout(function() { resolve(frame); }, 1000); | |
falken
2014/10/03 03:43:47
Especially with this timeout, we'll want separate
| |
70 }); | |
71 }) | |
72 .then(function(frame) { | |
73 assert_equals( | |
74 frame.contentDocument.body.textContent, | |
75 '', | |
76 'Opaque type response could not be loaded in the iframe.'); | |
77 unload_iframe(frame); | |
78 return service_worker_unregister_and_done(t, scope); | |
79 }) | |
80 .catch(unreached_rejection(t)); | |
81 }, 'Opaque type response could not be loaded in the iframe.'); | |
82 | |
83 async_test(function(t) { | |
84 var scope = 'resources/fetch-frame-resource/window-basic'; | |
85 service_worker_unregister_and_register(t, worker, scope) | |
86 .then(function(reg) { return wait_for_activated(t, reg); }) | |
87 .then(function() { | |
88 return new Promise(function(resolve) { | |
89 var win = window.open( | |
90 scope + '?url=' + | |
91 encodeURIComponent(host_info['HTTP_ORIGIN'] + path)); | |
92 win.onload = function() { resolve(win); }; | |
93 }); | |
94 }) | |
95 .then(function(win) { | |
96 assert_not_equals( | |
97 win.document.body.textContent, | |
98 '', | |
99 'Basic type response could be loaded in the new window.'); | |
100 win.close(); | |
101 return service_worker_unregister_and_done(t, scope); | |
102 }) | |
103 .catch(unreached_rejection(t)); | |
104 }, 'Basic type response could be loaded in the new window.'); | |
105 | |
106 async_test(function(t) { | |
107 var scope = 'resources/fetch-frame-resource/window-cors'; | |
108 service_worker_unregister_and_register(t, worker, scope) | |
109 .then(function(reg) { return wait_for_activated(t, reg); }) | |
110 .then(function() { | |
111 return new Promise(function(resolve) { | |
112 var win = window.open( | |
113 scope + '?mode=cors&url=' + | |
114 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path + | |
115 '?ACAOrigin=' + host_info['HTTP_ORIGIN'])); | |
116 win.onload = function() { resolve(win); }; | |
117 }); | |
118 }) | |
119 .then(function(win) { | |
120 assert_not_equals( | |
121 win.document.body.textContent, | |
122 '', | |
123 'CORS type response could be loaded in the new window.'); | |
124 win.close(); | |
125 return service_worker_unregister_and_done(t, scope); | |
126 }) | |
127 .catch(unreached_rejection(t)); | |
128 }, 'CORS type response could be loaded in the new window.'); | |
129 | |
130 async_test(function(t) { | |
131 var scope = 'resources/fetch-frame-resource/window-opaque'; | |
132 service_worker_unregister_and_register(t, worker, scope) | |
133 .then(function(reg) { return wait_for_activated(t, reg); }) | |
134 .then(function() { | |
135 var win = window.open( | |
136 scope + '?mode=no-cors&url=' + | |
137 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path)); | |
138 // We can't catch the network error on window. So we use the timer. | |
139 return new Promise(function(resolve) { | |
140 setTimeout(function() { resolve(win); }, 1000); | |
falken
2014/10/03 03:43:47
and this one
| |
141 }); | |
142 }) | |
143 .then(function(win) { | |
144 assert_equals( | |
145 win.document.body.textContent, | |
146 '', | |
147 'CORS type response could not be loaded in the new window.'); | |
148 win.close(); | |
149 return service_worker_unregister_and_done(t, scope); | |
150 }) | |
151 .catch(unreached_rejection(t)); | |
152 }, 'Opaque type response could not be loaded in the new window.'); | |
153 </script> | |
154 </body> | |
OLD | NEW |