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

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

Issue 265943003: Add blink-side binding code for navigator.serviceWorker.current (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebased cached properties access tests Created 6 years, 7 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 <script src="resources/testutils.js"></script>
7 <body>
8 <script>
9 var t = async_test('current is set upon reload after registration');
10 t.step(function() {
11 var reloaded = false;
12 var scope = 'resources/blank.html';
13 navigator.serviceWorker.unregister(scope).then(
14 doTest,
15 unreached_rejection(t, 'Unregister should not fail')
16 );
17
18 function doTest() {
19 with_iframe(scope, t.step_func(onIframeLoad));
20 }
21
22 function onIframeLoad(frame) {
23 var w = frame.contentWindow;
24
25 function onActive(event) {
26 assert_equals(w.navigator.serviceWorker.current, null,
27 'current should be null until the document is reloaded' );
28 reloaded = true;
29 w.location.reload();
30 }
31
32 function onRegister(worker) {
33 worker.addEventListener('statechange', t.step_func(function(event) {
34 if (event.target.state == 'active')
35 onActive();
36 }));
37 }
38
39 if (reloaded) {
40 assert_true(w.navigator.serviceWorker.current instanceof w.ServiceWo rker,
41 'current should be a ServiceWorker object upon reload');
42 t.done();
43 return;
44 }
45
46 w.navigator.serviceWorker.register(
47 'worker-no-op.js', {scope: 'blank.html'}
48 ).then(
49 t.step_func(onRegister),
50 unreached_rejection(t, 'Registration should succeed, but failed')
51 );
52 }
53 });
54 </script>
55 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698