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

Unified Diff: third_party/WebKit/LayoutTests/bluetooth/disconnect-when-hidden-or-closed.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: Address jyasskin's comments #2 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-when-hidden-or-closed.html
diff --git a/third_party/WebKit/LayoutTests/bluetooth/disconnect-when-hidden-or-closed.html b/third_party/WebKit/LayoutTests/bluetooth/disconnect-when-hidden-or-closed.html
new file mode 100644
index 0000000000000000000000000000000000000000..fcf3ca0c24aee58e8327f2cdee61980ef12cebc8
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/bluetooth/disconnect-when-hidden-or-closed.html
@@ -0,0 +1,61 @@
+<!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. ' +
+ 'We shouldn\'t crash.');
+
+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. ' +
+ 'We shouldn\'t crash.');
+
+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