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

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

Issue 1754543003: Add WebUSB layout tests for device disconnection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
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);
}

Powered by Google App Engine
This is Rietveld 408576698