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

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

Issue 2706453002: [Presentation API] return valid WebPresentationConnection object in PresentationReceiver (Closed)
Patch Set: resolve code review comments from Derek 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/presentation/resources/presentation-service-mock.js
diff --git a/third_party/WebKit/LayoutTests/presentation/resources/presentation-service-mock.js b/third_party/WebKit/LayoutTests/presentation/resources/presentation-service-mock.js
index 3db3d1ea3ca4bddcb83bb9f1701627cd94f5f5a6..15007fe7f8f7b0243d2dc677a155025db995b5e7 100644
--- a/third_party/WebKit/LayoutTests/presentation/resources/presentation-service-mock.js
+++ b/third_party/WebKit/LayoutTests/presentation/resources/presentation-service-mock.js
@@ -8,9 +8,13 @@ let presentationServiceMock = loadMojoModules(
'presentationServiceMock',
[
'third_party/WebKit/public/platform/modules/presentation/presentation.mojom',
+ 'url/mojo/url.mojom',
'mojo/public/js/bindings',
]).then(mojo => {
- let [ presentationService, bindings ] = mojo.modules;
+ let [ presentationService, url, bindings ] = mojo.modules;
+
+ class MockPresentationConnection {
+ };
class PresentationServiceMock {
constructor(interfaceProvider) {
@@ -23,6 +27,10 @@ let presentationServiceMock = loadMojoModules(
presentationService.PresentationService);
}
+ setClient(client) {
+ this.client_ = client;
+ }
+
startSession(urls) {
return Promise.resolve({
sessionInfo: { url: urls[0], id: 'fakesession' },
@@ -36,6 +44,22 @@ let presentationServiceMock = loadMojoModules(
error: null,
});
}
+
+ onReceiverConnectionAvailable(strUrl, id) {
+ const mojoUrl = new url.Url();
+ mojoUrl.url = strUrl;
+ const controllerConnectionPtr = new presentationService.PresentationConnectionPtr();
+ const connectionBinding = new bindings.Binding(
+ presentationService.PresentationConnection,
+ new MockPresentationConnection(),
+ bindings.makeRequest(controllerConnectionPtr));
+ const receiverConnectionPtr = new presentationService.PresentationConnectionPtr();
+
+ this.client_.onReceiverConnectionAvailable(
+ { url: mojoUrl, id: id },
+ controllerConnectionPtr,
+ bindings.makeRequest(receiverConnectionPtr));
+ }
}
return new PresentationServiceMock(mojo.frameInterfaces);
@@ -47,9 +71,9 @@ function waitForClick(callback, button) {
if (!('eventSender' in window))
return;
- var boundingRect = button.getBoundingClientRect();
- var x = boundingRect.left + boundingRect.width / 2;
- var y = boundingRect.top + boundingRect.height / 2;
+ const boundingRect = button.getBoundingClientRect();
+ const x = boundingRect.left + boundingRect.width / 2;
+ const y = boundingRect.top + boundingRect.height / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();

Powered by Google App Engine
This is Rietveld 408576698