Chromium Code Reviews| Index: LayoutTests/bluetooth/requestDevice.html |
| diff --git a/LayoutTests/bluetooth/requestDevice.html b/LayoutTests/bluetooth/requestDevice.html |
| index c4e712cfa4a9fad4eb2a84d11b00f6b21ed2a1b8..19affac34025c258ec692122e32e6605022a3f3a 100644 |
| --- a/LayoutTests/bluetooth/requestDevice.html |
| +++ b/LayoutTests/bluetooth/requestDevice.html |
| @@ -3,40 +3,57 @@ |
| <script src="../resources/testharnessreport.js"></script> |
| <script> |
| +var promise_tests = Promise.resolve(); |
| +// Helper function to run promise tests one after the other. |
| +// TODO(ortuno): Remove once https://github.com/w3c/testharness.js/pull/115/files |
| +// gets through. |
| +function sequential_promise_test(func, name) { |
| + var test = async_test(name); |
| + promise_tests = promise_tests.then(function() { |
| + return Promise.resolve(test.step(func, test, test)) |
| + .then( |
| + function() { |
|
esprehn
2015/04/11 00:45:02
I think we usually put the function() inline with
|
| + test.done(); |
| + }) |
| + .catch(test.step_func( |
| + function(value) { |
| + throw value; |
| + })); |
| + }); |
| +} |
| + |
| test(function(t) { assert_exists(window, "testRunner"); t.done(); }, |
| "window.testRunner is required for the following tests."); |
| -async_test(function(t) { |
| +sequential_promise_test(function(t) { |
| testRunner.setBluetoothMockDataSet('RejectRequestDevice_NotFoundError'); |
| - navigator.bluetooth.requestDevice() |
| + return 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(); |
| - })); |
| + function() { |
| + assert_unreached('Mock was set to reject.'); |
| + }, |
| + function(e) { |
| + assert_equals(e.name, 'NotFoundErrora'); |
| + }); |
| }, 'Reject with NotFoundError.'); |
| -async_test(function(t) { |
| +sequential_promise_test(function(t) { |
| testRunner.setBluetoothMockDataSet('RejectRequestDevice_SecurityError'); |
| - navigator.bluetooth.requestDevice() |
| + return navigator.bluetooth.requestDevice() |
| .then( |
| - t.step_func(function() { assert_unreached('Mock was set to reject.'); }), |
| - t.step_func(function(e) { |
| + function() { |
| + assert_unreached('Mock was set to reject.'); |
| + }, |
| + function(e) { |
| assert_equals(e.name, 'SecurityError'); |
| - t.done(); |
| - })); |
| + }); |
| }, 'Reject with SecurityError.'); |
| -async_test(function(t) { |
| +sequential_promise_test(function() { |
| 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.'); })); |
| + return navigator.bluetooth.requestDevice() |
| + .then(function(device) { |
| + assert_equals(device.constructor.name, "BluetoothDevice"); |
| + }); |
| }, 'Mock will resolve.'); |
| - |
| </script> |