如何通过 chrome-remote-interface 远程评估 Angular 应用程序的承诺
How to evaluate a promise of an Angular app remotely via chrome-remote-interface
我正在使用 chrome-remote-interface 节点包来远程访问 Angular 应用程序。
为了评估 returns 一个 Promise 的表达式,我使用了这个代码片段:
Runtime.evaluate({expression, awaitPromise: true, returnByValue: true});
我收到以下错误消息:
Error: Result of the evaluation is not a promise
我知道,zone.js 正在使用 ZoneAwarePromise 猴子修补 Promise。
这可能是原因,还是我做错了什么?有没有办法使用原生的 Promise?
问题是,chrome-remote-interface 无法评估 ZoneAwarePromise,它在使用 zone.js 时取代了本机 Promise。 zone.js 将原始原生 Promise 存储在 window.__zone_symbol__Promise 中。
使用 Runtime.evaluate({window.__zone_symbol__Promise.resolve(expression), awaitPromise: true, returnByValue: true});
为我修复了它。不过,这实际上只是一种解决方法,具体取决于 zone.js 实施细节,因此不应在生产代码中使用。
我正在使用 chrome-remote-interface 节点包来远程访问 Angular 应用程序。 为了评估 returns 一个 Promise 的表达式,我使用了这个代码片段:
Runtime.evaluate({expression, awaitPromise: true, returnByValue: true});
我收到以下错误消息:
Error: Result of the evaluation is not a promise
我知道,zone.js 正在使用 ZoneAwarePromise 猴子修补 Promise。 这可能是原因,还是我做错了什么?有没有办法使用原生的 Promise?
问题是,chrome-remote-interface 无法评估 ZoneAwarePromise,它在使用 zone.js 时取代了本机 Promise。 zone.js 将原始原生 Promise 存储在 window.__zone_symbol__Promise 中。
使用 Runtime.evaluate({window.__zone_symbol__Promise.resolve(expression), awaitPromise: true, returnByValue: true});
为我修复了它。不过,这实际上只是一种解决方法,具体取决于 zone.js 实施细节,因此不应在生产代码中使用。