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

Unified Diff: LayoutTests/http/tests/serviceworker/clients-getall.html

Issue 778703004: Implement ServiceWorkerClient attributes [3/3] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@properties-step1
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/serviceworker/clients-getall.html
diff --git a/LayoutTests/http/tests/serviceworker/clients-getall.html b/LayoutTests/http/tests/serviceworker/clients-getall.html
new file mode 100644
index 0000000000000000000000000000000000000000..52b2d59a85f76f13329967d34687e1718f3abe36
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/clients-getall.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<title>Service Worker: ServiceWorkerClient.getAll</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.js"></script>
+<script>
+var t = async_test('Test ServiceWorkerClient.getAll()');
+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.
+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
+ service_worker_unregister_and_register(
+ t, 'resources/clients-getall-worker.js', scope)
+ .then(function(registration) {
+ 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.
+ })
+ .then(function(sw) {
+ return wait_for_state(t, sw, 'activated');
+ })
+ .then(function() { return with_iframe(scope + '#1'); })
+ .then(function(frame1) {
+ frame1.focus();
+ return with_iframe(scope + '#2');
+ })
+ .then(function(frame2) {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = t.step_func(onMessage);
+ frame2.contentWindow.navigator.serviceWorker.controller.postMessage(
+ {port:channel.port2}, [channel.port2]);
+ })
+ .catch(unreached_rejection(t));
+ });
+
+var expected = [
+ /* visibilityState, focused, url, frameType */
+ ['visible', true, new URL(scope + '#1', location).toString(), 'nested'],
+ ['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.
+];
+
+function onMessage(e) {
+ assert_equals(e.data.length, 2);
+ assert_array_equals(e.data[0], expected[0]);
+ assert_array_equals(e.data[1], expected[1]);
+ 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.
+}
+</script>

Powered by Google App Engine
This is Rietveld 408576698