Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/inspector/inspector-test.js |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/inspector/inspector-test.js b/third_party/WebKit/LayoutTests/http/tests/inspector/inspector-test.js |
| index 3f06fbf7460a19b31805a6c78a95db6c45c34ba9..6009ccbf91e967d3811c3d96199d38c3dc588bb1 100644 |
| --- a/third_party/WebKit/LayoutTests/http/tests/inspector/inspector-test.js |
| +++ b/third_party/WebKit/LayoutTests/http/tests/inspector/inspector-test.js |
| @@ -427,6 +427,27 @@ InspectorTest.dumpNavigatorViewInMode = function(view, mode) |
| InspectorTest.dumpNavigatorView(view); |
| } |
| +/** |
| + * @param {symbol} event |
| + * @param {!Common.Object} obj |
| + * @param {(function(?):boolean)|undefined} |
| + * @return {!Promise} |
| + */ |
| +InspectorTest.waitEventListener = function(event, obj, condition = undefined) |
|
allada
2017/05/10 22:25:01
There are a few places in this file that could use
dgozman
2017/05/10 22:57:13
Paul is adding .once(), will it work in most cases
|
| +{ |
| + condition = condition || function() { return true;}; |
| + return new Promise(resolve => { |
| + obj.addEventListener(event, onEventFired); |
| + |
| + function onEventFired(event) { |
| + if (!condition(event.data)) |
| + return; |
| + obj.removeEventListener(event, onEventFired); |
| + resolve(event.data); |
| + } |
| + }); |
| +} |
| + |
| InspectorTest.waitForUISourceCode = function(urlSuffix, projectType) |
| { |
| function matches(uiSourceCode) |