Index: third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js |
diff --git a/third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js b/third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js |
index 4ea82a82f85afdf09ba9efc55d07332c696157d0..8d1a1b12eb300a1d4b030edc1465ace044d45d64 100644 |
--- a/third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js |
+++ b/third_party/WebKit/LayoutTests/usb/resources/usb-helpers.js |
@@ -371,7 +371,12 @@ function usbMocks(mojo) { |
getDevice(guid, pipe) { |
let device = this.mockDevices_.get(guid); |
- if (device !== undefined) { |
+ if (device === undefined) { |
+ // In C++ this happens automatically if the pipe is not bound to a |
+ // new device but must be explicit in JavaScript to avoid dependency |
+ // on GC timing. |
+ mojo.core.close(pipe); |
Ken Rockot(use gerrit already)
2016/03/02 01:54:19
nit: I'm not sure this comment belongs here. It's
Reilly Grant (use Gerrit)
2016/03/02 19:13:26
Agreed.
|
+ } else { |
var mock = new MockDevice(device.info, pipe); |
device.handles.push(mock); |
} |