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

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

Issue 1439333002: Service Worker: Add Clients.get(id) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add layout test Created 4 years, 12 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: third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get.html
new file mode 100644
index 0000000000000000000000000000000000000000..9070a80f35763bd653d7ca4bb0212f20282d1b42
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get.html
@@ -0,0 +1,50 @@
+<!DOCTYPE html>
+<title>Service Worker: Clients.get(id)</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.js"></script>
+<script>
+var scope = 'resources/blank.html?clients-get';
+var expected_client_url = new URL(scope + '#2', location).toString();
+
+var frame1, frame2;
+var worker;
+promise_test(function(t) {
+ return service_worker_unregister_and_register(
+ t, 'resources/clients-get-worker.js', scope)
+ .then(function(registration) {
+ worker = registration.installing;
+ return wait_for_state(t, worker, 'activated');
+ })
+ .then(function() { return with_iframe(scope + '#1'); })
+ .then(function(f) {
+ frame1 = f;
+ return with_iframe(scope + '#2');
+ })
+ .then(function(f) {
+ frame2 = f;
+ return new Promise(function(resolve) {
+ // Make a subresource request in the second iframe (scope + '#2').
+ var xhr = new f.contentWindow.XMLHttpRequest();
+ xhr.onload = function() {
+ resolve();
+ };
+ xhr.open('GET', 'simple.txt');
+ xhr.send();
+ });
+ })
+ .then(function() {
+ return new Promise(function(resolve) {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = resolve;
+ worker.postMessage({port:channel.port2}, [channel.port2]);
+ });
+ })
+ .then(function(message) {
+ assert_array_equals(message.data, expected_client_url);
+ frame1.remove();
+ frame2.remove();
+ return service_worker_unregister_and_done(t, scope);
+ })
+ }, 'Test Clients.get(id)');
+</script>

Powered by Google App Engine
This is Rietveld 408576698