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

Unified Diff: third_party/WebKit/LayoutTests/usb/resources/webusb-test.js

Issue 2831223003: Move the onclose event handler to the FakeUSBDevice object (Closed)
Patch Set: Rebased Created 3 years, 8 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/usb/usbDevice-iframe.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/usb/resources/webusb-test.js
diff --git a/third_party/WebKit/LayoutTests/usb/resources/webusb-test.js b/third_party/WebKit/LayoutTests/usb/resources/webusb-test.js
index 77afd9973fea812ae17239b35b6d8af4b7f19dda..66acc93efce4d85ec6e88a5ea1adb9a62c19b2ed 100644
--- a/third_party/WebKit/LayoutTests/usb/resources/webusb-test.js
+++ b/third_party/WebKit/LayoutTests/usb/resources/webusb-test.js
@@ -14,8 +14,6 @@ let mojo = null;
let g_initializePromise = null;
let g_chooserService = null;
let g_deviceManager = null;
-let g_closeListener = null;
-let g_nextGuid = 0;
function fakeDeviceInitToDeviceInfo(guid, init) {
let deviceInfo = {
@@ -349,8 +347,8 @@ class FakeDeviceManager {
let binding = new mojo.bindings.Binding(
mojo.device.UsbDevice, new FakeDevice(device.info), request);
binding.setConnectionErrorHandler(() => {
- if (g_closeListener)
- g_closeListener(device.fakeDevice);
+ if (device.fakeDevice.onclose)
+ device.fakeDevice.onclose();
});
device.bindingArray.push(binding);
} else {
@@ -394,6 +392,10 @@ class FakeChooserService {
// Unlike FakeDevice this class is exported to callers of USBTest.addFakeDevice.
class FakeUSBDevice {
+ constructor() {
+ this.onclose = null;
+ }
+
disconnect() {
setTimeout(() => g_deviceManager.removeDevice(this), 0);
}
@@ -485,10 +487,6 @@ class USBTest {
return fakeDevice;
}
- set ondeviceclose(func) {
- g_closeListener = func;
- }
-
set chosenDevice(fakeDevice) {
if (!g_chooserService)
throw new Error('Call initialize() before setting chosenDevice.');
@@ -509,7 +507,6 @@ class USBTest {
g_deviceManager.removeAllDevices();
g_chooserService.setChosenDevice(null);
- g_closeListener = null;
}
}
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/usb/usbDevice-iframe.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698