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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/bluetooth-helpers.js"></script>
5 <script>
6 'use strict';
7 test(t => { assert_true(window.testRunner instanceof Object); t.done(); },
8 'window.testRunner is required for the following tests.');
9
10 // TODO(ortuno): Allow connections when the tab is in the background.
11 // This is a short term solution instead of implementing a tab indicator
12 // for bluetooth connections.
13 // https://crbug.com/579746
14 promise_test(() => {
15 testRunner.setPageVisibility("visible");
16 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
17 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
18 .then(device => device.connectGATT())
19 .then(gatt_server => {
20 assert_true(gatt_server.connected);
21 testRunner.setPageVisibility("hidden");
22 assert_false(gatt_server.connected);
23 testRunner.setPageVisibility("visible");
24 assert_false(gatt_server.connected);
25 });
26 }, 'Test device disconnects when tab becomes hidden');
27
28 promise_test(() => {
29 testRunner.setPageVisibility('visible');
30 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
31 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
32 .then(device => device.connectGATT())
33 .then(gatt_server => {})
34 .then(() => runGarbageCollection())
35 .then(() => testRunner.setPageVisibility('hidden'));
36 }, '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.
37
38 promise_test(() => {
39 testRunner.setPageVisibility('visible');
40 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
41 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
42 .then(device => device.connectGATT())
43 .then(gatt_server => testRunner.setPageVisibility('hidden'))
44 .then(() => runGarbageCollection());
45 }, '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.
46
47 promise_test(() => {
48 testRunner.setPageVisibility('visible');
49 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
50 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
51 .then(device => {
52 let connect_promise = device.connectGATT();
53 testRunner.setPageVisibility('hidden');
54 return connect_promise;
55 }).then(gatt_server => {
56 assert_false(gatt_server.connected);
57 });
58 }, 'Visibility changes during connection. Should disconnect.');
59 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698