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

Side by Side Diff: LayoutTests/http/tests/serviceworker/controller-on-reload.html

Issue 835673006: Use caller's document url to resolve scriptURL/patternURL in registerServiceWorker/getRegistration (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address comments in registration-iframe.html Created 5 years, 9 months 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: Controller on reload</title> 2 <title>Service Worker: Controller on reload</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 t = async_test('controller is set upon reload after registration'); 8 var t = async_test('controller is set upon reload after registration');
9 t.step(function() { 9 t.step(function() {
10 var reloaded = false; 10 var reloaded = false;
11 var scope = 'resources/blank.html'; 11 var scope = 'resources/blank.html';
12 service_worker_unregister(t, scope).then(doTest); 12 service_worker_unregister(t, scope).then(doTest);
13 13
14 function doTest() { 14 function doTest() {
15 with_iframe(scope, t.step_func(onIframeLoad)); 15 with_iframe(scope, t.step_func(onIframeLoad));
16 } 16 }
17 17
18 function onIframeLoad(frame) { 18 function onIframeLoad(frame) {
19 var w = frame.contentWindow; 19 var w = frame.contentWindow;
20 if (reloaded) { 20 if (reloaded) {
21 assert_true(w.navigator.serviceWorker.controller instanceof w.Servic eWorker, 21 assert_true(w.navigator.serviceWorker.controller instanceof w.Servic eWorker,
22 'controller should be a ServiceWorker object upon reload '); 22 'controller should be a ServiceWorker object upon reload ');
23 service_worker_unregister_and_done(t, scope); 23 service_worker_unregister_and_done(t, scope);
24 return; 24 return;
25 } 25 }
26 26
27 w.navigator.serviceWorker.register('empty-worker.js', 27 w.navigator.serviceWorker.register('resources/empty-worker.js',
28 {scope: 'blank.html'}) 28 {scope: 'resources/blank.html'})
29 .then(function(registration) { 29 .then(function(registration) {
30 return wait_for_state(t, registration.installing, 'activated'); 30 return wait_for_state(t, registration.installing, 'activated');
31 }) 31 })
32 .then(function() { 32 .then(function() {
33 assert_equals(w.navigator.serviceWorker.controller, null, 33 assert_equals(w.navigator.serviceWorker.controller, null,
34 'controller should be null until the document is reloa ded'); 34 'controller should be null until the document is reloa ded');
35 reloaded = true; 35 reloaded = true;
36 w.location.reload(); 36 w.location.reload();
37 }) 37 })
38 .catch(unreached_rejection(t)); 38 .catch(unreached_rejection(t));
39 } 39 }
40 }); 40 });
41 </script> 41 </script>
42 </body> 42 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698