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

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: 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/testutils.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(doTest, doTest);
13
14 function doTest() {
15 withIframe(scope, t.step_func(onIframeLoad));
16 }
17
18 function onIframeLoad(frame) {
19 var w = frame.contentWindow;
20
21 function onActive(event) {
22 assert_equals(w.navigator.serviceWorker.current, null,
23 'current should be null until the document is reloaded' );
24 reloaded = true;
25 w.location.reload();
26 }
27
28 function onRegister(worker) {
29 worker.addEventListener('statechange', function(event) {
30 if (event.target.state == 'active')
31 t.step(onActive);
32 });
33 }
34
35 if (reloaded) {
36
37 // FIXME: Why instanceof doesn't work?
38 // assert_true(w.navigator.serviceWorker.current instanceof ServiceW orker,
kinuko 2014/05/02 12:26:13 Somehow I can't make it work for .current. I'm lik
jsbell 2014/05/02 17:55:03 w.navigator.serviceWorker.current is reaching into
kinuko 2014/05/05 14:20:27 Very cool, thanks!
39 assert_true(w.navigator.serviceWorker.current.constructor.name == 'S erviceWorker',
40 'current should be a ServiceWorker object upon reload');
41 t.done();
42 return;
43 }
44
45 w.navigator.serviceWorker.register(
46 'worker-no-op.js', {scope: 'blank.html'}
47 ).then(t.step_func(onRegister), t.step_func(function(reason) {
48 assert_unreached('Registration should succeed, but failed: ' + reaso n.name);
49 }));
50 }
51 });
52 </script>
53 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698