| Index: third_party/WebKit/LayoutTests/resources/mojo-helpers.js
|
| diff --git a/third_party/WebKit/LayoutTests/resources/mojo-helpers.js b/third_party/WebKit/LayoutTests/resources/mojo-helpers.js
|
| index 8752dd16989983ce2aea49bc3eaa26e35a1f4f8b..625d7fdfe46e06c320489bf8f8267644dfb9c658 100644
|
| --- a/third_party/WebKit/LayoutTests/resources/mojo-helpers.js
|
| +++ b/third_party/WebKit/LayoutTests/resources/mojo-helpers.js
|
| @@ -35,3 +35,25 @@ function mojo_test(func, name, properties) {
|
| });
|
| }, name, properties);
|
| }
|
| +
|
| +// Polls aggressively for a message to become available on a pipe.
|
| +function mojo_wait_for_incoming_message(mojo, pipe) {
|
| + return new Promise((resolve, reject) => {
|
| + let wait = () => {
|
| + let result = mojo.core.readMessage(pipe, 0);
|
| + if (result.result === mojo.core.RESULT_SHOULD_WAIT) {
|
| + setTimeout(wait);
|
| + return;
|
| + }
|
| +
|
| + if (result.result !== mojo.core.RESULT_OK) {
|
| + reject(result.result);
|
| + return;
|
| + }
|
| +
|
| + resolve({ buffer: result.buffer, handles: result.handles });
|
| + };
|
| +
|
| + wait();
|
| + });
|
| +};
|
|
|