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

Side by Side Diff: third_party/WebKit/LayoutTests/bluetooth/connectGATT.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 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
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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return requestDeviceWithKeyDown({filters: [{services: [testSpec.uuid]}]}) 110 return requestDeviceWithKeyDown({filters: [{services: [testSpec.uuid]}]})
111 .then(device => { 111 .then(device => {
112 assert_promise_rejects_with_message( 112 assert_promise_rejects_with_message(
113 device.connectGATT(), 113 device.connectGATT(),
114 testSpec.error, 114 testSpec.error,
115 'Adapter failed to connect to device.'); 115 'Adapter failed to connect to device.');
116 }); 116 });
117 }, testSpec.testName); 117 }, testSpec.testName);
118 }); 118 });
119 119
120 // TODO(ortuno): Allow connections when the tab is in the background.
121 // This is a short term solution instead of implementing a tab indicator
122 // for bluetooth connections.
123 // https://crbug.com/579746
124 promise_test(() => {
125 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
126 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
127 .then(device => {
128 testRunner.setPageVisibility('hidden');
129 return assert_promise_rejects_with_message(
130 device.connectGATT(),
131 new DOMException('Connection is only allowed while the page is visible. ' +
132 'This is a temporary measure until we are able to ' +
133 'effectively communicate to the user that a page is ' +
134 'connected to a device.',
135 'SecurityError'));
136 })
137 .then(() => testRunner.setPageVisibility('visible'))
138 .catch(error => {
139 testRunner.setPageVisibility('visible');
140 throw error;
141 });
142 }, 'Device should not be able to connect in background.');
143
120 promise_test(() => { 144 promise_test(() => {
121 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); 145 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
122 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) 146 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
123 .then(device => device.connectGATT()) 147 .then(device => device.connectGATT())
124 .then(gattServer => assert_true(gattServer.connected)); 148 .then(gattServer => assert_true(gattServer.connected));
125 }, 'Device will connect'); 149 }, 'Device will connect');
126 150
127 promise_test(() => { 151 promise_test(() => {
128 testRunner.setBluetoothMockDataSet(''); 152 testRunner.setBluetoothMockDataSet('');
129 testRunner.setBluetoothMockDataSet('HeartRateAdapter'); 153 testRunner.setBluetoothMockDataSet('HeartRateAdapter');
130 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]}) 154 return requestDeviceWithKeyDown({filters: [{services: ['heart_rate']}]})
131 .then(device => { 155 .then(device => {
132 return Promise.all([device.connectGATT(), device.connectGATT()]) 156 return Promise.all([device.connectGATT(), device.connectGATT()])
133 }).then(gattServers => { 157 }).then(gattServers => {
134 // connectGATT should return the same object if it was created earlier. 158 // connectGATT should return the same object if it was created earlier.
135 // TODO(ortuno): change to assert_equals. 159 // TODO(ortuno): change to assert_equals.
136 assert_not_equals(gattServers[0], gattServers[1]); 160 assert_not_equals(gattServers[0], gattServers[1]);
137 }); 161 });
138 }); 162 });
139 </script> 163 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698