| Index: third_party/WebKit/LayoutTests/http/tests/notifications/resources/test-helpers.js
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/notifications/resources/test-helpers.js b/third_party/WebKit/LayoutTests/http/tests/notifications/resources/test-helpers.js
|
| index fca5463c72841efe40fc2ad556868a9b1995d9ac..608f37f42f7520efd4bea4809ae6123f24d49634 100644
|
| --- a/third_party/WebKit/LayoutTests/http/tests/notifications/resources/test-helpers.js
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/notifications/resources/test-helpers.js
|
| @@ -66,3 +66,38 @@ function getActiveServiceWorkerWithMessagePort(test, script, scope)
|
| });
|
| });
|
| }
|
| +
|
| +// Sends a message with |data| over |port|. Returns a promise that either rejects when a bad
|
| +// response message is received, or otherwise resolves with the response data.
|
| +function sendCommand(port, data)
|
| +{
|
| + return new Promise((resolve, reject) => {
|
| + port.postMessage(data);
|
| + port.addEventListener('message', function listener(event) {
|
| + port.removeEventListener('message', listener);
|
| + if (typeof event.data != 'object' || !event.data.command) {
|
| + reject(new Error('Invalid message from the Service Worker.'));
|
| + } else {
|
| + resolve(event.data);
|
| + }
|
| + });
|
| + });
|
| +}
|
| +
|
| +// Simulates a click on the notification whose title equals |title|. The |actionIndex| specifies
|
| +// which action button to activate, where -1 means the notification itself is clicked, not an action
|
| +// button.
|
| +function simulateNotificationClick(title, actionIndex, port)
|
| +{
|
| + return new Promise((resolve, reject) => {
|
| + testRunner.simulateWebNotificationClick(title, actionIndex);
|
| + port.addEventListener('message', function listener(event) {
|
| + port.removeEventListener('message', listener);
|
| + if (typeof event.data != 'object' || event.data.command != 'click') {
|
| + reject(new Error('Invalid message from the Service Worker.'));
|
| + } else {
|
| + resolve(event.data);
|
| + }
|
| + });
|
| + });
|
| +}
|
|
|