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

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

Issue 301103003: Rename navigator.serviceWorker.current to controller. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Bring rebaselines to head. Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Service Worker: Current on reload</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 t = async_test('current is set upon reload after registration');
9 t.step(function() {
10 var reloaded = false;
11 var scope = 'resources/blank.html';
12 navigator.serviceWorker.unregister(scope).then(
13 doTest,
14 unreached_rejection(t, 'Unregister should not fail')
15 );
16
17 function doTest() {
18 with_iframe(scope, t.step_func(onIframeLoad));
19 }
20
21 function onIframeLoad(frame) {
22 var w = frame.contentWindow;
23
24 function onActive(event) {
25 assert_equals(w.navigator.serviceWorker.current, null,
26 'current should be null until the document is reloaded' );
27 reloaded = true;
28 w.location.reload();
29 }
30
31 function onRegister(worker) {
32 worker.addEventListener('statechange', t.step_func(function(event) {
33 if (event.target.state == 'active')
34 onActive();
35 }));
36 }
37
38 if (reloaded) {
39 assert_true(w.navigator.serviceWorker.current instanceof w.ServiceWo rker,
40 'current should be a ServiceWorker object upon reload');
41 service_worker_unregister_and_done(t, scope);
42 return;
43 }
44
45 w.navigator.serviceWorker.register(
46 'worker-no-op.js', {scope: 'blank.html'}
47 ).then(
48 t.step_func(onRegister),
49 unreached_rejection(t, 'Registration should succeed, but failed')
50 );
51 }
52 });
53 </script>
54 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698