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

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

Issue 2655073007: Revert of [Presentation API] Allow PresentationConnection state change to "Connecting" (Closed)
Patch Set: Created 3 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 /* 1 /*
2 * Mock implementation of mojo PresentationService. 2 * Mock implementation of mojo PresentationService.
3 */ 3 */
4 4
5 "use strict"; 5 "use strict";
6 6
7 const presentationServiceMock = 7 let presentationServiceMock = loadMojoModules(
8 loadMojoModules('presentationServiceMock', [ 8 'presentationServiceMock',
9 [
9 'third_party/WebKit/public/platform/modules/presentation/presentation.mojo m', 10 'third_party/WebKit/public/platform/modules/presentation/presentation.mojo m',
10 'mojo/public/js/bindings', 11 'mojo/public/js/bindings',
11 ]).then(mojo => { 12 ]).then(mojo => {
12 const [presentationService, bindings] = mojo.modules; 13 let [ presentationService, bindings ] = mojo.modules;
13 14
14 class PresentationServiceMock { 15 class PresentationServiceMock {
15 constructor(interfaceProvider) { 16 constructor(interfaceProvider) {
16 interfaceProvider.addInterfaceOverrideForTesting( 17 interfaceProvider.addInterfaceOverrideForTesting(
17 presentationService.PresentationService.name, 18 presentationService.PresentationService.name,
18 handle => this.bindingSet_.addBinding(this, handle)); 19 handle => this.bindingSet_.addBinding(this, handle));
19 this.interfaceProvider_ = interfaceProvider; 20 this.interfaceProvider_ = interfaceProvider;
20 this.pendingResponse_ = null; 21 this.pendingResponse_ = null;
21 this.bindingSet_ = new bindings.BindingSet( 22 this.bindingSet_ = new bindings.BindingSet(
22 presentationService.PresentationService); 23 presentationService.PresentationService);
23 } 24 }
24 25
25 setClient(client) { this.client_ = client; }
26
27 startSession(urls) { 26 startSession(urls) {
28 return Promise.resolve({ 27 return Promise.resolve({
29 sessionInfo: { url: urls[0], id: 'fakesession' }, 28 sessionInfo: { url: urls[0], id: 'fakesession' },
30 error: null, 29 error: null,
31 }); 30 });
32 } 31 }
33 32
34 joinSession(urls) { 33 joinSession(urls) {
35 return Promise.resolve({ 34 return Promise.resolve({
36 sessionInfo: { url: urls[0], id: 'fakeSessionId' }, 35 sessionInfo: { url: urls[0], id: 'fakeSessionId' },
37 error: null, 36 error: null,
38 }); 37 });
39 } 38 }
40
41 closeConnection(url, id) {
42 this.client_.onConnectionClosed(
43 {url: url, id: id},
44 presentationService.PresentationConnectionCloseReason.CLOSED, '');
45 }
46 } 39 }
47 40
48 return new PresentationServiceMock(mojo.frameInterfaces); 41 return new PresentationServiceMock(mojo.frameInterfaces);
49 }); 42 });
50 43
51 function waitForClick(callback, button) { 44 function waitForClick(callback, button) {
52 button.addEventListener('click', callback, { once: true }); 45 button.addEventListener('click', callback, { once: true });
53 46
54 if (!('eventSender' in window)) 47 if (!('eventSender' in window))
55 return; 48 return;
56 49
57 const boundingRect = button.getBoundingClientRect(); 50 var boundingRect = button.getBoundingClientRect();
58 const x = boundingRect.left + boundingRect.width / 2; 51 var x = boundingRect.left + boundingRect.width / 2;
59 const y = boundingRect.top + boundingRect.height / 2; 52 var y = boundingRect.top + boundingRect.height / 2;
60 53
61 eventSender.mouseMoveTo(x, y); 54 eventSender.mouseMoveTo(x, y);
62 eventSender.mouseDown(); 55 eventSender.mouseDown();
63 eventSender.mouseUp(); 56 eventSender.mouseUp();
64 } 57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698