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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../resources/testharness.js"></script>
3 <script src="../../resources/testharnessreport.js"></script>
4 <script src="../../resources/get-host-info.js"></script>
5 <script src="test-helpers.js"></script>
6 <script>
7 var host_info = get_host_info();
8 var SCOPE = 'blank.html?clients-get';
9 var SCRIPT = 'clients-get-worker.js';
10
11 var registration;
12 var worker;
13 var wait_for_worker_promise = navigator.serviceWorker.getRegistration(SCOPE)
14 .then(function(reg) {
15 if (reg)
16 return reg.unregister();
17 })
18 .then(function() {
19 return navigator.serviceWorker.register(SCRIPT, {scope: SCOPE});
20 })
21 .then(function(reg) {
22 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
23 worker = reg.installing;
24 return new Promise(function(resolve) {
25 worker.addEventListener('statechange', function() {
26 if (worker.state == 'activated')
27 resolve();
28 });
29 });
30 });
31
32 function send_result(result) {
33 window.parent.postMessage(
34 {result: result},
35 host_info['HTTP_ORIGIN']);
36 }
37
38 window.addEventListener('message', function(e) {
39 assert_equals(e.origin, host_info['HTTP_ORIGIN']);
40 var otherOriginClientIds = [];
nhiroki 2016/02/17 02:40:28 other_origin_client_ids
jungkees 2016/02/17 14:01:13 Done.
41 otherOriginClientIds.push(e.data.clientId);
42 wait_for_worker_promise
43 .then(function() {
44 return with_iframe(SCOPE);
45 })
46 .then(function(iframe) {
47 add_completion_callback(function() { iframe.remove(); });
48 var channel = new MessageChannel();
49 channel.port1.onmessage = function(e) {
50 navigator.serviceWorker.getRegistration(SCOPE)
51 .then(function(reg) {
52 reg.unregister();
53 send_result(e.data);
54 });
55 };
56 iframe.contentWindow.navigator.serviceWorker.controller.postMessage(
57 {port:channel.port2, clientIds: otherOriginClientIds},
58 [channel.port2]);
59 });
60 });
61 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698