From 042ab47e788e4f69a1058917faa272cb6046cecd Mon Sep 17 00:00:00 2001 From: Reilly Grant Date: Wed, 18 Jul 2018 19:03:38 -0700 Subject: [PATCH] Add [SecureContext] to additional WebUSB interfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change updates the WebUSB WebIDL files to match the recently merged spec pull request #142 by hiding interfaces which aren't useful in insecure contexts. Change-Id: I98625b2634e452c775601525300672d9440ddbcc Reviewed-on: https://chromium-review.googlesource.com/1137435 Commit-Queue: Reilly Grant Reviewed-by: Kentaro Hara Reviewed-by: Philip Jägenstedt Cr-Commit-Position: refs/heads/master@{#576316} --- webusb/insecure-context.any.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 webusb/insecure-context.any.js diff --git a/webusb/insecure-context.any.js b/webusb/insecure-context.any.js new file mode 100644 index 00000000000000..42452b532e9acd --- /dev/null +++ b/webusb/insecure-context.any.js @@ -0,0 +1,22 @@ +// META: global=sharedworker +'use strict'; + +test(() => { + assert_false(isSecureContext); + assert_false('usb' in navigator); +}, '"usb" should not be present on navigator in an insecure context.'); + +[ + 'USB', 'USBAlternateInterface', 'USBConfiguration', 'USBConnectionEvent', + 'USBDevice', 'USBEndpoint', 'USBInterface', 'USBInTransferResult', + 'USBOutTransferResult', 'USBIsochronousInTransferResult', + 'USBIsochronousOutTransferResult', 'USBIsochronousInTransferPacket', + 'USBIsochronousOutTransferPacket', +].forEach((symbol) => { + test(() => { + assert_false(isSecureContext); + assert_false(symbol in this) + }, '"' + symbol + '" should not be visible in an insecure context.'); +}); + +done();