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

Side by Side Diff: LayoutTests/http/tests/navigatorconnect/connect-from-worker.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
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 web worker. 4 a web worker.
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 sw_scope = 'resources/service-worker-scope' + window.location.pathname; 14 var sw_scope = 'resources/service-worker-scope' + window.location.pathname;
14 15
15 // Method that behaves similarly to navigator.connect, but the actual connect
16 // call is made from a worker.
17 function connect_from_worker(t, service) {
18 // |service| is a relative URL, but for this to work from the worker it needs
19 // an absolute URL.
20 var target_url = location.origin + base_path() + service;
21 var worker = new Worker('resources/connect-helper.js');
22 var channel = new MessageChannel();
23 worker.postMessage
24 ({connect: target_url, port: channel.port2}, [channel.port2]);
25 return new Promise(function(resolve, reject) {
26 var got_reply = false;
27 channel.port1.onmessage = t.step_func(function(event) {
28 assert_false(got_reply);
29 assert_true('success' in event.data);
30 assert_true('result' in event.data);
31 got_reply = true;
32 if (event.data.success)
33 resolve(event.data.result);
34 else
35 reject(event.data.result);
36 });
37 });
38 }
39
40 run_connect_tests(connect_from_worker); 16 run_connect_tests(connect_from_worker);
41 </script> 17 </script>
42 </body> 18 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698