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

Unified Diff: third_party/WebKit/LayoutTests/nfc/resources/nfc-helpers.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 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/nfc/resources/nfc-helpers.js
diff --git a/third_party/WebKit/LayoutTests/nfc/resources/nfc-helpers.js b/third_party/WebKit/LayoutTests/nfc/resources/nfc-helpers.js
index f9dcca236cb27840b1cf5d32dc95a36fee2c5147..ff8f03ebc150f3917f11acdef311b02fd0f01446 100644
--- a/third_party/WebKit/LayoutTests/nfc/resources/nfc-helpers.js
+++ b/third_party/WebKit/LayoutTests/nfc/resources/nfc-helpers.js
@@ -70,9 +70,8 @@ function createUrlRecord(url) {
function nfc_mocks(mojo) {
return define('NFC mocks', [
'mojo/public/js/bindings',
- 'mojo/public/js/connection',
'device/nfc/nfc.mojom',
- ], (bindings, connection, nfc) => {
+ ], (bindings, nfc) => {
function toMojoNFCRecordType(type) {
switch (type) {
@@ -259,6 +258,8 @@ function nfc_mocks(mojo) {
class MockNFC {
constructor() {
+ this.bindingSet = new bindings.BindingSet(nfc.NFC);
+
this.hw_status_ = NFCHWStatus.ENABLED;
this.pushed_message_ = null;
this.push_options_ = null;
@@ -270,7 +271,7 @@ function nfc_mocks(mojo) {
this.watchers_ = [];
}
- // NFC.stubClass delegate functions
+ // NFC delegate functions
push(message, options) {
let error = this.isReady();
if (error)
@@ -338,14 +339,6 @@ function nfc_mocks(mojo) {
return Promise.resolve(createNFCError(null));
}
-
- // Mock utility functions
- bindToPipe(pipe) {
- this.stub_ = connection.bindHandleToStub(
- pipe, nfc.NFC);
- bindings.StubBindings(this.stub_).delegate = this;
- }
-
isReady() {
if (this.hw_status_ === NFCHWStatus.DISABLED)
return createNFCError(nfc.NFCErrorType.DEVICE_DISABLED);
@@ -408,8 +401,8 @@ function nfc_mocks(mojo) {
let mockNFC = new MockNFC;
mojo.frameInterfaces.addInterfaceOverrideForTesting(
nfc.NFC.name,
- pipe => {
- mockNFC.bindToPipe(pipe);
+ handle => {
+ mockNFC.bindingSet.addBinding(mockNFC, handle);
});
return Promise.resolve({

Powered by Google App Engine
This is Rietveld 408576698