Index: LayoutTests/bluetooth/requestDevice.html |
diff --git a/LayoutTests/bluetooth/requestDevice.html b/LayoutTests/bluetooth/requestDevice.html |
index c4e712cfa4a9fad4eb2a84d11b00f6b21ed2a1b8..7a394c6b37f6bebbf25d3372e30277b6fdb5c330 100644 |
--- a/LayoutTests/bluetooth/requestDevice.html |
+++ b/LayoutTests/bluetooth/requestDevice.html |
@@ -2,41 +2,74 @@ |
<script src="../resources/testharness.js"></script> |
<script src="../resources/testharnessreport.js"></script> |
<script> |
+var lock = false; |
+var testQueue = []; |
+ |
+var getLock = function(test) { |
esprehn
2015/04/08 00:10:29
function getLock, no need for the var.
|
+ if (lock) { |
+ testQueue.push(test); |
+ } else { |
+ lock = true; |
+ test(); |
+ } |
+}; |
+ |
+var releaseLock = function() { |
esprehn
2015/04/08 00:10:29
function releaseLock()
|
+ var nextTest = testQueue.shift(); |
+ if (nextTest) { |
+ nextTest(); |
Jeffrey Yasskin
2015/04/07 23:46:38
Probably use `Promise.resolve().then(nextTest)` or
|
+ } else { |
+ lock = false; |
+ } |
+}; |
test(function(t) { assert_exists(window, "testRunner"); t.done(); }, |
"window.testRunner is required for the following tests."); |
-async_test(function(t) { |
- testRunner.setBluetoothMockDataSet('RejectRequestDevice_NotFoundError'); |
- navigator.bluetooth.requestDevice() |
- .then( |
- t.step_func(function() { assert_unreached('Mock was set to reject.'); }), |
- t.step_func(function(e) { |
- assert_equals(e.name, 'NotFoundError'); |
- t.done(); |
- })); |
-}, 'Reject with NotFoundError.'); |
- |
-async_test(function(t) { |
- testRunner.setBluetoothMockDataSet('RejectRequestDevice_SecurityError'); |
- navigator.bluetooth.requestDevice() |
- .then( |
- t.step_func(function() { assert_unreached('Mock was set to reject.'); }), |
- t.step_func(function(e) { |
- assert_equals(e.name, 'SecurityError'); |
- t.done(); |
- })); |
-}, 'Reject with SecurityError.'); |
+getLock(function(t) { |
Jeffrey Yasskin
2015/04/07 23:46:38
I'm not sure the test will wait for all of the tes
|
+ async_test(function(t) { |
+ testRunner.setBluetoothMockDataSet('RejectRequestDevice_NotFoundError'); |
Jeffrey Yasskin
2015/04/07 23:46:38
If this throws, it'll hang the test. It'd be bette
|
+ navigator.bluetooth.requestDevice() |
+ .then( |
+ t.step_func(function() { |
+ releaseLock(); |
+ assert_unreached('Mock was set to reject.'); }), |
+ t.step_func(function(e) { |
+ releaseLock(); |
+ assert_equals(e.name, 'NotFoundError'); |
+ t.done(); |
+ })); |
+ }, 'Reject with NotFoundError.')}); |
-async_test(function(t) { |
- testRunner.setBluetoothMockDataSet('Single Empty Device'); |
- navigator.bluetooth.requestDevice() |
- .then( |
- t.step_func(function(device) { |
- assert_equals(device.constructor.name, "BluetoothDevice"); |
- t.done(); |
- }), |
- t.step_func(function() { assert_unreached('Mock was set to resolve.'); })); |
-}, 'Mock will resolve.'); |
+getLock(function(t) { |
+ async_test(function(t) { |
+ testRunner.setBluetoothMockDataSet('RejectRequestDevice_SecurityError'); |
+ navigator.bluetooth.requestDevice() |
+ .then( |
+ t.step_func(function() { |
+ releaseLock(); |
+ assert_unreached('Mock was set to reject.'); |
+ }), |
+ t.step_func(function(e) { |
+ releaseLock(); |
+ assert_equals(e.name, 'SecurityError'); |
+ t.done(); |
+ })); |
+ }, 'Reject with SecurityError.')}); |
+getLock(function(t) { |
+ async_test(function(t) { |
+ testRunner.setBluetoothMockDataSet('Single Empty Device'); |
+ navigator.bluetooth.requestDevice() |
+ .then( |
+ t.step_func(function(device) { |
+ releaseLock(); |
+ assert_equals(device.constructor.name, "BluetoothDevice"); |
+ t.done(); |
+ }), |
+ t.step_func(function() { |
+ releaseLock(); |
+ assert_unreached('Mock was set to resolve.'); |
+ })); |
+ }, 'Mock will resolve.')}); |
</script> |