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

Side by Side Diff: extensions/test/data/api_test/usb/remove_event/background.js

Issue 800963005: Add browser tests for USB device add/remove events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjusted JavaScript style. Created 5 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var known_devices = {}; 5 var known_devices = {};
6 6
7 chrome.hid.onDeviceRemoved.addListener(function (deviceId) { 7 chrome.usb.onDeviceRemoved.addListener(function(device) {
8 if (deviceId in known_devices) { 8 if (device.device in known_devices) {
9 chrome.test.sendMessage("success"); 9 chrome.test.sendMessage("success");
10 } else { 10 } else {
11 console.error("Unexpected device removed: " + device.deviceId); 11 console.error("Unexpected device removed: " + device.device);
12 chrome.test.sendMessage("failure"); 12 chrome.test.sendMessage("failure");
13 } 13 }
14 }); 14 });
15 15
16 chrome.hid.getDevices({}, function (devices) { 16 chrome.usb.getDevices({}, function(devices) {
17 for (var device of devices) { 17 for (var device of devices) {
18 known_devices[device.deviceId] = device; 18 known_devices[device.device] = device;
19 } 19 }
20 chrome.test.sendMessage("loaded"); 20 chrome.test.sendMessage("loaded");
21 }); 21 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698