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

Unified Diff: LayoutTests/http/tests/serviceworker/clients-matchall-client-types.html

Issue 1040993003: ServiceWorker: Support non-window clients in Clients.matchAll (2/2 blink) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/serviceworker/clients-matchall-client-types.html
diff --git a/LayoutTests/http/tests/serviceworker/clients-matchall-client-types.html b/LayoutTests/http/tests/serviceworker/clients-matchall-client-types.html
new file mode 100644
index 0000000000000000000000000000000000000000..70193f091fb931d0a9e2d826d67ef0442aa7a6cc
--- /dev/null
+++ b/LayoutTests/http/tests/serviceworker/clients-matchall-client-types.html
@@ -0,0 +1,82 @@
+<!DOCTYPE html>
+<title>Service Worker: Clients.matchAll with various clientTypes</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.js"></script>
+<script>
+var scope = 'resources/clients-matchall-client-types';
+var iframe_url = scope + '-iframe.html';
+var worker_url = scope + '-worker.js';
falken 2015/03/31 04:34:32 nit: hmm we've been using -worker.js for service w
nhiroki 2015/04/01 04:51:34 Renamed to -shared-worker.js
+
+/* visibilityState, focused, url, frameType */
+var expected_without_type = [
+ ['visible', true, new URL(iframe_url, location).toString(), 'nested']
falken 2015/03/31 04:34:32 nit: these .toString() could be .href to save typi
nhiroki 2015/04/01 04:51:34 Done.
+];
+var expected_with_window = [
+ ['visible', true, new URL(iframe_url, location).toString(), 'nested']
+];
+var expected_with_shared_worker = [
+ [,,new URL(worker_url, location).toString(), 'none']
+];
+var expected_with_all = [
+ ['visible', true, new URL(iframe_url, location).toString(), 'nested'],
+ [,,new URL(worker_url, location).toString(), 'none']
+];
+
+function test_matchall(frame, expected, query_options) {
+ // Make sure the frame gets focus.
+ frame.focus();
+ expected.sort(function(a, b) { return a[2] > b[2] ? 1 : -1; });
+ return new Promise(function(resolve, reject) {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = function(e) {
+ assert_equals(e.data.length, expected.length);
+ for (var i = 0; i < e.data.length; i++)
+ assert_array_equals(e.data[i], expected[i]);
+ resolve(frame);
falken 2015/03/31 04:34:32 nit: this return value isn't used
nhiroki 2015/04/01 04:51:34 Removed.
+ };
+ frame.contentWindow.navigator.serviceWorker.controller.postMessage(
+ {port:channel.port2, options:query_options},
+ [channel.port2]);
+ });
+}
+
+promise_test(function(t) {
+ var frame;
+ return service_worker_unregister_and_register(
+ t, 'resources/clients-matchall-worker.js', scope)
+ .then(function(registration) {
+ return wait_for_state(t, registration.installing, 'activated');
+ })
+ .then(function() { return with_iframe(iframe_url); })
+ .then(function(f) {
+ frame = f;
+ return new Promise(function(resolve, reject) {
+ var w = new SharedWorker(worker_url);
+ w.port.onmessage = function(e) {
+ resolve(e.data);
falken 2015/03/31 04:34:32 nit: unused
nhiroki 2015/04/01 04:51:34 Removed.
+ }
falken 2015/03/31 04:34:32 nit: missing semi-colon
nhiroki 2015/04/01 04:51:34 Done.
+ });
+ })
+ .then(function() {
+ return test_matchall(frame, expected_without_type, {});
+ })
+ .then(function() {
+ return test_matchall(frame, expected_with_window,
+ {type:"window"});
falken 2015/03/31 04:34:31 nit: should be single-quotes in JS (same below)
nhiroki 2015/04/01 04:51:34 Done.
+ })
+ .then(function() {
+ return test_matchall(frame, expected_with_shared_worker,
+ {type:"sharedworker"});
+ })
+ .then(function() {
+ return test_matchall(frame, expected_with_all,
+ {type:"all"});
+ })
+ .then(function() {
+ frame.remove();
+ return service_worker_unregister_and_done(t, scope);
+ });
+ }, 'Verify matchAll() with various client types');
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698