Chromium Code Reviews| Index: LayoutTests/bluetooth/requestDevice.html |
| diff --git a/LayoutTests/bluetooth/requestDevice.html b/LayoutTests/bluetooth/requestDevice.html |
| index c4e712cfa4a9fad4eb2a84d11b00f6b21ed2a1b8..7aa06cf9deffabc659d0cbadbc00cc094c7911fc 100644 |
| --- a/LayoutTests/bluetooth/requestDevice.html |
| +++ b/LayoutTests/bluetooth/requestDevice.html |
| @@ -3,40 +3,55 @@ |
| <script src="../resources/testharnessreport.js"></script> |
| <script> |
| +var promise_tests = Promise.resolve(); |
| +// Helper function to run promise tests one after the other. |
|
Jeffrey Yasskin
2015/04/10 23:56:13
Add a TODO to remove this once https://github.com/
|
| +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() { |
| + 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> |