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

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

Issue 1439333002: Service Worker: Add Clients.get(id) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary condition 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
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-cross-origin.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-cross-origin.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-cross-origin.html
new file mode 100644
index 0000000000000000000000000000000000000000..e1ec570cd313db8a2193d8efaecaf340358fce27
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/clients-get-cross-origin.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<title>Service Worker: Clients.get across origins</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 host_info = get_host_info();
+
+var scope = 'resources/clients-get-frame.html';
+var other_origin_iframe = host_info['HTTP_REMOTE_ORIGIN'] + base_path() +
+ 'resources/clients-get-cross-origin-frame.html';
+var my_origin_client_id;
+promise_test(function(t) {
+ return service_worker_unregister_and_register(
+ t, 'resources/clients-get-worker.js', scope)
+ .then(function(registration) {
+ add_completion_callback(function() { registration.unregister(); });
+ return wait_for_state(t, registration.installing, 'activated');
+ })
+ .then(function() {
+ return with_iframe(scope);
+ })
+ .then(function(frame1) {
+ add_completion_callback(function() { frame1.remove(); });
+ return new Promise(function(resolve, reject) {
+ function get_client_id(e) {
+ window.removeEventListener('message', get_client_id);
+ resolve(e.data.clientId);
+ }
+ window.addEventListener('message', get_client_id, false);
+ });
+ })
+ .then(function(client_id) {
+ my_origin_client_id = client_id;
+ return with_iframe(other_origin_iframe);
+ })
+ .then(function(frame2) {
+ add_completion_callback(function() { frame2.remove(); });
+ window.addEventListener('message', function(e) {
+ assert_equals(e.data.result, undefined);
+ t.done();
+ });
+ frame2.contentWindow.postMessage(
+ {clientId: my_origin_client_id}, host_info['HTTP_REMOTE_ORIGIN']);
+ });
+ }, 'Test Clients.get() cross origin');
+</script>

Powered by Google App Engine
This is Rietveld 408576698