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

Side by Side Diff: third_party/WebKit/LayoutTests/bluetooth/connect.html

Issue 1859463002: bluetooth: Remove disconnect when page hidden (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address jyasskin's comments Created 4 years, 8 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/bluetooth-helpers.js"></script> 4 <script src="resources/bluetooth-helpers.js"></script>
5 <script> 5 <script>
6 'use strict'; 6 'use strict';
7 7
8 test(t => { assert_true(window.testRunner instanceof Object); t.done(); }, 8 test(t => { assert_true(window.testRunner instanceof Object); t.done(); },
9 'window.testRunner is required for the following tests.'); 9 'window.testRunner is required for the following tests.');
10 10
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // need to be cleaned up. 117 // need to be cleaned up.
118 // TODO(ortuno): Re-enable the test when the errors are cleaned up. 118 // TODO(ortuno): Re-enable the test when the errors are cleaned up.
119 // http://crbug.com/598341 119 // http://crbug.com/598341
120 // .then(device => assert_promise_rejects_with_message( 120 // .then(device => assert_promise_rejects_with_message(
121 // device.gatt.connect(), 121 // device.gatt.connect(),
122 // testSpec.error, 122 // testSpec.error,
123 // 'Adapter failed to connect to device.')) 123 // 'Adapter failed to connect to device.'))
124 }, testSpec.testName); 124 }, testSpec.testName);
125 }); 125 });
126 126
127 // TODO(ortuno): Allow connections when the tab is in the background.
128 // This is a short term solution instead of implementing a tab indicator
129 // for bluetooth connections.
130 // https://crbug.com/579746
131 promise_test(() => {
132 return setBluetoothFakeAdapter('HeartRateAdapter')
133 .then(() => requestDeviceWithKeyDown({
134 filters: [{services: ['heart_rate']}]}))
135 .then(device => {
136 testRunner.setPageVisibility('hidden');
137 return assert_promise_rejects_with_message(
138 device.gatt.connect(),
139 new DOMException('Connection is only allowed while the page is visible. ' +
140 'This is a temporary measure until we are able to ' +
141 'effectively communicate to the user that a page is ' +
142 'connected to a device.',
143 'SecurityError'))
144 .then(() => {
145 assert_false(device.gatt.connected);
146 });
147 })
148 .then(() => testRunner.setPageVisibility('visible'))
149 .catch(error => {
150 testRunner.setPageVisibility('visible');
151 throw error;
152 });
153 }, 'Device should not be able to connect in background.');
154
155 promise_test(() => { 127 promise_test(() => {
156 return setBluetoothFakeAdapter('HeartRateAdapter') 128 return setBluetoothFakeAdapter('HeartRateAdapter')
157 .then(() => requestDeviceWithKeyDown({ 129 .then(() => requestDeviceWithKeyDown({
158 filters: [{services: ['heart_rate']}]})) 130 filters: [{services: ['heart_rate']}]}))
159 .then(device => device.gatt.connect()) 131 .then(device => device.gatt.connect())
160 .then(gattServer => assert_true(gattServer.connected)); 132 .then(gattServer => assert_true(gattServer.connected));
161 }, 'Device will connect'); 133 }, 'Device will connect');
162 134
163 promise_test(() => { 135 promise_test(() => {
164 return setBluetoothFakeAdapter('HeartRateAdapter') 136 return setBluetoothFakeAdapter('HeartRateAdapter')
165 .then(() => requestDeviceWithKeyDown({ 137 .then(() => requestDeviceWithKeyDown({
166 filters: [{services: ['heart_rate']}]})) 138 filters: [{services: ['heart_rate']}]}))
167 .then(device => { 139 .then(device => {
168 return Promise.all([device.gatt.connect(), device.gatt.connect()]) 140 return Promise.all([device.gatt.connect(), device.gatt.connect()])
169 }).then(gattServers => { 141 }).then(gattServers => {
170 assert_equals(gattServers[0], gattServers[1]); 142 assert_equals(gattServers[0], gattServers[1]);
171 }); 143 });
172 }); 144 });
173 145
174 // TODO(ortuno): Remove connectGATT in M52. 146 // TODO(ortuno): Remove connectGATT in M52.
175 // http://crbug.com/582292 147 // http://crbug.com/582292
176 promise_test(() => { 148 promise_test(() => {
177 return setBluetoothFakeAdapter('HeartRateAdapter') 149 return setBluetoothFakeAdapter('HeartRateAdapter')
178 .then(() => requestDeviceWithKeyDown({ 150 .then(() => requestDeviceWithKeyDown({
179 filters: [{services: ['heart_rate']}]})) 151 filters: [{services: ['heart_rate']}]}))
180 .then(device => device.connectGATT()) 152 .then(device => device.connectGATT())
181 }, 'Make sure deprecated method is still usable.') 153 }, 'Make sure deprecated method is still usable.')
182 </script> 154 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698