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

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

Issue 1439333002: Service Worker: Add Clients.get(id) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase; 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
Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-other-origin.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-other-origin.html b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-other-origin.html
new file mode 100644
index 0000000000000000000000000000000000000000..15d824e8b1d5b5115b2d5ac685d1e70b4c54a684
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-other-origin.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../../resources/get-host-info.js"></script>
+<script src="test-helpers.js"></script>
+<script>
+var host_info = get_host_info();
+var SCOPE = 'blank.html?clients-get';
+var SCRIPT = 'clients-get-worker.js';
+
+var registration;
+var worker;
+var wait_for_worker_promise = navigator.serviceWorker.getRegistration(SCOPE)
+ .then(function(reg) {
+ if (reg)
+ return reg.unregister();
+ })
+ .then(function() {
+ return navigator.serviceWorker.register(SCRIPT, {scope: SCOPE});
+ })
+ .then(function(reg) {
+ registration = reg;
nhiroki 2016/02/17 02:40:28 |registration| is not used. Did you mean to use it
jungkees 2016/02/17 14:01:13 Yes, I removed the getRegistration() in line 50 an
+ worker = reg.installing;
+ return new Promise(function(resolve) {
+ worker.addEventListener('statechange', function() {
+ if (worker.state == 'activated')
+ resolve();
+ });
+ });
+ });
+
+function send_result(result) {
+ window.parent.postMessage(
+ {result: result},
+ host_info['HTTP_ORIGIN']);
+}
+
+window.addEventListener('message', function(e) {
+ assert_equals(e.origin, host_info['HTTP_ORIGIN']);
+ var otherOriginClientIds = [];
nhiroki 2016/02/17 02:40:28 other_origin_client_ids
jungkees 2016/02/17 14:01:13 Done.
+ otherOriginClientIds.push(e.data.clientId);
+ wait_for_worker_promise
+ .then(function() {
+ return with_iframe(SCOPE);
+ })
+ .then(function(iframe) {
+ add_completion_callback(function() { iframe.remove(); });
+ var channel = new MessageChannel();
+ channel.port1.onmessage = function(e) {
+ navigator.serviceWorker.getRegistration(SCOPE)
+ .then(function(reg) {
+ reg.unregister();
+ send_result(e.data);
+ });
+ };
+ iframe.contentWindow.navigator.serviceWorker.controller.postMessage(
+ {port:channel.port2, clientIds: otherOriginClientIds},
+ [channel.port2]);
+ });
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698