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

Side by Side Diff: LayoutTests/http/tests/navigatorconnect/connect-cross-origin.html

Issue 812853002: Basic tests for sending messages over a navigator.connect initiated channel. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@navigator-connect_connect-tests
Patch Set: fix Created 6 years 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
« no previous file with comments | « no previous file | LayoutTests/http/tests/navigatorconnect/connect-from-worker.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title> 2 <title>
3 Tests accepting and rejecting connections calling navigator.connect from 3 Tests accepting and rejecting connections calling navigator.connect from
4 a cross origin iframe. 4 a cross origin iframe.
5 </title> 5 </title>
6 <script src="../../resources/testharness.js"></script> 6 <script src="../../resources/testharness.js"></script>
7 <script src="../../resources/testharnessreport.js"></script> 7 <script src="../../resources/testharnessreport.js"></script>
8 <script src="../../resources/testharness-helpers.js"></script> 8 <script src="../../resources/testharness-helpers.js"></script>
9 <script src="../serviceworker/resources/test-helpers.js"></script> 9 <script src="../serviceworker/resources/test-helpers.js"></script>
10 <script src="resources/test-helpers.js"></script>
10 <script src="resources/connect-tests.js"></script> 11 <script src="resources/connect-tests.js"></script>
11 <body> 12 <body>
12 <script> 13 <script>
13 var cross_origin = get_host_info().UNAUTHENTICATED_ORIGIN; 14 var cross_origin = get_host_info().UNAUTHENTICATED_ORIGIN;
14 var sw_scope = 'resources/service-worker-scope' + window.location.pathname; 15 var sw_scope = 'resources/service-worker-scope' + window.location.pathname;
15 16
16 // Method that behaves similarly to navigator.connect, but the actual connect
17 // call is made from a cross origin iframe.
18 function cross_origin_connect(t, service) {
19 // |service| is a relative URL, but for this to work from the iframe it needs
20 // an absolute URL.
21 var target_url = location.origin + base_path() + service;
22 return with_iframe(
23 cross_origin + base_path() + 'resources/connect-helper.html')
24 .then(function(iframe) {
25 var channel = new MessageChannel();
26 iframe.contentWindow.postMessage(
27 {connect: target_url, port: channel.port2}, '*', [channel.port2]);
28 return new Promise(function(resolve, reject) {
29 var got_reply = false;
30 channel.port1.onmessage = t.step_func(function(event) {
31 assert_false(got_reply);
32 assert_true('success' in event.data);
33 assert_true('result' in event.data);
34 got_reply = true;
35 if (event.data.success)
36 resolve(event.data.result);
37 else
38 reject(event.data.result);
39 });
40 });
41 });
42 }
43
44 run_connect_tests(cross_origin_connect); 17 run_connect_tests(cross_origin_connect);
45 </script> 18 </script>
46 </body> 19 </body>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/navigatorconnect/connect-from-worker.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698