mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
@@ -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);
|
||||
});
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user