| 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 ff8f03ebc150f3917f11acdef311b02fd0f01446..f9dcca236cb27840b1cf5d32dc95a36fee2c5147 100644
|
| --- a/third_party/WebKit/LayoutTests/nfc/resources/nfc-helpers.js
|
| +++ b/third_party/WebKit/LayoutTests/nfc/resources/nfc-helpers.js
|
| @@ -70,8 +70,9 @@
|
| function nfc_mocks(mojo) {
|
| return define('NFC mocks', [
|
| 'mojo/public/js/bindings',
|
| + 'mojo/public/js/connection',
|
| 'device/nfc/nfc.mojom',
|
| - ], (bindings, nfc) => {
|
| + ], (bindings, connection, nfc) => {
|
|
|
| function toMojoNFCRecordType(type) {
|
| switch (type) {
|
| @@ -258,8 +259,6 @@
|
|
|
| class MockNFC {
|
| constructor() {
|
| - this.bindingSet = new bindings.BindingSet(nfc.NFC);
|
| -
|
| this.hw_status_ = NFCHWStatus.ENABLED;
|
| this.pushed_message_ = null;
|
| this.push_options_ = null;
|
| @@ -271,7 +270,7 @@
|
| this.watchers_ = [];
|
| }
|
|
|
| - // NFC delegate functions
|
| + // NFC.stubClass delegate functions
|
| push(message, options) {
|
| let error = this.isReady();
|
| if (error)
|
| @@ -339,6 +338,14 @@
|
| 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);
|
| @@ -401,8 +408,8 @@
|
| let mockNFC = new MockNFC;
|
| mojo.frameInterfaces.addInterfaceOverrideForTesting(
|
| nfc.NFC.name,
|
| - handle => {
|
| - mockNFC.bindingSet.addBinding(mockNFC, handle);
|
| + pipe => {
|
| + mockNFC.bindToPipe(pipe);
|
| });
|
|
|
| return Promise.resolve({
|
|
|