feat: expose frame's execution contexts (#3048)

This patch exposes frame's execution contexts, making it possible
to debug extension's content scripts.

This is a resurrected #2812.
This commit is contained in:
Andrey Lushnikov
2018-08-09 14:57:08 -07:00
committed by GitHub
parent b84404c94e
commit 231a2be971
9 changed files with 158 additions and 27 deletions

View File

@@ -78,7 +78,14 @@ const utils = module.exports = {
* @param {string} eventName
* @return {!Promise<!Object>}
*/
waitEvent: function(emitter, eventName) {
return new Promise(fulfill => emitter.once(eventName, fulfill));
waitEvent: function(emitter, eventName, predicate = () => true) {
return new Promise(fulfill => {
emitter.on(eventName, function listener(event) {
if (!predicate(event))
return;
emitter.removeListener(eventName, listener);
fulfill(event);
});
});
},
};