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

Side by Side Diff: third_party/WebKit/LayoutTests/webshare/resources/mock-share-service.js

Issue 2571903003: Mojo JS bindings: switch most usage of "connection"/"router" module to "bindings". (Closed)
Patch Set: remove the changes to web_ui_mojo.js which seemed to cause flakiness. Created 3 years, 12 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
« no previous file with comments | « third_party/WebKit/LayoutTests/shapedetection/resources/mock-facedetection.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 'use strict'; 1 'use strict';
2 2
3 let mockShareService = loadMojoModules( 3 let mockShareService = loadMojoModules(
4 'mockShareService', 4 'mockShareService',
5 ['mojo/public/js/router', 5 ['mojo/public/js/bindings',
6 'third_party/WebKit/public/platform/modules/webshare/webshare.mojom', 6 'third_party/WebKit/public/platform/modules/webshare/webshare.mojom',
7 ]).then(mojo => { 7 ]).then(mojo => {
8 let [router, webshare] = mojo.modules; 8 let [bindings, webshare] = mojo.modules;
9 9
10 class MockShareService extends webshare.ShareService.stubClass { 10 class MockShareService {
11 constructor(interfaceProvider) { 11 constructor(interfaceProvider) {
12 super(); 12 this.bindingSet_ = new bindings.BindingSet(webshare.ShareService);
13
13 interfaceProvider.addInterfaceOverrideForTesting( 14 interfaceProvider.addInterfaceOverrideForTesting(
14 webshare.ShareService.name, 15 webshare.ShareService.name,
15 handle => this.connect_(handle)); 16 handle => this.bindingSet_.addBinding(this, handle));
16 } 17 }
17 18
18 // Returns a Promise that gets rejected if the test should fail. 19 // Returns a Promise that gets rejected if the test should fail.
19 init_() { 20 init_() {
20 // sequence of [expectedTitle, expectedText, result]. 21 // sequence of [expectedTitle, expectedText, result].
21 this.shareResultQueue_ = []; 22 this.shareResultQueue_ = [];
22 23
23 return new Promise((resolve, reject) => {this.reject_ = reject}); 24 return new Promise((resolve, reject) => {this.reject_ = reject});
24 } 25 }
25 26
26 connect_(handle) {
27 this.router_ = new router.Router(handle);
28 this.router_.setIncomingReceiver(this);
29 }
30
31 share(title, text, url) { 27 share(title, text, url) {
32 let callback = null; 28 let callback = null;
33 let result = new Promise(resolve => {callback = resolve;}); 29 let result = new Promise(resolve => {callback = resolve;});
34 30
35 if (!this.shareResultQueue_.length) { 31 if (!this.shareResultQueue_.length) {
36 this.reject_('Unexpected call to mojo share method'); 32 this.reject_('Unexpected call to mojo share method');
37 return result; 33 return result;
38 } 34 }
39 35
40 let [expectedTitle, expectedText, expectedUrl, error] = 36 let [expectedTitle, expectedText, expectedUrl, error] =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return new Promise(resolve => { 68 return new Promise(resolve => {
73 function onKeyPress() { 69 function onKeyPress() {
74 document.removeEventListener('keypress', onKeyPress, false); 70 document.removeEventListener('keypress', onKeyPress, false);
75 resolve(functionCalledOnKeyPress()); 71 resolve(functionCalledOnKeyPress());
76 } 72 }
77 document.addEventListener('keypress', onKeyPress, false); 73 document.addEventListener('keypress', onKeyPress, false);
78 74
79 eventSender.keyDown(' ', []); 75 eventSender.keyDown(' ', []);
80 }); 76 });
81 } 77 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/shapedetection/resources/mock-facedetection.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698