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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-client-types.html

Issue 1731823003: Service Worker: Add worker client test for Clients.get(id) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 10 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-client-types-frame.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-client-types.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-client-types.html
similarity index 62%
copy from third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get.html
copy to third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-client-types.html
index 67110c90b794ac41b11349d3ed69140683f22001..75f54ebe194f344b5c8d9d396249810e862c0262 100644
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get.html
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-client-types.html
@@ -1,11 +1,12 @@
<!DOCTYPE html>
-<title>Service Worker: Clients.get</title>
+<title>Service Worker: Clients.get with window and worker clients</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
-<script src="../resources/get-host-info.js"></script>
<script src="resources/test-helpers.js"></script>
<script>
-var scope = 'resources/clients-get-frame.html';
+var scope = 'resources/clients-get-client-types';
+var frame_url = scope + '-frame.html';
+var shared_worker_url = scope + '-shared-worker.js';
var client_ids = [];
var frame;
promise_test(function(t) {
@@ -16,24 +17,25 @@ promise_test(function(t) {
return wait_for_state(t, registration.installing, 'activated');
})
.then(function() {
- return with_iframe(scope + '#1');
+ return with_iframe(frame_url);
})
- .then(function(frame1) {
- add_completion_callback(function() { frame1.remove(); });
- frame1.focus();
+ .then(function(f) {
+ frame = f;
+ add_completion_callback(function() { frame.remove(); });
+ frame.focus();
return wait_for_clientId();
})
.then(function(client_id) {
client_ids.push(client_id);
- return with_iframe(scope + '#2');
- })
- .then(function(frame2) {
- frame = frame2;
- add_completion_callback(function() { frame2.remove(); });
- return wait_for_clientId();
+ return new Promise(function(resolve) {
+ var w = new SharedWorker(shared_worker_url);
+ w.port.onmessage = function(e) {
+ resolve(e.data.clientId);
+ };
+ });
})
.then(function(client_id) {
- client_ids.push(client_id, 'invalid-id');
+ client_ids.push(client_id);
var channel = new MessageChannel();
var saw_message = new Promise(function(resolve) {
channel.port1.onmessage = resolve;
@@ -43,15 +45,14 @@ promise_test(function(t) {
return saw_message;
})
.then(function(e) {
- assert_equals(e.data.length, 3);
+ assert_equals(e.data.length, 2);
assert_array_equals(e.data[0], expected[0]);
assert_array_equals(e.data[1], expected[1]);
- assert_equals(e.data[2], expected[2]);
});
- }, 'Test Clients.get()');
+ }, 'Test Clients.get() with window and worker clients');
function wait_for_clientId() {
- return new Promise(function(resolve, reject) {
+ return new Promise(function(resolve) {
function get_client_id(e) {
window.removeEventListener('message', get_client_id);
resolve(e.data.clientId);
@@ -62,8 +63,7 @@ function wait_for_clientId() {
var expected = [
/* visibilityState, focused, url, frameType */
- ['visible', true, normalizeURL(scope) + '#1', 'nested'],
- ['visible', false, normalizeURL(scope) + '#2', 'nested'],
- undefined
+ ['visible', true, normalizeURL(scope) + '-frame.html', 'nested'],
+ [,,normalizeURL(scope) + '-shared-worker.js', 'none']
];
</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-client-types-frame.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698