patchright-core 1.48.2 → 1.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/ThirdPartyNotices.txt +70 -384
- package/bin/reinstall_chrome_beta_linux.sh +10 -8
- package/bin/reinstall_chrome_stable_linux.sh +10 -8
- package/bin/reinstall_msedge_beta_linux.sh +11 -9
- package/bin/reinstall_msedge_dev_linux.sh +11 -9
- package/bin/reinstall_msedge_stable_linux.sh +11 -9
- package/browsers.json +19 -11
- package/lib/cli/program.js +23 -5
- package/lib/client/channelOwner.js +2 -2
- package/lib/client/locator.js +7 -0
- package/lib/client/network.js +5 -0
- package/lib/client/page.js +4 -2
- package/lib/client/tracing.js +13 -0
- package/lib/client/waiter.js +15 -11
- package/lib/generated/consoleApiSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/generated/webSocketMockSource.js +1 -1
- package/lib/protocol/validator.js +23 -3
- package/lib/server/ariaSnapshot.js +33 -0
- package/lib/server/bidi/bidiChromium.js +1 -1
- package/lib/server/bidi/bidiConnection.js +0 -2
- package/lib/server/bidi/bidiExecutionContext.js +0 -3
- package/lib/server/browserType.js +4 -1
- package/lib/server/chromium/chromium.js +6 -2
- package/lib/server/chromium/crExecutionContext.js +0 -13
- package/lib/server/chromium/crPage.js +4 -1
- package/lib/server/codegen/csharp.js +11 -16
- package/lib/server/codegen/java.js +4 -7
- package/lib/server/codegen/javascript.js +28 -6
- package/lib/server/codegen/python.js +12 -16
- package/lib/server/debugController.js +8 -5
- package/lib/server/deviceDescriptorsSource.json +127 -127
- package/lib/server/dispatchers/androidDispatcher.js +13 -2
- package/lib/server/dispatchers/debugControllerDispatcher.js +1 -1
- package/lib/server/dispatchers/dispatcher.js +1 -1
- package/lib/server/dispatchers/frameDispatcher.js +8 -1
- package/lib/server/dispatchers/tracingDispatcher.js +10 -0
- package/lib/server/dom.js +79 -36
- package/lib/server/fetch.js +30 -17
- package/lib/server/firefox/ffExecutionContext.js +0 -12
- package/lib/server/firefox/ffNetworkManager.js +1 -1
- package/lib/server/frames.js +43 -27
- package/lib/server/index.js +0 -6
- package/lib/server/javascript.js +0 -6
- package/lib/server/page.js +32 -5
- package/lib/server/progress.js +0 -3
- package/lib/server/recorder/recorderApp.js +6 -15
- package/lib/server/recorder/recorderInTraceViewer.js +3 -3
- package/lib/server/recorder/recorderUtils.js +2 -1
- package/lib/server/recorder.js +66 -31
- package/lib/server/registry/index.js +70 -23
- package/lib/server/registry/nativeDeps.js +6 -3
- package/lib/server/socksClientCertificatesInterceptor.js +1 -1
- package/lib/server/trace/recorder/snapshotter.js +1 -12
- package/lib/server/trace/recorder/snapshotterInjected.js +19 -1
- package/lib/server/trace/recorder/tracing.js +69 -15
- package/lib/server/trace/test/inMemorySnapshotter.js +3 -3
- package/lib/server/trace/viewer/traceViewer.js +2 -1
- package/lib/server/webkit/wkBrowser.js +2 -2
- package/lib/server/webkit/wkExecutionContext.js +0 -13
- package/lib/server/webkit/wkPage.js +4 -0
- package/lib/utils/comparators.js +12 -30
- package/lib/utils/crypto.js +1 -4
- package/lib/utils/hostPlatform.js +6 -0
- package/lib/utils/isomorphic/ariaSnapshot.js +267 -0
- package/lib/utils/isomorphic/locatorGenerators.js +23 -5
- package/lib/utils/isomorphic/recorderUtils.js +36 -4
- package/lib/utils/isomorphic/stringUtils.js +30 -0
- package/lib/utils/isomorphic/urlMatch.js +5 -1
- package/lib/utils/network.js +1 -1
- package/lib/utils/sequence.js +64 -0
- package/lib/utils/stackTrace.js +16 -3
- package/lib/utils/zones.js +32 -23
- package/lib/utilsBundle.js +4 -5
- package/lib/utilsBundleImpl/index.js +190 -33
- package/lib/vite/htmlReport/index.html +19 -16
- package/lib/vite/recorder/assets/codeMirrorModule-DUzBrnvO.js +24 -0
- package/lib/vite/recorder/assets/index-CqeZmzx8.js +184 -0
- package/lib/vite/recorder/assets/{index-BW-aOBcL.css → index-iA1aAGZg.css} +1 -1
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-KatbITLF.js +24 -0
- package/lib/vite/traceViewer/assets/inspectorTab-DdpLd2bb.js +68 -0
- package/lib/vite/traceViewer/assets/workbench-CdYbzWFD.js +9 -0
- package/lib/vite/traceViewer/{embedded.BlHoW5LY.js → embedded.6m3UZh7r.js} +1 -1
- package/lib/vite/traceViewer/embedded.html +5 -5
- package/lib/vite/traceViewer/{index.DaWVfou1.js → index.WUV-8boJ.js} +1 -1
- package/lib/vite/traceViewer/index.html +24 -7
- package/lib/vite/traceViewer/{inspectorTab.DLjBDrQR.css → inspectorTab.DEOUW62d.css} +1 -1
- package/lib/vite/traceViewer/recorder.OT2tVHgn.js +2 -0
- package/lib/vite/traceViewer/recorder.html +3 -3
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/uiMode.BZBTyvGn.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +6 -6
- package/lib/vite/traceViewer/{uiMode.CAYqod-m.css → uiMode.voC1ZiOQ.css} +1 -1
- package/lib/vite/traceViewer/workbench.C-zR9ysA.css +1 -0
- package/package.json +1 -1
- package/types/protocol.d.ts +58 -10
- package/types/types.d.ts +116 -20
- package/lib/third_party/diff_match_patch.js +0 -2222
- package/lib/vite/recorder/assets/codeMirrorModule-baozm8ur.js +0 -24
- package/lib/vite/recorder/assets/index-2ElAIWFB.js +0 -42
- package/lib/vite/traceViewer/assets/codeMirrorModule-Bh1rfd2w.js +0 -24
- package/lib/vite/traceViewer/assets/inspectorTab-7GHnKvSD.js +0 -64
- package/lib/vite/traceViewer/assets/workbench-DPQnTHYP.js +0 -9
- package/lib/vite/traceViewer/recorder.C4zxcvd2.js +0 -2
- package/lib/vite/traceViewer/uiMode.mTXWniJb.js +0 -5
- package/lib/vite/traceViewer/workbench.D3JVcA9K.css +0 -1
|
@@ -8,15 +8,17 @@ if [[ $(arch) == "aarch64" ]]; then
|
|
|
8
8
|
exit 1
|
|
9
9
|
fi
|
|
10
10
|
|
|
11
|
-
if [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
if [ -z "$PLAYWRIGHT_HOST_PLATFORM_OVERRIDE" ]; then
|
|
12
|
+
if [[ ! -f "/etc/os-release" ]]; then
|
|
13
|
+
echo "ERROR: cannot install on unknown linux distribution (/etc/os-release is missing)"
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
ID=$(bash -c 'source /etc/os-release && echo $ID')
|
|
18
|
+
if [[ "${ID}" != "ubuntu" && "${ID}" != "debian" ]]; then
|
|
19
|
+
echo "ERROR: cannot install on $ID distribution - only Ubuntu and Debian are supported"
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
20
22
|
fi
|
|
21
23
|
|
|
22
24
|
# 1. make sure to remove old dev if any.
|
|
@@ -8,15 +8,17 @@ if [[ $(arch) == "aarch64" ]]; then
|
|
|
8
8
|
exit 1
|
|
9
9
|
fi
|
|
10
10
|
|
|
11
|
-
if [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
if [ -z "$PLAYWRIGHT_HOST_PLATFORM_OVERRIDE" ]; then
|
|
12
|
+
if [[ ! -f "/etc/os-release" ]]; then
|
|
13
|
+
echo "ERROR: cannot install on unknown linux distribution (/etc/os-release is missing)"
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
ID=$(bash -c 'source /etc/os-release && echo $ID')
|
|
18
|
+
if [[ "${ID}" != "ubuntu" && "${ID}" != "debian" ]]; then
|
|
19
|
+
echo "ERROR: cannot install on $ID distribution - only Ubuntu and Debian are supported"
|
|
20
|
+
exit 1
|
|
21
|
+
fi
|
|
20
22
|
fi
|
|
21
23
|
|
|
22
24
|
# 1. make sure to remove old stable if any.
|
package/browsers.json
CHANGED
|
@@ -3,31 +3,37 @@
|
|
|
3
3
|
"browsers": [
|
|
4
4
|
{
|
|
5
5
|
"name": "chromium",
|
|
6
|
-
"revision": "
|
|
6
|
+
"revision": "1148",
|
|
7
7
|
"installByDefault": true,
|
|
8
|
-
"browserVersion": "
|
|
8
|
+
"browserVersion": "131.0.6778.33"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "chromium-headless-shell",
|
|
12
|
+
"revision": "1148",
|
|
13
|
+
"installByDefault": true,
|
|
14
|
+
"browserVersion": "131.0.6778.33"
|
|
9
15
|
},
|
|
10
16
|
{
|
|
11
17
|
"name": "chromium-tip-of-tree",
|
|
12
|
-
"revision": "
|
|
18
|
+
"revision": "1277",
|
|
13
19
|
"installByDefault": false,
|
|
14
|
-
"browserVersion": "
|
|
20
|
+
"browserVersion": "132.0.6834.0"
|
|
15
21
|
},
|
|
16
22
|
{
|
|
17
23
|
"name": "firefox",
|
|
18
|
-
"revision": "
|
|
24
|
+
"revision": "1466",
|
|
19
25
|
"installByDefault": true,
|
|
20
|
-
"browserVersion": "
|
|
26
|
+
"browserVersion": "132.0"
|
|
21
27
|
},
|
|
22
28
|
{
|
|
23
29
|
"name": "firefox-beta",
|
|
24
|
-
"revision": "
|
|
30
|
+
"revision": "1465",
|
|
25
31
|
"installByDefault": false,
|
|
26
|
-
"browserVersion": "
|
|
32
|
+
"browserVersion": "132.0b8"
|
|
27
33
|
},
|
|
28
34
|
{
|
|
29
35
|
"name": "webkit",
|
|
30
|
-
"revision": "
|
|
36
|
+
"revision": "2104",
|
|
31
37
|
"installByDefault": true,
|
|
32
38
|
"revisionOverrides": {
|
|
33
39
|
"mac10.14": "1446",
|
|
@@ -35,9 +41,11 @@
|
|
|
35
41
|
"mac11": "1816",
|
|
36
42
|
"mac11-arm64": "1816",
|
|
37
43
|
"mac12": "2009",
|
|
38
|
-
"mac12-arm64": "2009"
|
|
44
|
+
"mac12-arm64": "2009",
|
|
45
|
+
"ubuntu20.04-x64": "2092",
|
|
46
|
+
"ubuntu20.04-arm64": "2092"
|
|
39
47
|
},
|
|
40
|
-
"browserVersion": "18.
|
|
48
|
+
"browserVersion": "18.2"
|
|
41
49
|
},
|
|
42
50
|
{
|
|
43
51
|
"name": "ffmpeg",
|
package/lib/cli/program.js
CHANGED
|
@@ -82,23 +82,41 @@ Examples:
|
|
|
82
82
|
function suggestedBrowsersToInstall() {
|
|
83
83
|
return _server.registry.executables().filter(e => e.installType !== 'none' && e.type !== 'tool').map(e => e.name).join(', ');
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function defaultBrowsersToInstall(options) {
|
|
86
|
+
let executables = _server.registry.defaultExecutables();
|
|
87
|
+
if (options.noShell) executables = executables.filter(e => e.name !== 'chromium-headless-shell');
|
|
88
|
+
if (options.onlyShell) executables = executables.filter(e => e.name !== 'chromium');
|
|
89
|
+
return executables;
|
|
90
|
+
}
|
|
91
|
+
function checkBrowsersToInstall(args, options) {
|
|
92
|
+
if (options.noShell && options.onlyShell) throw new Error(`Only one of --no-shell and --only-shell can be specified`);
|
|
86
93
|
const faultyArguments = [];
|
|
87
94
|
const executables = [];
|
|
88
|
-
|
|
95
|
+
const handleArgument = arg => {
|
|
89
96
|
const executable = _server.registry.findExecutable(arg);
|
|
90
97
|
if (!executable || executable.installType === 'none') faultyArguments.push(arg);else executables.push(executable);
|
|
98
|
+
if ((executable === null || executable === void 0 ? void 0 : executable.browserName) === 'chromium') executables.push(_server.registry.findExecutable('ffmpeg'));
|
|
99
|
+
};
|
|
100
|
+
for (const arg of args) {
|
|
101
|
+
if (arg === 'chromium') {
|
|
102
|
+
if (!options.onlyShell) handleArgument('chromium');
|
|
103
|
+
if (!options.noShell) handleArgument('chromium-headless-shell');
|
|
104
|
+
} else {
|
|
105
|
+
handleArgument(arg);
|
|
106
|
+
}
|
|
91
107
|
}
|
|
92
108
|
if (faultyArguments.length) throw new Error(`Invalid installation targets: ${faultyArguments.map(name => `'${name}'`).join(', ')}. Expecting one of: ${suggestedBrowsersToInstall()}`);
|
|
93
109
|
return executables;
|
|
94
110
|
}
|
|
95
|
-
_utilsBundle.program.command('install [browser...]').description('ensure browsers necessary for this version of Playwright are installed').option('--with-deps', 'install system dependencies for browsers').option('--dry-run', 'do not execute installation, only print information').option('--force', 'force reinstall of stable browser channels').action(async function (args, options) {
|
|
111
|
+
_utilsBundle.program.command('install [browser...]').description('ensure browsers necessary for this version of Playwright are installed').option('--with-deps', 'install system dependencies for browsers').option('--dry-run', 'do not execute installation, only print information').option('--force', 'force reinstall of stable browser channels').option('--only-shell', 'only install headless shell when installing chromium').option('--no-shell', 'do not install chromium headless shell').action(async function (args, options) {
|
|
112
|
+
// For '--no-shell' option, commander sets `shell: false` instead.
|
|
113
|
+
if (options.shell === false) options.noShell = true;
|
|
96
114
|
if ((0, _utils.isLikelyNpxGlobal)()) {
|
|
97
115
|
console.error((0, _utils.wrapInASCIIBox)([`WARNING: It looks like you are running 'npx playwright install' without first`, `installing your project's dependencies.`, ``, `To avoid unexpected behavior, please install your dependencies first, and`, `then run Playwright's install command:`, ``, ` npm install`, ` npx playwright install`, ``, `If your project does not yet depend on Playwright, first install the`, `applicable npm package (most commonly @playwright/test), and`, `then run Playwright's install command to download the browsers:`, ``, ` npm install @playwright/test`, ` npx playwright install`, ``].join('\n'), 1));
|
|
98
116
|
}
|
|
99
117
|
try {
|
|
100
118
|
const hasNoArguments = !args.length;
|
|
101
|
-
const executables = hasNoArguments ?
|
|
119
|
+
const executables = hasNoArguments ? defaultBrowsersToInstall(options) : checkBrowsersToInstall(args, options);
|
|
102
120
|
if (options.withDeps) await _server.registry.installDeps(executables, !!options.dryRun);
|
|
103
121
|
if (options.dryRun) {
|
|
104
122
|
for (const executable of executables) {
|
|
@@ -146,7 +164,7 @@ _utilsBundle.program.command('uninstall').description('Removes browsers used by
|
|
|
146
164
|
});
|
|
147
165
|
_utilsBundle.program.command('install-deps [browser...]').description('install dependencies necessary to run browsers (will ask for sudo permissions)').option('--dry-run', 'Do not execute installation commands, only print them').action(async function (args, options) {
|
|
148
166
|
try {
|
|
149
|
-
if (!args.length) await _server.registry.installDeps(
|
|
167
|
+
if (!args.length) await _server.registry.installDeps(defaultBrowsersToInstall({}), !!options.dryRun);else await _server.registry.installDeps(checkBrowsersToInstall(args, {}), !!options.dryRun);
|
|
150
168
|
} catch (e) {
|
|
151
169
|
console.log(`Failed to install browser dependencies\n${e}`);
|
|
152
170
|
(0, _utils.gracefullyProcessExitDoNotHang)(1);
|
|
@@ -160,14 +160,14 @@ class ChannelOwner extends _eventEmitter.EventEmitter {
|
|
|
160
160
|
channel._object = this;
|
|
161
161
|
return channel;
|
|
162
162
|
}
|
|
163
|
-
async _wrapApiCall(func, isInternal
|
|
163
|
+
async _wrapApiCall(func, isInternal) {
|
|
164
164
|
const logger = this._logger;
|
|
165
165
|
const apiZone = _zones.zones.zoneData('apiZone');
|
|
166
166
|
if (apiZone) return await func(apiZone);
|
|
167
167
|
const stackTrace = (0, _stackTrace.captureLibraryStackTrace)();
|
|
168
168
|
let apiName = stackTrace.apiName;
|
|
169
169
|
const frames = stackTrace.frames;
|
|
170
|
-
isInternal
|
|
170
|
+
if (isInternal === undefined) isInternal = this._isInternalType;
|
|
171
171
|
if (isInternal) apiName = undefined;
|
|
172
172
|
|
|
173
173
|
// Enclosing zone could have provided the apiName and wallTime.
|
package/lib/client/locator.js
CHANGED
|
@@ -291,6 +291,13 @@ class Locator {
|
|
|
291
291
|
timeout
|
|
292
292
|
}), options.timeout);
|
|
293
293
|
}
|
|
294
|
+
async ariaSnapshot(options) {
|
|
295
|
+
const result = await this._frame._channel.ariaSnapshot({
|
|
296
|
+
...options,
|
|
297
|
+
selector: this._selector
|
|
298
|
+
});
|
|
299
|
+
return result.snapshot;
|
|
300
|
+
}
|
|
294
301
|
async scrollIntoViewIfNeeded(options = {}) {
|
|
295
302
|
return await this._withElement((h, timeout) => h.scrollIntoViewIfNeeded({
|
|
296
303
|
...options,
|
package/lib/client/network.js
CHANGED
|
@@ -654,10 +654,12 @@ class RouteHandler {
|
|
|
654
654
|
this.handler = void 0;
|
|
655
655
|
this._ignoreException = false;
|
|
656
656
|
this._activeInvocations = new Set();
|
|
657
|
+
this._svedZone = void 0;
|
|
657
658
|
this._baseURL = baseURL;
|
|
658
659
|
this._times = times;
|
|
659
660
|
this.url = url;
|
|
660
661
|
this.handler = handler;
|
|
662
|
+
this._svedZone = _utils.zones.currentZone();
|
|
661
663
|
}
|
|
662
664
|
static prepareInterceptionPatterns(handlers) {
|
|
663
665
|
const patterns = [];
|
|
@@ -679,6 +681,9 @@ class RouteHandler {
|
|
|
679
681
|
return (0, _utils.urlMatches)(this._baseURL, requestURL, this.url);
|
|
680
682
|
}
|
|
681
683
|
async handle(route) {
|
|
684
|
+
return await this._svedZone.run(async () => this._handleImpl(route));
|
|
685
|
+
}
|
|
686
|
+
async _handleImpl(route) {
|
|
682
687
|
const handlerInvocation = {
|
|
683
688
|
complete: new _manualPromise.ManualPromise(),
|
|
684
689
|
route
|
package/lib/client/page.js
CHANGED
|
@@ -680,14 +680,16 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
680
680
|
workers() {
|
|
681
681
|
return [...this._workers];
|
|
682
682
|
}
|
|
683
|
-
async pause() {
|
|
683
|
+
async pause(_options) {
|
|
684
684
|
var _this$_instrumentatio;
|
|
685
685
|
if (require('inspector').url()) return;
|
|
686
686
|
const defaultNavigationTimeout = this._browserContext._timeoutSettings.defaultNavigationTimeout();
|
|
687
687
|
const defaultTimeout = this._browserContext._timeoutSettings.defaultTimeout();
|
|
688
688
|
this._browserContext.setDefaultNavigationTimeout(0);
|
|
689
689
|
this._browserContext.setDefaultTimeout(0);
|
|
690
|
-
(_this$_instrumentatio = this._instrumentation) === null || _this$_instrumentatio === void 0 || _this$_instrumentatio.onWillPause(
|
|
690
|
+
(_this$_instrumentatio = this._instrumentation) === null || _this$_instrumentatio === void 0 || _this$_instrumentatio.onWillPause({
|
|
691
|
+
keepTestTimeout: !!(_options !== null && _options !== void 0 && _options.__testHookKeepTestTimeout)
|
|
692
|
+
});
|
|
691
693
|
await this._closedOrCrashedScope.safeRace(this.context()._channel.pause());
|
|
692
694
|
this._browserContext.setDefaultNavigationTimeout(defaultNavigationTimeout);
|
|
693
695
|
this._browserContext.setDefaultTimeout(defaultTimeout);
|
package/lib/client/tracing.js
CHANGED
|
@@ -56,6 +56,19 @@ class Tracing extends _channelOwner.ChannelOwner {
|
|
|
56
56
|
} = await this._channel.tracingStartChunk(options);
|
|
57
57
|
await this._startCollectingStacks(traceName);
|
|
58
58
|
}
|
|
59
|
+
async group(name, options = {}) {
|
|
60
|
+
await this._wrapApiCall(async () => {
|
|
61
|
+
await this._channel.tracingGroup({
|
|
62
|
+
name,
|
|
63
|
+
location: options.location
|
|
64
|
+
});
|
|
65
|
+
}, false);
|
|
66
|
+
}
|
|
67
|
+
async groupEnd() {
|
|
68
|
+
await this._wrapApiCall(async () => {
|
|
69
|
+
await this._channel.tracingGroupEnd();
|
|
70
|
+
}, false);
|
|
71
|
+
}
|
|
59
72
|
async _startCollectingStacks(traceName) {
|
|
60
73
|
if (!this._isTracing) {
|
|
61
74
|
this._isTracing = true;
|
package/lib/client/waiter.js
CHANGED
|
@@ -32,8 +32,10 @@ class Waiter {
|
|
|
32
32
|
this._channelOwner = void 0;
|
|
33
33
|
this._waitId = void 0;
|
|
34
34
|
this._error = void 0;
|
|
35
|
+
this._savedZone = void 0;
|
|
35
36
|
this._waitId = (0, _utils.createGuid)();
|
|
36
37
|
this._channelOwner = channelOwner;
|
|
38
|
+
this._savedZone = _utils.zones.currentZone();
|
|
37
39
|
this._channelOwner._channel.waitForEventInfo({
|
|
38
40
|
info: {
|
|
39
41
|
waitId: this._waitId,
|
|
@@ -58,14 +60,14 @@ class Waiter {
|
|
|
58
60
|
const {
|
|
59
61
|
promise,
|
|
60
62
|
dispose
|
|
61
|
-
} = waitForEvent(emitter, event, predicate);
|
|
63
|
+
} = waitForEvent(emitter, event, this._savedZone, predicate);
|
|
62
64
|
return await this.waitForPromise(promise, dispose);
|
|
63
65
|
}
|
|
64
66
|
rejectOnEvent(emitter, event, error, predicate) {
|
|
65
67
|
const {
|
|
66
68
|
promise,
|
|
67
69
|
dispose
|
|
68
|
-
} = waitForEvent(emitter, event, predicate);
|
|
70
|
+
} = waitForEvent(emitter, event, this._savedZone, predicate);
|
|
69
71
|
this._rejectOn(promise.then(() => {
|
|
70
72
|
throw typeof error === 'function' ? error() : error;
|
|
71
73
|
}), dispose);
|
|
@@ -118,18 +120,20 @@ class Waiter {
|
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
122
|
exports.Waiter = Waiter;
|
|
121
|
-
function waitForEvent(emitter, event, predicate) {
|
|
123
|
+
function waitForEvent(emitter, event, savedZone, predicate) {
|
|
122
124
|
let listener;
|
|
123
125
|
const promise = new Promise((resolve, reject) => {
|
|
124
126
|
listener = async eventArg => {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
127
|
+
await savedZone.run(async () => {
|
|
128
|
+
try {
|
|
129
|
+
if (predicate && !(await predicate(eventArg))) return;
|
|
130
|
+
emitter.removeListener(event, listener);
|
|
131
|
+
resolve(eventArg);
|
|
132
|
+
} catch (e) {
|
|
133
|
+
emitter.removeListener(event, listener);
|
|
134
|
+
reject(e);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
133
137
|
};
|
|
134
138
|
emitter.addListener(event, listener);
|
|
135
139
|
});
|