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

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: add layout test for receiver.connectionList 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..f583269de1928cb461f416b9a1b440e7097d6a93 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(str_url, id) {
+ var mojo_url = new url.Url();
mark a. foltz 2017/02/21 17:47:38 s/var/const/ here and below. Also, Javascript var
zhaobin 2017/02/21 19:11:38 Done.
+ mojo_url.url = str_url;
+ var controller_connection_ptr = new presentationService.PresentationConnectionPtr();
+ var connectionBinding = new bindings.Binding(
+ presentationService.PresentationConnection,
+ new MockPresentationConnection(),
+ bindings.makeRequest(controller_connection_ptr));
+ var receiver_connection_ptr = new presentationService.PresentationConnectionPtr();
+
+ this.client_.onReceiverConnectionAvailable(
+ { url: mojo_url, id: id },
+ controller_connection_ptr,
+ bindings.makeRequest(receiver_connection_ptr));
+ }
}
return new PresentationServiceMock(mojo.frameInterfaces);

Powered by Google App Engine
This is Rietveld 408576698