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

Side by Side Diff: LayoutTests/http/tests/serviceworker/current-on-load.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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Service Worker: Activation occurs after registration</title> 2 <title>Service Worker: Current on load</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/testutils.js"></script> 5 <script src="resources/testutils.js"></script>
6 <body> 6 <body>
7 <script> 7 <script>
8 var t = async_test('activation occurs after registration'); 8 var t = async_test('current is set for a controlled document');
9 t.step(function() { 9 t.step(function() {
10 var scope = 'resources/blank.html'; 10 var scope = 'resources/blank.html'
11 navigator.serviceWorker.unregister(scope).then(doTest, doTest); 11 navigator.serviceWorker.unregister(scope).then(doTest, doTest);
12
12 function doTest() { 13 function doTest() {
13 navigator.serviceWorker.register( 14 navigator.serviceWorker.register(
14 'resources/worker-no-op.js', {scope: scope} 15 'resources/worker-no-op.js', {scope: scope}
15 ).then(t.step_func(onRegister), t.step_func(function(reason) { 16 ).then(onRegister, t.step_func(function(reason) {
16 assert_unreached('Registration should succeed, but failed: ' + reaso n.name); 17 assert_unreached('Registration should succeed, but failed: ' + reaso n.name);
17 })); 18 }));
18 } 19 }
19 20
20 function onRegister(worker) { 21 function onRegister(worker) {
21 assert_equals(worker.state, 'parsed', 'worker should be in the "parsed" state upon registration');
22 worker.addEventListener('statechange', t.step_func(function(event) { 22 worker.addEventListener('statechange', t.step_func(function(event) {
23 if (event.target.state == 'active') 23 if (event.target.state == 'active')
24 t.done(); 24 onActive();
25 }));
26 }
27
28 function onActive() {
29 withIframe(scope, t.step_func(function(frame) {
30 var w = frame.contentWindow;
31 // FIXME: Why instanceof doesn't work?
32 // assert_true(w.navigator.serviceWorker.current instanceof ServiceW orker,
33 assert_true(w.navigator.serviceWorker.current.constructor.name == 'S erviceWorker',
34 'current should be a ServiceWorker object');
35 t.done();
25 })); 36 }));
26 } 37 }
27 }); 38 });
28 </script> 39 </script>
29 </body> 40 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698