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

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

Issue 2590393002: Revert of Mojo JS bindings: switch most usage of "connection"/"router" module to "bindings". (Closed)
Patch Set: Created 4 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 | « 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/bindings', 5 ['mojo/public/js/router',
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 [bindings, webshare] = mojo.modules; 8 let [router, webshare] = mojo.modules;
9 9
10 class MockShareService { 10 class MockShareService extends webshare.ShareService.stubClass {
11 constructor(interfaceProvider) { 11 constructor(interfaceProvider) {
12 this.bindingSet_ = new bindings.BindingSet(webshare.ShareService); 12 super();
13
14 interfaceProvider.addInterfaceOverrideForTesting( 13 interfaceProvider.addInterfaceOverrideForTesting(
15 webshare.ShareService.name, 14 webshare.ShareService.name,
16 handle => this.bindingSet_.addBinding(this, handle)); 15 handle => this.connect_(handle));
17 } 16 }
18 17
19 // Returns a Promise that gets rejected if the test should fail. 18 // Returns a Promise that gets rejected if the test should fail.
20 init_() { 19 init_() {
21 // sequence of [expectedTitle, expectedText, result]. 20 // sequence of [expectedTitle, expectedText, result].
22 this.shareResultQueue_ = []; 21 this.shareResultQueue_ = [];
23 22
24 return new Promise((resolve, reject) => {this.reject_ = reject}); 23 return new Promise((resolve, reject) => {this.reject_ = reject});
25 } 24 }
26 25
26 connect_(handle) {
27 this.router_ = new router.Router(handle);
28 this.router_.setIncomingReceiver(this);
29 }
30
27 share(title, text, url) { 31 share(title, text, url) {
28 let callback = null; 32 let callback = null;
29 let result = new Promise(resolve => {callback = resolve;}); 33 let result = new Promise(resolve => {callback = resolve;});
30 34
31 if (!this.shareResultQueue_.length) { 35 if (!this.shareResultQueue_.length) {
32 this.reject_('Unexpected call to mojo share method'); 36 this.reject_('Unexpected call to mojo share method');
33 return result; 37 return result;
34 } 38 }
35 39
36 let [expectedTitle, expectedText, expectedUrl, error] = 40 let [expectedTitle, expectedText, expectedUrl, error] =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 return new Promise(resolve => { 72 return new Promise(resolve => {
69 function onKeyPress() { 73 function onKeyPress() {
70 document.removeEventListener('keypress', onKeyPress, false); 74 document.removeEventListener('keypress', onKeyPress, false);
71 resolve(functionCalledOnKeyPress()); 75 resolve(functionCalledOnKeyPress());
72 } 76 }
73 document.addEventListener('keypress', onKeyPress, false); 77 document.addEventListener('keypress', onKeyPress, false);
74 78
75 eventSender.keyDown(' ', []); 79 eventSender.keyDown(' ', []);
76 }); 80 });
77 } 81 }
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