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 608f37f42f7520efd4bea4809ae6123f24d49634..b94677f26dfc8a8742da9309fde175e7a9cf0bf4 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 |
@@ -101,3 +101,15 @@ function simulateNotificationClick(title, actionIndex, port) |
}); |
}); |
} |
+ |
+// Sets up a listener for events of |type| on |target|. The listener is removed the first time the |
+// event fires. Returns a promise that resolves with the fired event. |
+function listenOnce(target, type) |
+{ |
+ return new Promise((resolve, reject) => { |
+ target.addEventListener(type, function listener(event) { |
+ target.removeEventListener(type, listener); |
+ resolve(event); |
+ }); |
+ }); |
+} |