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

Side by Side Diff: third_party/WebKit/LayoutTests/bluetooth/requestDevice.html

Issue 1601323002: Use GetLastCommittedOrigin instead of GetLastCommittedURL in bluetooth chooser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed bluetooth test at: requestDevice.html Created 4 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharness-helpers.js"></script> 3 <script src="../resources/testharness-helpers.js"></script>
4 <script src="../resources/testharnessreport.js"></script> 4 <script src="../resources/testharnessreport.js"></script>
5 <script src="resources/bluetooth-helpers.js"></script> 5 <script src="resources/bluetooth-helpers.js"></script>
6 <script> 6 <script>
7 'use strict'; 7 'use strict';
8 8
9 test(t => { assert_true(window.testRunner instanceof Object); t.done(); }, 9 test(t => { assert_true(window.testRunner instanceof Object); t.done(); },
10 'window.testRunner is required for the following tests.'); 10 'window.testRunner is required for the following tests.');
11 11
12 promise_test(() => { 12 promise_test(() => {
13 testRunner.setBluetoothMockDataSet('FailStartDiscoveryAdapter'); 13 testRunner.setBluetoothMockDataSet('FailStartDiscoveryAdapter');
14 testRunner.setBluetoothManualChooser(); 14 testRunner.setBluetoothManualChooser();
15 let requestDevicePromise = 15 let requestDevicePromise =
16 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}); 16 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]});
17 return getBluetoothManualChooserEvents(3) 17 return getBluetoothManualChooserEvents(3)
18 .then(events => { 18 .then(events => {
19 assert_array_equals(events, 19 assert_array_equals(events,
20 ['chooser-opened(file:///)', 20 ['chooser-opened(file://)',
21 'discovering', 21 'discovering',
22 'discovery-failed-to-start'], 22 'discovery-failed-to-start'],
23 events); 23 events);
24 testRunner.sendBluetoothManualChooserEvent('cancelled', ''); 24 testRunner.sendBluetoothManualChooserEvent('cancelled', '');
25 return assert_promise_rejects_with_message( 25 return assert_promise_rejects_with_message(
26 requestDevicePromise, 26 requestDevicePromise,
27 new DOMException('User cancelled the requestDevice() chooser.', 27 new DOMException('User cancelled the requestDevice() chooser.',
28 'NotFoundError'), 28 'NotFoundError'),
29 'The adapter failed to start a discovery session.'); 29 'The adapter failed to start a discovery session.');
30 }); 30 });
31 }, 'Discovery session fails to start.'); 31 }, 'Discovery session fails to start.');
32 32
33 promise_test(() => { 33 promise_test(() => {
34 testRunner.setBluetoothMockDataSet('NotPresentAdapter'); 34 testRunner.setBluetoothMockDataSet('NotPresentAdapter');
35 return assert_promise_rejects_with_message( 35 return assert_promise_rejects_with_message(
36 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}), 36 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}),
37 new DOMException('Bluetooth adapter not available.', 'NotFoundError'), 37 new DOMException('Bluetooth adapter not available.', 'NotFoundError'),
38 'Bluetooth adapter is not present.'); 38 'Bluetooth adapter is not present.');
39 }, 'Reject with NotFoundError if the adapter is not present.'); 39 }, 'Reject with NotFoundError if the adapter is not present.');
40 40
41 promise_test(() => { 41 promise_test(() => {
42 testRunner.setBluetoothMockDataSet('NotPoweredAdapter'); 42 testRunner.setBluetoothMockDataSet('NotPoweredAdapter');
43 testRunner.setBluetoothManualChooser(); 43 testRunner.setBluetoothManualChooser();
44 let requestDevicePromise = 44 let requestDevicePromise =
45 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]}); 45 requestDeviceWithKeyDown({filters: [{services: ['generic_access']}]});
46 return getBluetoothManualChooserEvents(2) 46 return getBluetoothManualChooserEvents(2)
47 .then(events => { 47 .then(events => {
48 assert_array_equals(events, 48 assert_array_equals(events,
49 ['chooser-opened(file:///)', 49 ['chooser-opened(file://)',
50 'adapter-disabled'], 50 'adapter-disabled'],
51 events); 51 events);
52 testRunner.sendBluetoothManualChooserEvent('cancelled', ''); 52 testRunner.sendBluetoothManualChooserEvent('cancelled', '');
53 return assert_promise_rejects_with_message( 53 return assert_promise_rejects_with_message(
54 requestDevicePromise, 54 requestDevicePromise,
55 new DOMException('User cancelled the requestDevice() chooser.', 55 new DOMException('User cancelled the requestDevice() chooser.',
56 'NotFoundError'), 56 'NotFoundError'),
57 'Bluetooth adapter is not powered.'); 57 'Bluetooth adapter is not powered.');
58 }); 58 });
59 }, 'Reject with NotFoundError if the adapter is off.'); 59 }, 'Reject with NotFoundError if the adapter is off.');
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 promise_test(() => { 132 promise_test(() => {
133 testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter'); 133 testRunner.setBluetoothMockDataSet('GlucoseHeartRateAdapter');
134 testRunner.setBluetoothManualChooser(); 134 testRunner.setBluetoothManualChooser();
135 let requestDevicePromise = requestDeviceWithKeyDown({ 135 let requestDevicePromise = requestDeviceWithKeyDown({
136 filters: [{services: ['glucose']}, 136 filters: [{services: ['glucose']},
137 {services: ['heart_rate']}] 137 {services: ['heart_rate']}]
138 }); 138 });
139 return getBluetoothManualChooserEvents(5) 139 return getBluetoothManualChooserEvents(5)
140 .then(events => { 140 .then(events => {
141 assert_equals(events.length, 5, events); 141 assert_equals(events.length, 5, events);
142 assert_equals(events[0], 'chooser-opened(file:///)', 'events[0]'); 142 assert_equals(events[0], 'chooser-opened(file://)', 'events[0]');
143 let idsByName = new AddDeviceEventSet(); 143 let idsByName = new AddDeviceEventSet();
144 for (let addedDevice of [events[1], events[2]]) { 144 for (let addedDevice of [events[1], events[2]]) {
145 idsByName.assert_add_device_event(addedDevice); 145 idsByName.assert_add_device_event(addedDevice);
146 } 146 }
147 assert_true(idsByName.has('Heart Rate Device')); 147 assert_true(idsByName.has('Heart Rate Device'));
148 assert_true(idsByName.has('Glucose Device')); 148 assert_true(idsByName.has('Glucose Device'));
149 assert_equals(events[3], 'discovering'); 149 assert_equals(events[3], 'discovering');
150 assert_equals(events[4], 'discovery-idle'); 150 assert_equals(events[4], 'discovery-idle');
151 testRunner.sendBluetoothManualChooserEvent('selected', 151 testRunner.sendBluetoothManualChooserEvent('selected',
152 idsByName.get('Glucose Device') ); 152 idsByName.get('Glucose Device') );
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 testRunner.setBluetoothManualChooser(); 190 testRunner.setBluetoothManualChooser();
191 191
192 // Open the chooser, looking for a Heart Rate device. 192 // Open the chooser, looking for a Heart Rate device.
193 let requestDevicePromise = requestDeviceWithKeyDown({ 193 let requestDevicePromise = requestDeviceWithKeyDown({
194 filters: [{services: ['heart_rate']}] 194 filters: [{services: ['heart_rate']}]
195 }); 195 });
196 196
197 // The adapter finds nothing, so we just see discovery start and stop. 197 // The adapter finds nothing, so we just see discovery start and stop.
198 return getBluetoothManualChooserEvents(3).then(events => { 198 return getBluetoothManualChooserEvents(3).then(events => {
199 assert_array_equals(events, 199 assert_array_equals(events,
200 ['chooser-opened(file:///)', 200 ['chooser-opened(file://)',
201 'discovering', 201 'discovering',
202 'discovery-idle', 202 'discovery-idle',
203 ]); 203 ]);
204 204
205 // On the second discovery, the adapter finds the Heart Rate device. 205 // On the second discovery, the adapter finds the Heart Rate device.
206 testRunner.sendBluetoothManualChooserEvent('rescan', ''); 206 testRunner.sendBluetoothManualChooserEvent('rescan', '');
207 return getBluetoothManualChooserEvents(3); 207 return getBluetoothManualChooserEvents(3);
208 }).then(events => { 208 }).then(events => {
209 assert_equals(events.length, 3, events); 209 assert_equals(events.length, 3, events);
210 assert_equals(events[0], 'discovering', 'events[0]'); 210 assert_equals(events[0], 'discovering', 'events[0]');
211 let idsByName = new AddDeviceEventSet(); 211 let idsByName = new AddDeviceEventSet();
212 idsByName.assert_add_device_event(events[1]); 212 idsByName.assert_add_device_event(events[1]);
213 assert_true(idsByName.has('Heart Rate Device')); 213 assert_true(idsByName.has('Heart Rate Device'));
214 assert_equals(events[2], 'discovery-idle'); 214 assert_equals(events[2], 'discovery-idle');
215 215
216 // Select it and let the test complete. 216 // Select it and let the test complete.
217 testRunner.sendBluetoothManualChooserEvent('selected', 217 testRunner.sendBluetoothManualChooserEvent('selected',
218 idsByName.get('Heart Rate Device' )); 218 idsByName.get('Heart Rate Device' ));
219 return requestDevicePromise; 219 return requestDevicePromise;
220 }).then(device => assert_equals(device.name, 'Heart Rate Device')); 220 }).then(device => assert_equals(device.name, 'Heart Rate Device'));
221 }, 'The chooser can restart the BT scan.'); 221 }, 'The chooser can restart the BT scan.');
222 </script> 222 </script>
OLDNEW
« no previous file with comments | « content/shell/browser/shell.cc ('k') | third_party/WebKit/Source/modules/bluetooth/BluetoothError.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698