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

Side by Side 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 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. ' +
37 'We shouldn\'t crash.');
38
39 promise_test(() => {
40 testRunner.setPageVisibility('visible');
41 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
42 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
43 .then(device => device.connectGATT())
44 .then(gatt_server => testRunner.setPageVisibility('hidden'))
45 .then(() => runGarbageCollection());
46 }, 'Test object gets garbage collected after tab becomes hidden. ' +
47 'We shouldn\'t crash.');
48
49 promise_test(() => {
50 testRunner.setPageVisibility('visible');
51 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
52 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
53 .then(device => {
54 let connect_promise = device.connectGATT();
55 testRunner.setPageVisibility('hidden');
56 return connect_promise;
57 }).then(gatt_server => {
58 assert_false(gatt_server.connected);
59 });
60 }, 'Visibility changes during connection. Should disconnect.');
61 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698