Bug 1447862 [wpt PR 10130] - Make BlueTooth/USB requestDevice non-consuming., a=testonly
authorMustaq Ahmed <mustaq@google.com>
Mon, 09 Apr 2018 22:27:51 +0000
changeset 413729 21f189e1f5c9894fda096f7ad04b180c39ae47fa
parent 413728 1729ff1996d7ec2fa37729e591edf7950ccedaf1
child 413730 f1e731ebb6bb0614bb31f287112ef2c320925a25
push id102161
push userjames@hoppipolla.co.uk
push dateSun, 15 Apr 2018 09:10:16 +0000
treeherdermozilla-inbound@ebfad4be630d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1447862, 10130, 786407, 775866, 548768
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1447862 [wpt PR 10130] - Make BlueTooth/USB requestDevice non-consuming., a=testonly Automatic update from web-platform-testsMake BlueTooth/USB requestDevice non-consuming. The specs for both WebBlueTooth & WebUSB only require a user activation during a requestDevice call. So consuming the activation (vs just checking) is not a strong requirement. There was a concern that "not consuming" could possibly mean multiple choosers for a single user activation but our browser code already handles the situation gracefully. Multiple requests to browser is possible from different tabs anyway, even with (isolated) consumptions in individual tabs. Therefore it makes sense to remove the consumption behavior here, which is not spec-ed anyway. This would fit our goal of a simple user activation model ("UserActivationV2" project) which should be simple enough for cross-browser implementation and for a complete spec. Bug: 786407 Change-Id: I3c9dbf43df34d4cb4a2a33214a6c44847fa7435b Reviewed-on: https://chromium-review.googlesource.com/775866 Reviewed-by: Reilly Grant <reillyg@chromium.org> Reviewed-by: Giovanni Ortuño Urquidi <ortuno@chromium.org> Commit-Queue: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/master@{#548768} wpt-commits: 6ba01ea2ffbafbb329352628b244815654b38156 wpt-pr: 10130 wpt-commits: 6ba01ea2ffbafbb329352628b244815654b38156 wpt-pr: 10130
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/bluetooth/requestDevice/consumes-user-gesture.https.html
testing/web-platform/tests/bluetooth/requestDevice/doesnt-consume-user-gesture.https.html
testing/web-platform/tests/webusb/usb.https.html
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -308527,40 +308527,40 @@
    "bluetooth/requestDevice/canonicalizeFilter/wrong-service-in-services-member.https.html": [
     [
      "/bluetooth/requestDevice/canonicalizeFilter/wrong-service-in-services-member.https.html",
      {
       "testdriver": true
      }
     ]
    ],
-   "bluetooth/requestDevice/consumes-user-gesture.https.html": [
-    [
-     "/bluetooth/requestDevice/consumes-user-gesture.https.html",
-     {
-      "testdriver": true
-     }
-    ]
-   ],
    "bluetooth/requestDevice/cross-origin-iframe.sub.https.html": [
     [
      "/bluetooth/requestDevice/cross-origin-iframe.sub.https.html",
      {
       "testdriver": true
      }
     ]
    ],
    "bluetooth/requestDevice/discovery-succeeds.https.html": [
     [
      "/bluetooth/requestDevice/discovery-succeeds.https.html",
      {
       "testdriver": true
      }
     ]
    ],
+   "bluetooth/requestDevice/doesnt-consume-user-gesture.https.html": [
+    [
+     "/bluetooth/requestDevice/doesnt-consume-user-gesture.https.html",
+     {
+      "testdriver": true
+     }
+    ]
+   ],
    "bluetooth/requestDevice/filter-matches.https.html": [
     [
      "/bluetooth/requestDevice/filter-matches.https.html",
      {
       "testdriver": true
      }
     ]
    ],
@@ -403326,28 +403326,28 @@
   "bluetooth/requestDevice/canonicalizeFilter/wrong-service-in-optionalServices-member.https.html": [
    "4e8728f88844525f7fb95680499fc2024f74482c",
    "testharness"
   ],
   "bluetooth/requestDevice/canonicalizeFilter/wrong-service-in-services-member.https.html": [
    "084ec334261ed7c584a0888ff3dfdec0f3538bad",
    "testharness"
   ],
-  "bluetooth/requestDevice/consumes-user-gesture.https.html": [
-   "c76d7e37417a7db3043b761989eebbfded6e6804",
-   "testharness"
-  ],
   "bluetooth/requestDevice/cross-origin-iframe.sub.https.html": [
    "e5e22c1b7811699bb8bfd2b6593edf78a270a658",
    "testharness"
   ],
   "bluetooth/requestDevice/discovery-succeeds.https.html": [
    "0b75576a4742cc7496a890b273f2bb1c1f56017c",
    "testharness"
   ],
+  "bluetooth/requestDevice/doesnt-consume-user-gesture.https.html": [
+   "f7dfed31210d9e498648a3063313cb804a9a6879",
+   "testharness"
+  ],
   "bluetooth/requestDevice/filter-matches.https.html": [
    "22ea4176f1f5cdd67a730cce43e3fbf08d1fcfdb",
    "testharness"
   ],
   "bluetooth/requestDevice/le-not-supported.https.html": [
    "9870420cf924559cb02144ecd5da02d39f386f30",
    "testharness"
   ],
@@ -607227,17 +607227,17 @@
    "414b0b8087cbfa333e205a7b42d838c5f8108cf7",
    "testharness"
   ],
   "webusb/usb-disabled-by-feature-policy.https.sub.html.headers": [
    "7cc713de57caf823d0f778d943d6e7bb3900fb1e",
    "support"
   ],
   "webusb/usb.https.html": [
-   "47adf57ef06190594f80d8ae85d2ee8118889cb6",
+   "47be065f386fecc7557993c6d8ec61cac88fe71a",
    "testharness"
   ],
   "webusb/usbConnectionEvent.https.html": [
    "b350ec95c8dfc96783b80d4914b932eeecbe00a1",
    "testharness"
   ],
   "webusb/usbDevice-iframe.https.html": [
    "d2c3f13551a4d3b58e155aec01fb19f6fade5073",
deleted file mode 100644
--- a/testing/web-platform/tests/bluetooth/requestDevice/consumes-user-gesture.https.html
+++ /dev/null
@@ -1,27 +0,0 @@
-<!DOCTYPE html>
-<script src="/resources/testharness.js"></script>
-<script src="/resources/testharnessreport.js"></script>
-<script src="/resources/testdriver.js"></script>
-<script src="/resources/testdriver-vendor.js"></script>
-<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
-<script>
-'use strict';
-const test_desc = 'Consumes a user gesture.';
-const expected = new DOMException(
-    'Must be handling a user gesture to show a permission request.',
-    'SecurityError');
-
-bluetooth_test(() => setUpHealthThermometerAndHeartRateDevices()
-    .then(() => callWithTrustedClick(() => {
-      let first = navigator.bluetooth.requestDevice({
-        filters: [{services: ['heart_rate']}]});
-      let second = navigator.bluetooth.requestDevice({
-        filters: [{services: ['heart_rate']}]});
-      return Promise.all([
-        first.then(device => assert_equals(
-          device.constructor.name, 'BluetoothDevice')),
-        assert_promise_rejects_with_message(second,
-          expected, 'A request should consume a user gesture')
-      ]);
-    })), test_desc);
-</script>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/bluetooth/requestDevice/doesnt-consume-user-gesture.https.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/bluetooth/resources/bluetooth-helpers.js"></script>
+<script>
+'use strict';
+const test_desc = 'requestDevice calls do not consume user gestures.';
+
+bluetooth_test(() => setUpHealthThermometerAndHeartRateDevices()
+    .then(() => callWithTrustedClick(() => {
+      let first = navigator.bluetooth.requestDevice({
+        filters: [{services: ['heart_rate']}]});
+      let second = navigator.bluetooth.requestDevice({
+        filters: [{services: ['heart_rate']}]});
+      return Promise.all([
+        first.then(device => assert_equals(
+          device.constructor.name, 'BluetoothDevice')),
+        second.then(device => assert_equals(
+          device.constructor.name, 'BluetoothDevice')),
+      ]);
+    })), test_desc);
+</script>
--- a/testing/web-platform/tests/webusb/usb.https.html
+++ b/testing/web-platform/tests/webusb/usb.https.html
@@ -125,9 +125,29 @@ usb_test(usb => {
       return removedDevice.open().then(() => {
         assert_unreachable('should not be able to open a disconnected device');
       }, error => {
         assert_equals(error.code, DOMException.NOT_FOUND_ERR);
       });
     });
   });
 }, 'ondisconnect event is triggered by removing a device');
+
+usb_test(() => {
+  return getFakeDevice().then(({ device, fakeDevice }) => {
+    navigator.usb.test.onrequestdevice = event => {
+      event.respondWith(fakeDevice);
+    }
+    return callWithTrustedClick(() => {
+      let first = navigator.usb.requestDevice({ filters: [] });
+      let second = navigator.usb.requestDevice({ filters: [] });
+      return Promise.all([
+        first.then(chosenDevice => {
+          assert_equals(chosenDevice, device);
+        }),
+        second.then(chosenDevice => {
+          assert_equals(chosenDevice, device);
+        })
+      ]);
+    });
+  });
+}, 'multiple requestDevice calls are allowed per user activation');
 </script>