Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/bluetooth/disconnect-tab.html |
| diff --git a/third_party/WebKit/LayoutTests/bluetooth/disconnect-tab.html b/third_party/WebKit/LayoutTests/bluetooth/disconnect-tab.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..346df6e1fcfd05c691f4443f711e3dd18d2367d3 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/bluetooth/disconnect-tab.html |
| @@ -0,0 +1,59 @@ |
| +<!DOCTYPE html> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="resources/bluetooth-helpers.js"></script> |
| +<script> |
| +'use strict'; |
| +test(t => { assert_true(window.testRunner instanceof Object); t.done(); }, |
| + 'window.testRunner is required for the following tests.'); |
| + |
| +// TODO(ortuno): Allow connections when the tab is in the background. |
| +// This is a short term solution instead of implementing a tab indicator |
| +// for bluetooth connections. |
| +// https://crbug.com/579746 |
| +promise_test(() => { |
| + testRunner.setPageVisibility("visible"); |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => device.connectGATT()) |
| + .then(gatt_server => { |
| + assert_true(gatt_server.connected); |
| + testRunner.setPageVisibility("hidden"); |
| + assert_false(gatt_server.connected); |
| + testRunner.setPageVisibility("visible"); |
| + assert_false(gatt_server.connected); |
| + }); |
| +}, 'Test device disconnects when tab becomes hidden'); |
| + |
| +promise_test(() => { |
| + testRunner.setPageVisibility('visible'); |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => device.connectGATT()) |
| + .then(gatt_server => {}) |
| + .then(() => runGarbageCollection()) |
| + .then(() => testRunner.setPageVisibility('hidden')); |
| +}, 'Test object gets garbage collected before tab becomes hidden'); |
|
Jeffrey Yasskin
2016/01/21 23:44:33
This is checking that Chrome doesn't crash?
Would
ortuno
2016/01/22 21:34:12
Yup.
|
| + |
| +promise_test(() => { |
| + testRunner.setPageVisibility('visible'); |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => device.connectGATT()) |
| + .then(gatt_server => testRunner.setPageVisibility('hidden')) |
| + .then(() => runGarbageCollection()); |
| +}, 'Test object gets garbage collected after tab becomes hidden'); |
|
Jeffrey Yasskin
2016/01/21 23:44:33
Is this also a crash test?
ortuno
2016/01/22 21:34:12
Yup. Added comment to clarify.
|
| + |
| +promise_test(() => { |
| + testRunner.setPageVisibility('visible'); |
| + testRunner.setBluetoothMockDataSet('HeartRateAdapter'); |
| + return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) |
| + .then(device => { |
| + let connect_promise = device.connectGATT(); |
| + testRunner.setPageVisibility('hidden'); |
| + return connect_promise; |
| + }).then(gatt_server => { |
| + assert_false(gatt_server.connected); |
| + }); |
| +}, 'Visibility changes during connection. Should disconnect.'); |
| +</script> |