OLD | NEW |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 // Sometimes we need to test that using either the name, alias, or UUID | 3 // Sometimes we need to test that using either the name, alias, or UUID |
4 // produces the same result. The following objects help us do that. | 4 // produces the same result. The following objects help us do that. |
5 var generic_access = { | 5 var generic_access = { |
6 alias: 0x1800, | 6 alias: 0x1800, |
7 name: 'generic_access', | 7 name: 'generic_access', |
8 uuid: '00001800-0000-1000-8000-00805f9b34fb' | 8 uuid: '00001800-0000-1000-8000-00805f9b34fb' |
9 }; | 9 }; |
10 var device_name = { | 10 var device_name = { |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 constructor(object, event) { | 280 constructor(object, event) { |
281 this.eventFired = false; | 281 this.eventFired = false; |
282 let event_listener = e => { | 282 let event_listener = e => { |
283 object.removeEventListener(event, event_listener); | 283 object.removeEventListener(event, event_listener); |
284 this.eventFired = true; | 284 this.eventFired = true; |
285 } | 285 } |
286 object.addEventListener(event, event_listener); | 286 object.addEventListener(event, event_listener); |
287 } | 287 } |
288 } | 288 } |
289 | 289 |
| 290 // Layout tests default to denying permissions, but to test the Bluetooth |
| 291 // chooser we need to be in the "prompt" state. |
| 292 testRunner.setPermission("bluetooth-guard", "prompt", location.origin, location.
origin); |
| 293 |
290 // Bluetooth tests sometimes have left-over state that could leak into the | 294 // Bluetooth tests sometimes have left-over state that could leak into the |
291 // next test. add_result_callback which is exposed by testharness.js allows us | 295 // next test. add_result_callback which is exposed by testharness.js allows us |
292 // to clean up this state after each test. In the future we will split tests | 296 // to clean up this state after each test. In the future we will split tests |
293 // into separate files so that we don't have to add this callback ourselves. | 297 // into separate files so that we don't have to add this callback ourselves. |
294 // TODO(ortuno): Split tests into separate files. | 298 // TODO(ortuno): Split tests into separate files. |
295 // https://crbug.com/554240 | 299 // https://crbug.com/554240 |
296 add_result_callback(() => { | 300 add_result_callback(() => { |
297 // At the end of each test we clean up all the leftover data in the browser, | 301 // At the end of each test we clean up all the leftover data in the browser, |
298 // including revoking permissions. This happens before the test document is | 302 // including revoking permissions. This happens before the test document is |
299 // detached. Once the document is detached any device that connected tries | 303 // detached. Once the document is detached any device that connected tries |
300 // to disconnect but by then the document no longer has permission to | 304 // to disconnect but by then the document no longer has permission to |
301 // interact with the device. So before we clean up the browser data | 305 // interact with the device. So before we clean up the browser data |
302 // we change the visibility which results in all devices disconnecing. | 306 // we change the visibility which results in all devices disconnecing. |
303 // TODO(ortuno): Remove setPageVisibility hack. In the future, the browser | 307 // TODO(ortuno): Remove setPageVisibility hack. In the future, the browser |
304 // will notify the renderer that the device disconnected so we won't need | 308 // will notify the renderer that the device disconnected so we won't need |
305 // this hack. | 309 // this hack. |
306 // https://crbug.com/581855 | 310 // https://crbug.com/581855 |
307 testRunner.setPageVisibility('hidden'); | 311 testRunner.setPageVisibility('hidden'); |
308 testRunner.setPageVisibility('visible'); | 312 testRunner.setPageVisibility('visible'); |
309 testRunner.setBluetoothMockDataSet(''); | 313 testRunner.setBluetoothMockDataSet(''); |
310 }); | 314 }); |
OLD | NEW |