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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Geolocation/resources/geolocation-mock.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
OLDNEW
1 /* 1 /*
2 * geolocation-mock contains a mock implementation of GeolocationService and 2 * geolocation-mock contains a mock implementation of GeolocationService and
3 * PermissionService. 3 * PermissionService.
4 */ 4 */
5 5
6 "use strict"; 6 "use strict";
7 7
8 let geolocationServiceMock = loadMojoModules( 8 let geolocationServiceMock = loadMojoModules(
9 'geolocationServiceMock', 9 'geolocationServiceMock',
10 ['device/geolocation/public/interfaces/geolocation.mojom', 10 ['device/geolocation/public/interfaces/geolocation.mojom',
11 'third_party/WebKit/public/platform/modules/permissions/permission.mojom', 11 'third_party/WebKit/public/platform/modules/permissions/permission.mojom',
12 'third_party/WebKit/public/platform/modules/permissions/permission_status.m ojom', 12 'third_party/WebKit/public/platform/modules/permissions/permission_status.m ojom',
13 'mojo/public/js/router', 13 'mojo/public/js/bindings',
14 ]).then(mojo => { 14 ]).then(mojo => {
15 let [geolocation, permission, permissionStatus, router] = 15 let [geolocation, permission, permissionStatus, bindings] =
16 mojo.modules; 16 mojo.modules;
17 17
18 class GeolocationServiceMock { 18 class GeolocationServiceMock {
19 constructor(interfaceProvider) { 19 constructor(interfaceProvider) {
20 interfaceProvider.addInterfaceOverrideForTesting( 20 interfaceProvider.addInterfaceOverrideForTesting(
21 geolocation.GeolocationService.name, 21 geolocation.GeolocationService.name,
22 handle => this.connectGeolocation_(handle)); 22 handle => this.connectGeolocation_(handle));
23 23
24 interfaceProvider.addInterfaceOverrideForTesting( 24 interfaceProvider.addInterfaceOverrideForTesting(
25 permission.PermissionService.name, 25 permission.PermissionService.name,
(...skipping 18 matching lines...) Expand all
44 /** 44 /**
45 * The status to respond to permission requests with. If set to ASK, then 45 * The status to respond to permission requests with. If set to ASK, then
46 * permission requests will block until setGeolocationPermission is called 46 * permission requests will block until setGeolocationPermission is called
47 * to allow or deny permission requests. 47 * to allow or deny permission requests.
48 * 48 *
49 * @type {!permissionStatus.PermissionStatus} 49 * @type {!permissionStatus.PermissionStatus}
50 */ 50 */
51 this.permissionStatus_ = permissionStatus.PermissionStatus.ASK; 51 this.permissionStatus_ = permissionStatus.PermissionStatus.ASK;
52 this.rejectPermissionConnections_ = false; 52 this.rejectPermissionConnections_ = false;
53 this.rejectGeolocationConnections_ = false; 53 this.rejectGeolocationConnections_ = false;
54
55 this.geolocationBindingSet_ = new bindings.BindingSet(
56 geolocation.GeolocationService);
57 this.permissionBindingSet_ = new bindings.BindingSet(
58 permission.PermissionService);
54 } 59 }
55 60
56 connectGeolocation_(handle) { 61 connectGeolocation_(handle) {
57 if (this.rejectGeolocationConnections_) { 62 if (this.rejectGeolocationConnections_) {
58 mojo.core.close(handle); 63 mojo.core.close(handle);
59 return; 64 return;
60 } 65 }
61 this.geolocationStub_ = new geolocation.GeolocationService.stubClass( 66 this.geolocationBindingSet_.addBinding(this, handle);
62 this);
63 this.geolocationRouter_ = new router.Router(handle);
64 this.geolocationRouter_.setIncomingReceiver(this.geolocationStub_);
65 } 67 }
66 68
67 connectPermission_(handle) { 69 connectPermission_(handle) {
68 if (this.rejectPermissionConnections_) { 70 if (this.rejectPermissionConnections_) {
69 mojo.core.close(handle); 71 mojo.core.close(handle);
70 return; 72 return;
71 } 73 }
72 this.permissionStub_ = new permission.PermissionService.stubClass(this); 74 this.permissionBindingSet_.addBinding(this, handle);
73 this.permissionRouter_ = new router.Router(handle);
74 this.permissionRouter_.setIncomingReceiver(this.permissionStub_);
75 } 75 }
76 76
77 setHighAccuracy(highAccuracy) { 77 setHighAccuracy(highAccuracy) {
78 // FIXME: We need to add some tests regarding "high accuracy" mode. 78 // FIXME: We need to add some tests regarding "high accuracy" mode.
79 // See https://bugs.webkit.org/show_bug.cgi?id=49438 79 // See https://bugs.webkit.org/show_bug.cgi?id=49438
80 } 80 }
81 81
82 /** 82 /**
83 * A mock implementation of GeolocationService.queryNextPosition(). This 83 * A mock implementation of GeolocationService.queryNextPosition(). This
84 * returns the position set by a call to setGeolocationPosition() or 84 * returns the position set by a call to setGeolocationPosition() or
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 setGeolocationPermission(allowed) { 177 setGeolocationPermission(allowed) {
178 this.permissionStatus_ = allowed ? 178 this.permissionStatus_ = allowed ?
179 permissionStatus.PermissionStatus.GRANTED : 179 permissionStatus.PermissionStatus.GRANTED :
180 permissionStatus.PermissionStatus.DENIED; 180 permissionStatus.PermissionStatus.DENIED;
181 this.runPermissionCallback_(); 181 this.runPermissionCallback_();
182 } 182 }
183 183
184 } 184 }
185 return new GeolocationServiceMock(mojo.frameInterfaces); 185 return new GeolocationServiceMock(mojo.frameInterfaces);
186 }); 186 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698