Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(704)

Side by Side Diff: LayoutTests/http/tests/serviceworker/fetch-frame-resource.html

Issue 790683002: ServiceWorker cleanup: remove wait_for_activated(); just use wait_for_state() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: Fetch for the frame loading.</title> 2 <title>Service Worker: Fetch for the frame loading.</title>
3 <script src="../resources/testharness.js"></script> 3 <script src="../resources/testharness.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/test-helpers.js"></script> 5 <script src="resources/test-helpers.js"></script>
6 <body> 6 <body>
7 <script> 7 <script>
8 var worker = 'resources/fetch-rewrite-worker.js'; 8 var worker = 'resources/fetch-rewrite-worker.js';
9 var path = base_path() + 'resources/fetch-access-control.php'; 9 var path = base_path() + 'resources/fetch-access-control.php';
10 var host_info = get_host_info(); 10 var host_info = get_host_info();
11 11
12 if (window.testRunner) { 12 if (window.testRunner) {
13 testRunner.setCanOpenWindows(); 13 testRunner.setCanOpenWindows();
14 } 14 }
15 15
16 async_test(function(t) { 16 async_test(function(t) {
17 var scope = 'resources/fetch-frame-resource/frame-basic'; 17 var scope = 'resources/fetch-frame-resource/frame-basic';
18 service_worker_unregister_and_register(t, worker, scope) 18 service_worker_unregister_and_register(t, worker, scope)
19 .then(function(reg) { return wait_for_activated(t, reg); }) 19 .then(function(reg) {
20 return wait_for_state(t, reg.installing, 'activated');
21 })
20 .then(function() { 22 .then(function() {
21 return with_iframe( 23 return with_iframe(
22 scope + '?url=' + 24 scope + '?url=' +
23 encodeURIComponent(host_info['HTTP_ORIGIN'] + path)); 25 encodeURIComponent(host_info['HTTP_ORIGIN'] + path));
24 }) 26 })
25 .then(function(frame) { 27 .then(function(frame) {
26 assert_not_equals( 28 assert_not_equals(
27 frame.contentDocument.body.textContent, 29 frame.contentDocument.body.textContent,
28 '', 30 '',
29 'Basic type response could be loaded in the iframe.'); 31 'Basic type response could be loaded in the iframe.');
30 unload_iframe(frame); 32 unload_iframe(frame);
31 return service_worker_unregister_and_done(t, scope); 33 return service_worker_unregister_and_done(t, scope);
32 }) 34 })
33 .catch(unreached_rejection(t)); 35 .catch(unreached_rejection(t));
34 }, 'Basic type response could be loaded in the iframe.'); 36 }, 'Basic type response could be loaded in the iframe.');
35 37
36 async_test(function(t) { 38 async_test(function(t) {
37 var scope = 'resources/fetch-frame-resource/frame-cors'; 39 var scope = 'resources/fetch-frame-resource/frame-cors';
38 service_worker_unregister_and_register(t, worker, scope) 40 service_worker_unregister_and_register(t, worker, scope)
39 .then(function(reg) { return wait_for_activated(t, reg); }) 41 .then(function(reg) {
42 return wait_for_state(t, reg.installing, 'activated');
43 })
40 .then(function() { 44 .then(function() {
41 return with_iframe( 45 return with_iframe(
42 scope + '?mode=cors&url=' + 46 scope + '?mode=cors&url=' +
43 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path + 47 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path +
44 '?ACAOrigin=' + host_info['HTTP_ORIGIN'])); 48 '?ACAOrigin=' + host_info['HTTP_ORIGIN']));
45 }) 49 })
46 .then(function(frame) { 50 .then(function(frame) {
47 assert_not_equals( 51 assert_not_equals(
48 frame.contentDocument.body.textContent, 52 frame.contentDocument.body.textContent,
49 '', 53 '',
50 'CORS type response could be loaded in the iframe.'); 54 'CORS type response could be loaded in the iframe.');
51 unload_iframe(frame); 55 unload_iframe(frame);
52 return service_worker_unregister_and_done(t, scope); 56 return service_worker_unregister_and_done(t, scope);
53 }) 57 })
54 .catch(unreached_rejection(t)); 58 .catch(unreached_rejection(t));
55 }, 'CORS type response could be loaded in the iframe.'); 59 }, 'CORS type response could be loaded in the iframe.');
56 60
57 async_test(function(t) { 61 async_test(function(t) {
58 var scope = 'resources/fetch-frame-resource/frame-opaque'; 62 var scope = 'resources/fetch-frame-resource/frame-opaque';
59 service_worker_unregister_and_register(t, worker, scope) 63 service_worker_unregister_and_register(t, worker, scope)
60 .then(function(reg) { return wait_for_activated(t, reg); }) 64 .then(function(reg) {
65 return wait_for_state(t, reg.installing, 'activated');
66 })
61 .then(function() { 67 .then(function() {
62 var frame = document.createElement('iframe'); 68 var frame = document.createElement('iframe');
63 frame.src = 69 frame.src =
64 scope + '?mode=no-cors&url=' + 70 scope + '?mode=no-cors&url=' +
65 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path); 71 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path);
66 document.body.appendChild(frame); 72 document.body.appendChild(frame);
67 // We can't catch the network error on iframe. So we use the timer. 73 // We can't catch the network error on iframe. So we use the timer.
68 return new Promise(function(resolve) { 74 return new Promise(function(resolve) {
69 setTimeout(function() { resolve(frame); }, 1000); 75 setTimeout(function() { resolve(frame); }, 1000);
70 }); 76 });
71 }) 77 })
72 .then(function(frame) { 78 .then(function(frame) {
73 assert_equals( 79 assert_equals(
74 frame.contentDocument.body.textContent, 80 frame.contentDocument.body.textContent,
75 '', 81 '',
76 'Opaque type response could not be loaded in the iframe.'); 82 'Opaque type response could not be loaded in the iframe.');
77 unload_iframe(frame); 83 unload_iframe(frame);
78 return service_worker_unregister_and_done(t, scope); 84 return service_worker_unregister_and_done(t, scope);
79 }) 85 })
80 .catch(unreached_rejection(t)); 86 .catch(unreached_rejection(t));
81 }, 'Opaque type response could not be loaded in the iframe.'); 87 }, 'Opaque type response could not be loaded in the iframe.');
82 88
83 async_test(function(t) { 89 async_test(function(t) {
84 var scope = 'resources/fetch-frame-resource/window-basic'; 90 var scope = 'resources/fetch-frame-resource/window-basic';
85 service_worker_unregister_and_register(t, worker, scope) 91 service_worker_unregister_and_register(t, worker, scope)
86 .then(function(reg) { return wait_for_activated(t, reg); }) 92 .then(function(reg) {
93 return wait_for_state(t, reg.installing, 'activated');
94 })
87 .then(function() { 95 .then(function() {
88 return new Promise(function(resolve) { 96 return new Promise(function(resolve) {
89 var win = window.open( 97 var win = window.open(
90 scope + '?url=' + 98 scope + '?url=' +
91 encodeURIComponent(host_info['HTTP_ORIGIN'] + path)); 99 encodeURIComponent(host_info['HTTP_ORIGIN'] + path));
92 win.onload = function() { resolve(win); }; 100 win.onload = function() { resolve(win); };
93 }); 101 });
94 }) 102 })
95 .then(function(win) { 103 .then(function(win) {
96 assert_not_equals( 104 assert_not_equals(
97 win.document.body.textContent, 105 win.document.body.textContent,
98 '', 106 '',
99 'Basic type response could be loaded in the new window.'); 107 'Basic type response could be loaded in the new window.');
100 win.close(); 108 win.close();
101 return service_worker_unregister_and_done(t, scope); 109 return service_worker_unregister_and_done(t, scope);
102 }) 110 })
103 .catch(unreached_rejection(t)); 111 .catch(unreached_rejection(t));
104 }, 'Basic type response could be loaded in the new window.'); 112 }, 'Basic type response could be loaded in the new window.');
105 113
106 async_test(function(t) { 114 async_test(function(t) {
107 var scope = 'resources/fetch-frame-resource/window-cors'; 115 var scope = 'resources/fetch-frame-resource/window-cors';
108 service_worker_unregister_and_register(t, worker, scope) 116 service_worker_unregister_and_register(t, worker, scope)
109 .then(function(reg) { return wait_for_activated(t, reg); }) 117 .then(function(reg) {
118 return wait_for_state(t, reg.installing, 'activated');
119 })
110 .then(function() { 120 .then(function() {
111 return new Promise(function(resolve) { 121 return new Promise(function(resolve) {
112 var win = window.open( 122 var win = window.open(
113 scope + '?mode=cors&url=' + 123 scope + '?mode=cors&url=' +
114 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path + 124 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path +
115 '?ACAOrigin=' + host_info['HTTP_ORIGIN'])); 125 '?ACAOrigin=' + host_info['HTTP_ORIGIN']));
116 win.onload = function() { resolve(win); }; 126 win.onload = function() { resolve(win); };
117 }); 127 });
118 }) 128 })
119 .then(function(win) { 129 .then(function(win) {
120 assert_not_equals( 130 assert_not_equals(
121 win.document.body.textContent, 131 win.document.body.textContent,
122 '', 132 '',
123 'CORS type response could be loaded in the new window.'); 133 'CORS type response could be loaded in the new window.');
124 win.close(); 134 win.close();
125 return service_worker_unregister_and_done(t, scope); 135 return service_worker_unregister_and_done(t, scope);
126 }) 136 })
127 .catch(unreached_rejection(t)); 137 .catch(unreached_rejection(t));
128 }, 'CORS type response could be loaded in the new window.'); 138 }, 'CORS type response could be loaded in the new window.');
129 139
130 async_test(function(t) { 140 async_test(function(t) {
131 var scope = 'resources/fetch-frame-resource/window-opaque'; 141 var scope = 'resources/fetch-frame-resource/window-opaque';
132 service_worker_unregister_and_register(t, worker, scope) 142 service_worker_unregister_and_register(t, worker, scope)
133 .then(function(reg) { return wait_for_activated(t, reg); }) 143 .then(function(reg) {
144 return wait_for_state(t, reg.installing, 'activated');
145 })
134 .then(function() { 146 .then(function() {
135 var win = window.open( 147 var win = window.open(
136 scope + '?mode=no-cors&url=' + 148 scope + '?mode=no-cors&url=' +
137 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path)); 149 encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path));
138 // We can't catch the network error on window. So we use the timer. 150 // We can't catch the network error on window. So we use the timer.
139 return new Promise(function(resolve) { 151 return new Promise(function(resolve) {
140 setTimeout(function() { resolve(win); }, 1000); 152 setTimeout(function() { resolve(win); }, 1000);
141 }); 153 });
142 }) 154 })
143 .then(function(win) { 155 .then(function(win) {
144 assert_equals( 156 assert_equals(
145 win.document.body.textContent, 157 win.document.body.textContent,
146 '', 158 '',
147 'CORS type response could not be loaded in the new window.'); 159 'CORS type response could not be loaded in the new window.');
148 win.close(); 160 win.close();
149 return service_worker_unregister_and_done(t, scope); 161 return service_worker_unregister_and_done(t, scope);
150 }) 162 })
151 .catch(unreached_rejection(t)); 163 .catch(unreached_rejection(t));
152 }, 'Opaque type response could not be loaded in the new window.'); 164 }, 'Opaque type response could not be loaded in the new window.');
153 </script> 165 </script>
154 </body> 166 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698