Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <title>Service Worker: ServiceWorkerClient.getAll</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> | |
| 7 var t = async_test('Test ServiceWorkerClient.getAll()'); | |
| 8 var scope = 'resources/blank.html'; | |
|
nhiroki
2014/12/08 06:02:47
"blank.html?clients-getAll" could be more stable?
Kunihiko Sakamoto
2014/12/08 07:40:00
Done.
| |
| 9 t.step(function() { | |
|
nhiroki
2014/12/08 06:02:47
Optional: You may want to use 'promise_test' and o
Kunihiko Sakamoto
2014/12/08 07:39:59
It didn't work as promise_test calls done() but we
nhiroki
2014/12/08 08:01:08
I think wrapping onMessage() with Promise might wo
Kunihiko Sakamoto
2014/12/08 08:34:10
OK, let me keep the current style as it's easier t
| |
| 10 service_worker_unregister_and_register( | |
| 11 t, 'resources/clients-getall-worker.js', scope) | |
| 12 .then(function(registration) { | |
| 13 return wait_for_update(t, registration); | |
|
nhiroki
2014/12/08 06:02:47
To get a worker object, you can just use 'registra
Kunihiko Sakamoto
2014/12/08 07:40:00
Done.
| |
| 14 }) | |
| 15 .then(function(sw) { | |
| 16 return wait_for_state(t, sw, 'activated'); | |
| 17 }) | |
| 18 .then(function() { return with_iframe(scope + '#1'); }) | |
| 19 .then(function(frame1) { | |
| 20 frame1.focus(); | |
| 21 return with_iframe(scope + '#2'); | |
| 22 }) | |
| 23 .then(function(frame2) { | |
| 24 var channel = new MessageChannel(); | |
| 25 channel.port1.onmessage = t.step_func(onMessage); | |
| 26 frame2.contentWindow.navigator.serviceWorker.controller.postMessage( | |
| 27 {port:channel.port2}, [channel.port2]); | |
| 28 }) | |
| 29 .catch(unreached_rejection(t)); | |
| 30 }); | |
| 31 | |
| 32 var expected = [ | |
| 33 /* visibilityState, focused, url, frameType */ | |
| 34 ['visible', true, new URL(scope + '#1', location).toString(), 'nested'], | |
| 35 ['visible', false, new URL(scope + '#2', location).toString(), 'nested'] | |
|
nhiroki
2014/12/08 06:02:46
Can we have tests for other visibilityStates ('hid
Kunihiko Sakamoto
2014/12/08 07:39:59
We could call testRunner.setPageVisibility() but t
nhiroki
2014/12/08 08:01:08
Acknowledged.
| |
| 36 ]; | |
| 37 | |
| 38 function onMessage(e) { | |
| 39 assert_equals(e.data.length, 2); | |
| 40 assert_array_equals(e.data[0], expected[0]); | |
| 41 assert_array_equals(e.data[1], expected[1]); | |
| 42 t.done(); | |
|
nhiroki
2014/12/08 06:02:47
Calling service_worker_unregister_and_done() would
Kunihiko Sakamoto
2014/12/08 07:40:00
Done.
| |
| 43 } | |
| 44 </script> | |
| OLD | NEW |