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

Side by Side Diff: third_party/WebKit/LayoutTests/harness-tests/mojo-helpers.html

Issue 1639233004: Revert of [mojo] Enable ServiceRegistryImpl to override remote services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-testing-3
Patch Set: 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="../resources/mojo-helpers.js"></script> 4 <script src="../resources/mojo-helpers.js"></script>
5 <script> 5 <script>
6 'use strict'; 6 'use strict';
7 7
8 // Verify that the mojo_test helper functions properly and Mojo bindings 8 // Verify that the mojo_test helper functions properly and Mojo bindings
9 // are available. 9 // are available.
10 mojo_test(mojo => { 10 mojo_test(mojo => {
11 assert_true(mojo instanceof Object); 11 assert_true(mojo instanceof Object);
12 assert_true(mojo.core instanceof Object); 12 assert_true(mojo.core instanceof Object);
13 assert_true(mojo.router instanceof Object); 13 assert_true(mojo.router instanceof Object);
14 assert_true(mojo.serviceRegistry instanceof Object); 14 assert_true(mojo.serviceRegistry instanceof Object);
15 }, 'Mojo system APIs should be available to layout tests.'); 15 }, 'Mojo system APIs should be available to layout tests.');
16
17 mojo_test(mojo => {
18 return new Promise(resolve => {
19 // Complete the test as soon as a request comes in for a Frobinator service.
20 mojo.serviceRegistry.addServiceOverrideForTesting('Frobinator', resolve);
21
22 // Try to connect to the browser's Frobinator service. This should be
23 // intercepted by the above override.
24 mojo.serviceRegistry.connectToService('Frobinator');
25 });
26 }, 'Service registry overrides should be properly intercepted.');
27
28 mojo_test(mojo => {
29 return new Promise(resolve => {
30 let TEST_REQUEST = new Uint8Array([42, 0, 2, 3, 5, 7, 11, 13, 17, 19, 23]);
31
32 mojo.serviceRegistry.addServiceOverrideForTesting('Frobinator', pipe => {
33 resolve(mojo_wait_for_incoming_message(mojo, pipe)
34 .then(message => {
35 assert_array_equals(new Uint8Array(message.buffer), TEST_REQUEST);
36 assert_array_equals(message.handles, []);
37 }));
38 });
39
40 let pipe = mojo.serviceRegistry.connectToService('Frobinator');
41 assert_equals(mojo.core.writeMessage(pipe, TEST_REQUEST, [], 0),
42 mojo.core.RESULT_OK);
43 });
44 }, 'Mock services can receive messages from test code.');
45
46 mojo_test(mojo => {
47 let TEST_REQUEST = new Uint8Array([1, 2, 3, 4, 5]);
48 let EXPECTED_RESPONSE = new Uint8Array([5, 4, 3, 2, 1]);
49
50 // Mock service should respond to any message with its reverse.
51 mojo.serviceRegistry.addServiceOverrideForTesting('Reversinator', pipe => {
52 mojo_wait_for_incoming_message(mojo, pipe)
53 .then(message => {
54 let response = new Uint8Array(message.buffer);
55 response.reverse();
56 assert_equals(mojo.core.writeMessage(pipe, response, [], 0),
57 mojo.core.RESULT_OK);
58 });
59 });
60
61 let pipe = mojo.serviceRegistry.connectToService('Reversinator');
62 assert_equals(mojo.core.writeMessage(pipe, TEST_REQUEST, [], 0),
63 mojo.core.RESULT_OK);
64
65 return mojo_wait_for_incoming_message(mojo, pipe)
66 .then(response => {
67 assert_array_equals(new Uint8Array(response.buffer), EXPECTED_RESPONSE);
68 assert_array_equals(response.handles, []);
69 });
70 }, 'Test code can receive response messages from mock services.');
71 </script> 16 </script>
OLDNEW
« no previous file with comments | « content/renderer/mojo/service_registry_js_wrapper.cc ('k') | third_party/WebKit/LayoutTests/resources/mojo-helpers.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698