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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/clients-get-cross-origin-frame.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 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;
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 cross_origin_client_ids = [];
41 cross_origin_client_ids.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 registration.unregister();
51 send_result(e.data);
52 };
53 iframe.contentWindow.navigator.serviceWorker.controller.postMessage(
54 {port:channel.port2, clientIds: cross_origin_client_ids},
55 [channel.port2]);
56 });
57 });
58 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698