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

Unified Diff: third_party/WebKit/LayoutTests/bluetooth/disconnect-tab.html

Issue 1611773002: bluetooth: Disconnect if the page becomes hidden or is closed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Disconnect if page hidden when connected. Clean up 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 side-by-side diff with in-line comments
Download patch
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>

Powered by Google App Engine
This is Rietveld 408576698