@checkly/playwright-core 1.41.2-beta.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +3 -0
- package/ThirdPartyNotices.txt +1513 -0
- package/bin/PrintDeps.exe +0 -0
- package/bin/README.md +2 -0
- package/bin/install_media_pack.ps1 +5 -0
- package/bin/reinstall_chrome_beta_linux.sh +40 -0
- package/bin/reinstall_chrome_beta_mac.sh +13 -0
- package/bin/reinstall_chrome_beta_win.ps1 +23 -0
- package/bin/reinstall_chrome_stable_linux.sh +40 -0
- package/bin/reinstall_chrome_stable_mac.sh +12 -0
- package/bin/reinstall_chrome_stable_win.ps1 +23 -0
- package/bin/reinstall_msedge_beta_linux.sh +40 -0
- package/bin/reinstall_msedge_beta_mac.sh +11 -0
- package/bin/reinstall_msedge_beta_win.ps1 +22 -0
- package/bin/reinstall_msedge_dev_linux.sh +40 -0
- package/bin/reinstall_msedge_dev_mac.sh +11 -0
- package/bin/reinstall_msedge_dev_win.ps1 +22 -0
- package/bin/reinstall_msedge_stable_linux.sh +40 -0
- package/bin/reinstall_msedge_stable_mac.sh +11 -0
- package/bin/reinstall_msedge_stable_win.ps1 +23 -0
- package/browsers.json +64 -0
- package/cli.js +17 -0
- package/index.d.ts +17 -0
- package/index.js +33 -0
- package/index.mjs +28 -0
- package/lib/androidServerImpl.js +69 -0
- package/lib/browserServerImpl.js +92 -0
- package/lib/cli/driver.js +97 -0
- package/lib/cli/program.js +582 -0
- package/lib/cli/programWithTestStub.js +67 -0
- package/lib/client/accessibility.js +50 -0
- package/lib/client/android.js +473 -0
- package/lib/client/api.js +272 -0
- package/lib/client/artifact.js +79 -0
- package/lib/client/browser.js +145 -0
- package/lib/client/browserContext.js +509 -0
- package/lib/client/browserType.js +233 -0
- package/lib/client/cdpSession.js +53 -0
- package/lib/client/channelOwner.js +229 -0
- package/lib/client/clientHelper.js +57 -0
- package/lib/client/clientInstrumentation.js +40 -0
- package/lib/client/connection.js +327 -0
- package/lib/client/consoleMessage.js +55 -0
- package/lib/client/coverage.js +41 -0
- package/lib/client/dialog.js +57 -0
- package/lib/client/download.js +62 -0
- package/lib/client/electron.js +130 -0
- package/lib/client/elementHandle.js +291 -0
- package/lib/client/errors.js +77 -0
- package/lib/client/events.js +93 -0
- package/lib/client/fetch.js +343 -0
- package/lib/client/fileChooser.js +45 -0
- package/lib/client/frame.js +506 -0
- package/lib/client/harRouter.js +93 -0
- package/lib/client/input.js +111 -0
- package/lib/client/jsHandle.js +123 -0
- package/lib/client/jsonPipe.js +35 -0
- package/lib/client/localUtils.js +35 -0
- package/lib/client/locator.js +432 -0
- package/lib/client/network.js +601 -0
- package/lib/client/page.js +707 -0
- package/lib/client/playwright.js +74 -0
- package/lib/client/selectors.js +67 -0
- package/lib/client/stream.js +54 -0
- package/lib/client/tracing.js +135 -0
- package/lib/client/types.js +24 -0
- package/lib/client/video.js +51 -0
- package/lib/client/waiter.js +158 -0
- package/lib/client/webError.js +37 -0
- package/lib/client/worker.js +71 -0
- package/lib/client/writableStream.js +54 -0
- package/lib/common/socksProxy.js +569 -0
- package/lib/common/timeoutSettings.js +73 -0
- package/lib/common/types.js +5 -0
- package/lib/generated/consoleApiSource.js +7 -0
- package/lib/generated/injectedScriptSource.js +7 -0
- package/lib/generated/recorderSource.js +7 -0
- package/lib/generated/utilityScriptSource.js +7 -0
- package/lib/image_tools/colorUtils.js +98 -0
- package/lib/image_tools/compare.js +108 -0
- package/lib/image_tools/imageChannel.js +70 -0
- package/lib/image_tools/stats.js +102 -0
- package/lib/inProcessFactory.js +54 -0
- package/lib/inprocess.js +20 -0
- package/lib/outofprocess.js +67 -0
- package/lib/protocol/debug.js +27 -0
- package/lib/protocol/serializers.js +172 -0
- package/lib/protocol/transport.js +82 -0
- package/lib/protocol/validator.js +2599 -0
- package/lib/protocol/validatorPrimitives.js +139 -0
- package/lib/remote/playwrightConnection.js +274 -0
- package/lib/remote/playwrightServer.js +110 -0
- package/lib/server/accessibility.js +62 -0
- package/lib/server/android/android.js +441 -0
- package/lib/server/android/backendAdb.js +172 -0
- package/lib/server/artifact.js +104 -0
- package/lib/server/browser.js +129 -0
- package/lib/server/browserContext.js +609 -0
- package/lib/server/browserType.js +300 -0
- package/lib/server/chromium/appIcon.png +0 -0
- package/lib/server/chromium/chromium.js +346 -0
- package/lib/server/chromium/chromiumSwitches.js +41 -0
- package/lib/server/chromium/crAccessibility.js +237 -0
- package/lib/server/chromium/crBrowser.js +521 -0
- package/lib/server/chromium/crConnection.js +228 -0
- package/lib/server/chromium/crCoverage.js +246 -0
- package/lib/server/chromium/crDevTools.js +104 -0
- package/lib/server/chromium/crDragDrop.js +144 -0
- package/lib/server/chromium/crExecutionContext.js +156 -0
- package/lib/server/chromium/crInput.js +171 -0
- package/lib/server/chromium/crNetworkManager.js +723 -0
- package/lib/server/chromium/crPage.js +1173 -0
- package/lib/server/chromium/crPdf.js +147 -0
- package/lib/server/chromium/crProtocolHelper.js +131 -0
- package/lib/server/chromium/crServiceWorker.js +115 -0
- package/lib/server/chromium/defaultFontFamilies.js +145 -0
- package/lib/server/chromium/videoRecorder.js +155 -0
- package/lib/server/console.js +59 -0
- package/lib/server/cookieStore.js +112 -0
- package/lib/server/debugController.js +236 -0
- package/lib/server/debugger.js +132 -0
- package/lib/server/deviceDescriptors.js +21 -0
- package/lib/server/deviceDescriptorsSource.json +1549 -0
- package/lib/server/dialog.js +70 -0
- package/lib/server/dispatchers/androidDispatcher.js +193 -0
- package/lib/server/dispatchers/artifactDispatcher.js +118 -0
- package/lib/server/dispatchers/browserContextDispatcher.js +306 -0
- package/lib/server/dispatchers/browserDispatcher.js +170 -0
- package/lib/server/dispatchers/browserTypeDispatcher.js +55 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +48 -0
- package/lib/server/dispatchers/debugControllerDispatcher.js +103 -0
- package/lib/server/dispatchers/dialogDispatcher.js +44 -0
- package/lib/server/dispatchers/dispatcher.js +400 -0
- package/lib/server/dispatchers/electronDispatcher.js +80 -0
- package/lib/server/dispatchers/elementHandlerDispatcher.js +228 -0
- package/lib/server/dispatchers/frameDispatcher.js +287 -0
- package/lib/server/dispatchers/jsHandleDispatcher.js +102 -0
- package/lib/server/dispatchers/jsonPipeDispatcher.js +61 -0
- package/lib/server/dispatchers/localUtilsDispatcher.js +399 -0
- package/lib/server/dispatchers/networkDispatchers.js +221 -0
- package/lib/server/dispatchers/pageDispatcher.js +363 -0
- package/lib/server/dispatchers/playwrightDispatcher.js +105 -0
- package/lib/server/dispatchers/selectorsDispatcher.js +36 -0
- package/lib/server/dispatchers/streamDispatcher.js +62 -0
- package/lib/server/dispatchers/tracingDispatcher.js +54 -0
- package/lib/server/dispatchers/writableStreamDispatcher.js +55 -0
- package/lib/server/dom.js +808 -0
- package/lib/server/download.js +53 -0
- package/lib/server/electron/electron.js +254 -0
- package/lib/server/electron/loader.js +57 -0
- package/lib/server/errors.js +68 -0
- package/lib/server/fetch.js +611 -0
- package/lib/server/fileChooser.js +42 -0
- package/lib/server/fileUploadUtils.js +71 -0
- package/lib/server/firefox/ffAccessibility.js +215 -0
- package/lib/server/firefox/ffBrowser.js +447 -0
- package/lib/server/firefox/ffConnection.js +168 -0
- package/lib/server/firefox/ffExecutionContext.js +138 -0
- package/lib/server/firefox/ffInput.js +150 -0
- package/lib/server/firefox/ffNetworkManager.js +231 -0
- package/lib/server/firefox/ffPage.js +558 -0
- package/lib/server/firefox/firefox.js +91 -0
- package/lib/server/formData.js +75 -0
- package/lib/server/frameSelectors.js +171 -0
- package/lib/server/frames.js +1597 -0
- package/lib/server/har/harRecorder.js +139 -0
- package/lib/server/har/harTracer.js +539 -0
- package/lib/server/helper.js +103 -0
- package/lib/server/index.js +96 -0
- package/lib/server/input.js +301 -0
- package/lib/server/instrumentation.js +74 -0
- package/lib/server/isomorphic/utilityScriptSerializers.js +212 -0
- package/lib/server/javascript.js +305 -0
- package/lib/server/launchApp.js +90 -0
- package/lib/server/macEditingCommands.js +139 -0
- package/lib/server/network.js +607 -0
- package/lib/server/page.js +793 -0
- package/lib/server/pipeTransport.js +85 -0
- package/lib/server/playwright.js +82 -0
- package/lib/server/progress.js +102 -0
- package/lib/server/protocolError.js +49 -0
- package/lib/server/recorder/codeGenerator.js +153 -0
- package/lib/server/recorder/csharp.js +310 -0
- package/lib/server/recorder/java.js +216 -0
- package/lib/server/recorder/javascript.js +229 -0
- package/lib/server/recorder/jsonl.js +47 -0
- package/lib/server/recorder/language.js +44 -0
- package/lib/server/recorder/python.js +275 -0
- package/lib/server/recorder/recorderActions.js +5 -0
- package/lib/server/recorder/recorderApp.js +181 -0
- package/lib/server/recorder/recorderUtils.js +48 -0
- package/lib/server/recorder/utils.js +45 -0
- package/lib/server/recorder.js +700 -0
- package/lib/server/registry/browserFetcher.js +168 -0
- package/lib/server/registry/dependencies.js +322 -0
- package/lib/server/registry/index.js +925 -0
- package/lib/server/registry/nativeDeps.js +383 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +138 -0
- package/lib/server/screenshotter.js +354 -0
- package/lib/server/selectors.js +73 -0
- package/lib/server/socksInterceptor.js +100 -0
- package/lib/server/trace/recorder/snapshotter.js +168 -0
- package/lib/server/trace/recorder/snapshotterInjected.js +493 -0
- package/lib/server/trace/recorder/tracing.js +552 -0
- package/lib/server/trace/test/inMemorySnapshotter.js +93 -0
- package/lib/server/trace/viewer/traceViewer.js +229 -0
- package/lib/server/transport.js +191 -0
- package/lib/server/types.js +24 -0
- package/lib/server/usKeyboardLayout.js +555 -0
- package/lib/server/webkit/webkit.js +87 -0
- package/lib/server/webkit/wkAccessibility.js +194 -0
- package/lib/server/webkit/wkBrowser.js +328 -0
- package/lib/server/webkit/wkConnection.js +173 -0
- package/lib/server/webkit/wkExecutionContext.js +146 -0
- package/lib/server/webkit/wkInput.js +169 -0
- package/lib/server/webkit/wkInterceptableRequest.js +158 -0
- package/lib/server/webkit/wkPage.js +1198 -0
- package/lib/server/webkit/wkProvisionalPage.js +59 -0
- package/lib/server/webkit/wkWorkers.js +104 -0
- package/lib/third_party/diff_match_patch.js +2222 -0
- package/lib/third_party/pixelmatch.js +255 -0
- package/lib/utils/ascii.js +31 -0
- package/lib/utils/comparators.js +171 -0
- package/lib/utils/crypto.js +33 -0
- package/lib/utils/debug.js +46 -0
- package/lib/utils/debugLogger.js +89 -0
- package/lib/utils/env.js +47 -0
- package/lib/utils/eventsHelper.js +38 -0
- package/lib/utils/fileUtils.js +66 -0
- package/lib/utils/glob.js +83 -0
- package/lib/utils/happy-eyeballs.js +154 -0
- package/lib/utils/headers.js +52 -0
- package/lib/utils/hostPlatform.js +124 -0
- package/lib/utils/httpServer.js +195 -0
- package/lib/utils/index.js +324 -0
- package/lib/utils/isomorphic/cssParser.js +250 -0
- package/lib/utils/isomorphic/cssTokenizer.js +979 -0
- package/lib/utils/isomorphic/locatorGenerators.js +651 -0
- package/lib/utils/isomorphic/locatorParser.js +179 -0
- package/lib/utils/isomorphic/locatorUtils.js +62 -0
- package/lib/utils/isomorphic/selectorParser.js +397 -0
- package/lib/utils/isomorphic/stringUtils.js +107 -0
- package/lib/utils/isomorphic/traceUtils.js +39 -0
- package/lib/utils/linuxUtils.js +78 -0
- package/lib/utils/manualPromise.js +109 -0
- package/lib/utils/mimeType.js +29 -0
- package/lib/utils/multimap.js +75 -0
- package/lib/utils/network.js +189 -0
- package/lib/utils/processLauncher.js +248 -0
- package/lib/utils/profiler.js +53 -0
- package/lib/utils/rtti.js +41 -0
- package/lib/utils/semaphore.js +51 -0
- package/lib/utils/spawnAsync.js +45 -0
- package/lib/utils/stackTrace.js +123 -0
- package/lib/utils/task.js +58 -0
- package/lib/utils/time.js +37 -0
- package/lib/utils/timeoutRunner.js +131 -0
- package/lib/utils/traceUtils.js +44 -0
- package/lib/utils/userAgent.js +105 -0
- package/lib/utils/wsServer.js +125 -0
- package/lib/utils/zipFile.js +75 -0
- package/lib/utils/zones.js +99 -0
- package/lib/utilsBundle.js +81 -0
- package/lib/utilsBundleImpl/index.js +51 -0
- package/lib/utilsBundleImpl/xdg-open +1066 -0
- package/lib/vite/htmlReport/index.html +66 -0
- package/lib/vite/recorder/assets/codeMirrorModule-Hs9-1ZG4.css +1 -0
- package/lib/vite/recorder/assets/codeMirrorModule-I9ks4y7D.js +24 -0
- package/lib/vite/recorder/assets/codicon-zGuYmc9o.ttf +0 -0
- package/lib/vite/recorder/assets/index-ljsTwXtJ.css +1 -0
- package/lib/vite/recorder/assets/index-yg8ypzl6.js +47 -0
- package/lib/vite/recorder/index.html +29 -0
- package/lib/vite/recorder/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-GluP1cQ1.js +24 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-fqJB1XDu.js +24 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-y3M3aAqy.js +24 -0
- package/lib/vite/traceViewer/assets/wsPort-Rvwd4WC-.js +69 -0
- package/lib/vite/traceViewer/assets/wsPort-dlD7vDkY.js +69 -0
- package/lib/vite/traceViewer/assets/wsPort-qOE2NWrO.js +69 -0
- package/lib/vite/traceViewer/assets/xtermModule-Yt6xwiJ_.js +9 -0
- package/lib/vite/traceViewer/codeMirrorModule.Hs9-1ZG4.css +1 -0
- package/lib/vite/traceViewer/codicon.zGuYmc9o.ttf +0 -0
- package/lib/vite/traceViewer/index.-g_5lMbJ.css +1 -0
- package/lib/vite/traceViewer/index.4X7zDysg.js +2 -0
- package/lib/vite/traceViewer/index.HkJgzlGy.js +2 -0
- package/lib/vite/traceViewer/index.html +26 -0
- package/lib/vite/traceViewer/index.kRjx5sAJ.js +2 -0
- package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/snapshot.html +21 -0
- package/lib/vite/traceViewer/sw.bundle.js +4 -0
- package/lib/vite/traceViewer/uiMode.1Wcp_Kto.js +10 -0
- package/lib/vite/traceViewer/uiMode.GTNzARcV.js +10 -0
- package/lib/vite/traceViewer/uiMode.html +17 -0
- package/lib/vite/traceViewer/uiMode.pWy0Re7G.css +1 -0
- package/lib/vite/traceViewer/uiMode.zV-7Lf9v.js +10 -0
- package/lib/vite/traceViewer/wsPort.kSgQKQ0y.css +1 -0
- package/lib/vite/traceViewer/xtermModule.0lwXJFHT.css +32 -0
- package/lib/zipBundle.js +25 -0
- package/lib/zipBundleImpl.js +5 -0
- package/package.json +43 -0
- package/types/protocol.d.ts +20304 -0
- package/types/structs.d.ts +45 -0
- package/types/types.d.ts +20626 -0
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Page = exports.BindingCall = void 0;
|
|
7
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _errors = require("./errors");
|
|
10
|
+
var _network = require("../utils/network");
|
|
11
|
+
var _timeoutSettings = require("../common/timeoutSettings");
|
|
12
|
+
var _utils = require("../utils");
|
|
13
|
+
var _fileUtils = require("../utils/fileUtils");
|
|
14
|
+
var _accessibility = require("./accessibility");
|
|
15
|
+
var _artifact = require("./artifact");
|
|
16
|
+
var _channelOwner = require("./channelOwner");
|
|
17
|
+
var _clientHelper = require("./clientHelper");
|
|
18
|
+
var _coverage = require("./coverage");
|
|
19
|
+
var _download = require("./download");
|
|
20
|
+
var _elementHandle = require("./elementHandle");
|
|
21
|
+
var _events = require("./events");
|
|
22
|
+
var _fileChooser = require("./fileChooser");
|
|
23
|
+
var _frame = require("./frame");
|
|
24
|
+
var _input = require("./input");
|
|
25
|
+
var _jsHandle = require("./jsHandle");
|
|
26
|
+
var _stringUtils = require("../utils/isomorphic/stringUtils");
|
|
27
|
+
var _network2 = require("./network");
|
|
28
|
+
var _video = require("./video");
|
|
29
|
+
var _waiter = require("./waiter");
|
|
30
|
+
var _worker = require("./worker");
|
|
31
|
+
var _harRouter = require("./harRouter");
|
|
32
|
+
let _Symbol$asyncDispose;
|
|
33
|
+
/**
|
|
34
|
+
* Copyright 2017 Google Inc. All rights reserved.
|
|
35
|
+
* Modifications copyright (c) Microsoft Corporation.
|
|
36
|
+
*
|
|
37
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
38
|
+
* you may not use this file except in compliance with the License.
|
|
39
|
+
* You may obtain a copy of the License at
|
|
40
|
+
*
|
|
41
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
42
|
+
*
|
|
43
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
44
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
45
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
46
|
+
* See the License for the specific language governing permissions and
|
|
47
|
+
* limitations under the License.
|
|
48
|
+
*/
|
|
49
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
50
|
+
_Symbol$asyncDispose = Symbol.asyncDispose;
|
|
51
|
+
class Page extends _channelOwner.ChannelOwner {
|
|
52
|
+
static from(page) {
|
|
53
|
+
return page._object;
|
|
54
|
+
}
|
|
55
|
+
static fromNullable(page) {
|
|
56
|
+
return page ? Page.from(page) : null;
|
|
57
|
+
}
|
|
58
|
+
constructor(parent, type, guid, initializer) {
|
|
59
|
+
super(parent, type, guid, initializer);
|
|
60
|
+
this._browserContext = void 0;
|
|
61
|
+
this._ownedContext = void 0;
|
|
62
|
+
this._mainFrame = void 0;
|
|
63
|
+
this._frames = new Set();
|
|
64
|
+
this._workers = new Set();
|
|
65
|
+
this._closed = false;
|
|
66
|
+
this._closedOrCrashedScope = new _utils.LongStandingScope();
|
|
67
|
+
this._viewportSize = void 0;
|
|
68
|
+
this._routes = [];
|
|
69
|
+
this.accessibility = void 0;
|
|
70
|
+
this.coverage = void 0;
|
|
71
|
+
this.keyboard = void 0;
|
|
72
|
+
this.mouse = void 0;
|
|
73
|
+
this.request = void 0;
|
|
74
|
+
this.touchscreen = void 0;
|
|
75
|
+
this._bindings = new Map();
|
|
76
|
+
this._timeoutSettings = void 0;
|
|
77
|
+
this._video = null;
|
|
78
|
+
this._opener = void 0;
|
|
79
|
+
this._closeReason = void 0;
|
|
80
|
+
this._closeWasCalled = false;
|
|
81
|
+
this._harRouters = [];
|
|
82
|
+
this._locatorHandlers = new Map();
|
|
83
|
+
this._browserContext = parent;
|
|
84
|
+
this._timeoutSettings = new _timeoutSettings.TimeoutSettings(this._browserContext._timeoutSettings);
|
|
85
|
+
this.accessibility = new _accessibility.Accessibility(this._channel);
|
|
86
|
+
this.keyboard = new _input.Keyboard(this);
|
|
87
|
+
this.mouse = new _input.Mouse(this);
|
|
88
|
+
this.request = this._browserContext.request;
|
|
89
|
+
this.touchscreen = new _input.Touchscreen(this);
|
|
90
|
+
this._mainFrame = _frame.Frame.from(initializer.mainFrame);
|
|
91
|
+
this._mainFrame._page = this;
|
|
92
|
+
this._frames.add(this._mainFrame);
|
|
93
|
+
this._viewportSize = initializer.viewportSize || null;
|
|
94
|
+
this._closed = initializer.isClosed;
|
|
95
|
+
this._opener = Page.fromNullable(initializer.opener);
|
|
96
|
+
this._channel.on('bindingCall', ({
|
|
97
|
+
binding
|
|
98
|
+
}) => this._onBinding(BindingCall.from(binding)));
|
|
99
|
+
this._channel.on('close', () => this._onClose());
|
|
100
|
+
this._channel.on('crash', () => this._onCrash());
|
|
101
|
+
this._channel.on('download', ({
|
|
102
|
+
url,
|
|
103
|
+
suggestedFilename,
|
|
104
|
+
artifact
|
|
105
|
+
}) => {
|
|
106
|
+
const artifactObject = _artifact.Artifact.from(artifact);
|
|
107
|
+
this.emit(_events.Events.Page.Download, new _download.Download(this, url, suggestedFilename, artifactObject));
|
|
108
|
+
});
|
|
109
|
+
this._channel.on('fileChooser', ({
|
|
110
|
+
element,
|
|
111
|
+
isMultiple
|
|
112
|
+
}) => this.emit(_events.Events.Page.FileChooser, new _fileChooser.FileChooser(this, _elementHandle.ElementHandle.from(element), isMultiple)));
|
|
113
|
+
this._channel.on('frameAttached', ({
|
|
114
|
+
frame
|
|
115
|
+
}) => this._onFrameAttached(_frame.Frame.from(frame)));
|
|
116
|
+
this._channel.on('frameDetached', ({
|
|
117
|
+
frame
|
|
118
|
+
}) => this._onFrameDetached(_frame.Frame.from(frame)));
|
|
119
|
+
this._channel.on('locatorHandlerTriggered', ({
|
|
120
|
+
uid
|
|
121
|
+
}) => this._onLocatorHandlerTriggered(uid));
|
|
122
|
+
this._channel.on('route', ({
|
|
123
|
+
route
|
|
124
|
+
}) => this._onRoute(_network2.Route.from(route)));
|
|
125
|
+
this._channel.on('video', ({
|
|
126
|
+
artifact
|
|
127
|
+
}) => {
|
|
128
|
+
const artifactObject = _artifact.Artifact.from(artifact);
|
|
129
|
+
this._forceVideo()._artifactReady(artifactObject);
|
|
130
|
+
});
|
|
131
|
+
this._channel.on('webSocket', ({
|
|
132
|
+
webSocket
|
|
133
|
+
}) => this.emit(_events.Events.Page.WebSocket, _network2.WebSocket.from(webSocket)));
|
|
134
|
+
this._channel.on('worker', ({
|
|
135
|
+
worker
|
|
136
|
+
}) => this._onWorker(_worker.Worker.from(worker)));
|
|
137
|
+
this.coverage = new _coverage.Coverage(this._channel);
|
|
138
|
+
this.once(_events.Events.Page.Close, () => this._closedOrCrashedScope.close(this._closeErrorWithReason()));
|
|
139
|
+
this.once(_events.Events.Page.Crash, () => this._closedOrCrashedScope.close(new _errors.TargetClosedError()));
|
|
140
|
+
this._setEventToSubscriptionMapping(new Map([[_events.Events.Page.Console, 'console'], [_events.Events.Page.Dialog, 'dialog'], [_events.Events.Page.Request, 'request'], [_events.Events.Page.Response, 'response'], [_events.Events.Page.RequestFinished, 'requestFinished'], [_events.Events.Page.RequestFailed, 'requestFailed'], [_events.Events.Page.FileChooser, 'fileChooser']]));
|
|
141
|
+
}
|
|
142
|
+
_onFrameAttached(frame) {
|
|
143
|
+
frame._page = this;
|
|
144
|
+
this._frames.add(frame);
|
|
145
|
+
if (frame._parentFrame) frame._parentFrame._childFrames.add(frame);
|
|
146
|
+
this.emit(_events.Events.Page.FrameAttached, frame);
|
|
147
|
+
}
|
|
148
|
+
_onFrameDetached(frame) {
|
|
149
|
+
this._frames.delete(frame);
|
|
150
|
+
frame._detached = true;
|
|
151
|
+
if (frame._parentFrame) frame._parentFrame._childFrames.delete(frame);
|
|
152
|
+
this.emit(_events.Events.Page.FrameDetached, frame);
|
|
153
|
+
}
|
|
154
|
+
async _onRoute(route) {
|
|
155
|
+
route._context = this.context();
|
|
156
|
+
const routeHandlers = this._routes.slice();
|
|
157
|
+
for (const routeHandler of routeHandlers) {
|
|
158
|
+
// If the page was closed we stall all requests right away.
|
|
159
|
+
if (this._closeWasCalled || this._browserContext._closeWasCalled) return;
|
|
160
|
+
if (!routeHandler.matches(route.request().url())) continue;
|
|
161
|
+
const index = this._routes.indexOf(routeHandler);
|
|
162
|
+
if (index === -1) continue;
|
|
163
|
+
if (routeHandler.willExpire()) this._routes.splice(index, 1);
|
|
164
|
+
const handled = await routeHandler.handle(route);
|
|
165
|
+
if (!this._routes.length) this._wrapApiCall(() => this._updateInterceptionPatterns(), true).catch(() => {});
|
|
166
|
+
if (handled) return;
|
|
167
|
+
}
|
|
168
|
+
await this._browserContext._onRoute(route);
|
|
169
|
+
}
|
|
170
|
+
async _onBinding(bindingCall) {
|
|
171
|
+
const func = this._bindings.get(bindingCall._initializer.name);
|
|
172
|
+
if (func) {
|
|
173
|
+
await bindingCall.call(func);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
await this._browserContext._onBinding(bindingCall);
|
|
177
|
+
}
|
|
178
|
+
_onWorker(worker) {
|
|
179
|
+
this._workers.add(worker);
|
|
180
|
+
worker._page = this;
|
|
181
|
+
this.emit(_events.Events.Page.Worker, worker);
|
|
182
|
+
}
|
|
183
|
+
_onClose() {
|
|
184
|
+
this._closed = true;
|
|
185
|
+
this._browserContext._pages.delete(this);
|
|
186
|
+
this._browserContext._backgroundPages.delete(this);
|
|
187
|
+
this._disposeHarRouters();
|
|
188
|
+
this.emit(_events.Events.Page.Close, this);
|
|
189
|
+
}
|
|
190
|
+
_onCrash() {
|
|
191
|
+
this.emit(_events.Events.Page.Crash, this);
|
|
192
|
+
}
|
|
193
|
+
context() {
|
|
194
|
+
return this._browserContext;
|
|
195
|
+
}
|
|
196
|
+
async opener() {
|
|
197
|
+
if (!this._opener || this._opener.isClosed()) return null;
|
|
198
|
+
return this._opener;
|
|
199
|
+
}
|
|
200
|
+
mainFrame() {
|
|
201
|
+
return this._mainFrame;
|
|
202
|
+
}
|
|
203
|
+
frame(frameSelector) {
|
|
204
|
+
const name = (0, _utils.isString)(frameSelector) ? frameSelector : frameSelector.name;
|
|
205
|
+
const url = (0, _utils.isObject)(frameSelector) ? frameSelector.url : undefined;
|
|
206
|
+
(0, _utils.assert)(name || url, 'Either name or url matcher should be specified');
|
|
207
|
+
return this.frames().find(f => {
|
|
208
|
+
if (name) return f.name() === name;
|
|
209
|
+
return (0, _network.urlMatches)(this._browserContext._options.baseURL, f.url(), url);
|
|
210
|
+
}) || null;
|
|
211
|
+
}
|
|
212
|
+
frames() {
|
|
213
|
+
return [...this._frames];
|
|
214
|
+
}
|
|
215
|
+
setDefaultNavigationTimeout(timeout) {
|
|
216
|
+
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
|
|
217
|
+
this._wrapApiCall(async () => {
|
|
218
|
+
this._channel.setDefaultNavigationTimeoutNoReply({
|
|
219
|
+
timeout
|
|
220
|
+
}).catch(() => {});
|
|
221
|
+
}, true);
|
|
222
|
+
}
|
|
223
|
+
setDefaultTimeout(timeout) {
|
|
224
|
+
this._timeoutSettings.setDefaultTimeout(timeout);
|
|
225
|
+
this._wrapApiCall(async () => {
|
|
226
|
+
this._channel.setDefaultTimeoutNoReply({
|
|
227
|
+
timeout
|
|
228
|
+
}).catch(() => {});
|
|
229
|
+
}, true);
|
|
230
|
+
}
|
|
231
|
+
_forceVideo() {
|
|
232
|
+
if (!this._video) this._video = new _video.Video(this, this._connection);
|
|
233
|
+
return this._video;
|
|
234
|
+
}
|
|
235
|
+
video() {
|
|
236
|
+
// Note: we are creating Video object lazily, because we do not know
|
|
237
|
+
// BrowserContextOptions when constructing the page - it is assigned
|
|
238
|
+
// too late during launchPersistentContext.
|
|
239
|
+
if (!this._browserContext._options.recordVideo) return null;
|
|
240
|
+
return this._forceVideo();
|
|
241
|
+
}
|
|
242
|
+
async $(selector, options) {
|
|
243
|
+
return await this._mainFrame.$(selector, options);
|
|
244
|
+
}
|
|
245
|
+
async waitForSelector(selector, options) {
|
|
246
|
+
return await this._mainFrame.waitForSelector(selector, options);
|
|
247
|
+
}
|
|
248
|
+
async dispatchEvent(selector, type, eventInit, options) {
|
|
249
|
+
return await this._mainFrame.dispatchEvent(selector, type, eventInit, options);
|
|
250
|
+
}
|
|
251
|
+
async evaluateHandle(pageFunction, arg) {
|
|
252
|
+
(0, _jsHandle.assertMaxArguments)(arguments.length, 2);
|
|
253
|
+
return await this._mainFrame.evaluateHandle(pageFunction, arg);
|
|
254
|
+
}
|
|
255
|
+
async $eval(selector, pageFunction, arg) {
|
|
256
|
+
(0, _jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
257
|
+
return await this._mainFrame.$eval(selector, pageFunction, arg);
|
|
258
|
+
}
|
|
259
|
+
async $$eval(selector, pageFunction, arg) {
|
|
260
|
+
(0, _jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
261
|
+
return await this._mainFrame.$$eval(selector, pageFunction, arg);
|
|
262
|
+
}
|
|
263
|
+
async $$(selector) {
|
|
264
|
+
return await this._mainFrame.$$(selector);
|
|
265
|
+
}
|
|
266
|
+
async addScriptTag(options = {}) {
|
|
267
|
+
return await this._mainFrame.addScriptTag(options);
|
|
268
|
+
}
|
|
269
|
+
async addStyleTag(options = {}) {
|
|
270
|
+
return await this._mainFrame.addStyleTag(options);
|
|
271
|
+
}
|
|
272
|
+
async exposeFunction(name, callback) {
|
|
273
|
+
await this._channel.exposeBinding({
|
|
274
|
+
name
|
|
275
|
+
});
|
|
276
|
+
const binding = (source, ...args) => callback(...args);
|
|
277
|
+
this._bindings.set(name, binding);
|
|
278
|
+
}
|
|
279
|
+
async exposeBinding(name, callback, options = {}) {
|
|
280
|
+
await this._channel.exposeBinding({
|
|
281
|
+
name,
|
|
282
|
+
needsHandle: options.handle
|
|
283
|
+
});
|
|
284
|
+
this._bindings.set(name, callback);
|
|
285
|
+
}
|
|
286
|
+
async setExtraHTTPHeaders(headers) {
|
|
287
|
+
(0, _network2.validateHeaders)(headers);
|
|
288
|
+
await this._channel.setExtraHTTPHeaders({
|
|
289
|
+
headers: (0, _utils.headersObjectToArray)(headers)
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
url() {
|
|
293
|
+
return this._mainFrame.url();
|
|
294
|
+
}
|
|
295
|
+
async content() {
|
|
296
|
+
return await this._mainFrame.content();
|
|
297
|
+
}
|
|
298
|
+
async setContent(html, options) {
|
|
299
|
+
return await this._mainFrame.setContent(html, options);
|
|
300
|
+
}
|
|
301
|
+
async goto(url, options) {
|
|
302
|
+
return await this._mainFrame.goto(url, options);
|
|
303
|
+
}
|
|
304
|
+
async reload(options = {}) {
|
|
305
|
+
const waitUntil = (0, _frame.verifyLoadState)('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
|
|
306
|
+
return _network2.Response.fromNullable((await this._channel.reload({
|
|
307
|
+
...options,
|
|
308
|
+
waitUntil
|
|
309
|
+
})).response);
|
|
310
|
+
}
|
|
311
|
+
async handleLocator(locator, handler) {
|
|
312
|
+
if (locator._frame !== this._mainFrame) throw new Error(`Locator must belong to the main frame of this page`);
|
|
313
|
+
const {
|
|
314
|
+
uid
|
|
315
|
+
} = await this._channel.registerLocatorHandler({
|
|
316
|
+
selector: locator._selector
|
|
317
|
+
});
|
|
318
|
+
this._locatorHandlers.set(uid, handler);
|
|
319
|
+
}
|
|
320
|
+
async _onLocatorHandlerTriggered(uid) {
|
|
321
|
+
try {
|
|
322
|
+
const handler = this._locatorHandlers.get(uid);
|
|
323
|
+
await (handler === null || handler === void 0 ? void 0 : handler());
|
|
324
|
+
} finally {
|
|
325
|
+
this._channel.resolveLocatorHandlerNoReply({
|
|
326
|
+
uid
|
|
327
|
+
}).catch(() => {});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
async waitForLoadState(state, options) {
|
|
331
|
+
return await this._mainFrame.waitForLoadState(state, options);
|
|
332
|
+
}
|
|
333
|
+
async waitForNavigation(options) {
|
|
334
|
+
return await this._mainFrame.waitForNavigation(options);
|
|
335
|
+
}
|
|
336
|
+
async waitForURL(url, options) {
|
|
337
|
+
return await this._mainFrame.waitForURL(url, options);
|
|
338
|
+
}
|
|
339
|
+
async waitForRequest(urlOrPredicate, options = {}) {
|
|
340
|
+
const predicate = async request => {
|
|
341
|
+
if ((0, _utils.isString)(urlOrPredicate) || (0, _utils.isRegExp)(urlOrPredicate)) return (0, _network.urlMatches)(this._browserContext._options.baseURL, request.url(), urlOrPredicate);
|
|
342
|
+
return await urlOrPredicate(request);
|
|
343
|
+
};
|
|
344
|
+
const trimmedUrl = trimUrl(urlOrPredicate);
|
|
345
|
+
const logLine = trimmedUrl ? `waiting for request ${trimmedUrl}` : undefined;
|
|
346
|
+
return await this._waitForEvent(_events.Events.Page.Request, {
|
|
347
|
+
predicate,
|
|
348
|
+
timeout: options.timeout
|
|
349
|
+
}, logLine);
|
|
350
|
+
}
|
|
351
|
+
async waitForResponse(urlOrPredicate, options = {}) {
|
|
352
|
+
const predicate = async response => {
|
|
353
|
+
if ((0, _utils.isString)(urlOrPredicate) || (0, _utils.isRegExp)(urlOrPredicate)) return (0, _network.urlMatches)(this._browserContext._options.baseURL, response.url(), urlOrPredicate);
|
|
354
|
+
return await urlOrPredicate(response);
|
|
355
|
+
};
|
|
356
|
+
const trimmedUrl = trimUrl(urlOrPredicate);
|
|
357
|
+
const logLine = trimmedUrl ? `waiting for response ${trimmedUrl}` : undefined;
|
|
358
|
+
return await this._waitForEvent(_events.Events.Page.Response, {
|
|
359
|
+
predicate,
|
|
360
|
+
timeout: options.timeout
|
|
361
|
+
}, logLine);
|
|
362
|
+
}
|
|
363
|
+
async waitForEvent(event, optionsOrPredicate = {}) {
|
|
364
|
+
return await this._waitForEvent(event, optionsOrPredicate, `waiting for event "${event}"`);
|
|
365
|
+
}
|
|
366
|
+
_closeErrorWithReason() {
|
|
367
|
+
return new _errors.TargetClosedError(this._closeReason || this._browserContext._effectiveCloseReason());
|
|
368
|
+
}
|
|
369
|
+
async _waitForEvent(event, optionsOrPredicate, logLine) {
|
|
370
|
+
return await this._wrapApiCall(async () => {
|
|
371
|
+
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);
|
|
372
|
+
const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;
|
|
373
|
+
const waiter = _waiter.Waiter.createForEvent(this, event);
|
|
374
|
+
if (logLine) waiter.log(logLine);
|
|
375
|
+
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
|
|
376
|
+
if (event !== _events.Events.Page.Crash) waiter.rejectOnEvent(this, _events.Events.Page.Crash, new Error('Page crashed'));
|
|
377
|
+
if (event !== _events.Events.Page.Close) waiter.rejectOnEvent(this, _events.Events.Page.Close, () => this._closeErrorWithReason());
|
|
378
|
+
const result = await waiter.waitForEvent(this, event, predicate);
|
|
379
|
+
waiter.dispose();
|
|
380
|
+
return result;
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
async goBack(options = {}) {
|
|
384
|
+
const waitUntil = (0, _frame.verifyLoadState)('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
|
|
385
|
+
return _network2.Response.fromNullable((await this._channel.goBack({
|
|
386
|
+
...options,
|
|
387
|
+
waitUntil
|
|
388
|
+
})).response);
|
|
389
|
+
}
|
|
390
|
+
async goForward(options = {}) {
|
|
391
|
+
const waitUntil = (0, _frame.verifyLoadState)('waitUntil', options.waitUntil === undefined ? 'load' : options.waitUntil);
|
|
392
|
+
return _network2.Response.fromNullable((await this._channel.goForward({
|
|
393
|
+
...options,
|
|
394
|
+
waitUntil
|
|
395
|
+
})).response);
|
|
396
|
+
}
|
|
397
|
+
async emulateMedia(options = {}) {
|
|
398
|
+
await this._channel.emulateMedia({
|
|
399
|
+
media: options.media === null ? 'no-override' : options.media,
|
|
400
|
+
colorScheme: options.colorScheme === null ? 'no-override' : options.colorScheme,
|
|
401
|
+
reducedMotion: options.reducedMotion === null ? 'no-override' : options.reducedMotion,
|
|
402
|
+
forcedColors: options.forcedColors === null ? 'no-override' : options.forcedColors
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
async setViewportSize(viewportSize) {
|
|
406
|
+
this._viewportSize = viewportSize;
|
|
407
|
+
await this._channel.setViewportSize({
|
|
408
|
+
viewportSize
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
viewportSize() {
|
|
412
|
+
return this._viewportSize;
|
|
413
|
+
}
|
|
414
|
+
async evaluate(pageFunction, arg) {
|
|
415
|
+
(0, _jsHandle.assertMaxArguments)(arguments.length, 2);
|
|
416
|
+
return await this._mainFrame.evaluate(pageFunction, arg);
|
|
417
|
+
}
|
|
418
|
+
async addInitScript(script, arg) {
|
|
419
|
+
const source = await (0, _clientHelper.evaluationScript)(script, arg);
|
|
420
|
+
await this._channel.addInitScript({
|
|
421
|
+
source
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
async route(url, handler, options = {}) {
|
|
425
|
+
this._routes.unshift(new _network2.RouteHandler(this._browserContext._options.baseURL, url, handler, options.times));
|
|
426
|
+
await this._updateInterceptionPatterns();
|
|
427
|
+
}
|
|
428
|
+
async routeFromHAR(har, options = {}) {
|
|
429
|
+
if (options.update) {
|
|
430
|
+
await this._browserContext._recordIntoHAR(har, this, options);
|
|
431
|
+
return;
|
|
432
|
+
}
|
|
433
|
+
const harRouter = await _harRouter.HarRouter.create(this._connection.localUtils(), har, options.notFound || 'abort', {
|
|
434
|
+
urlMatch: options.url
|
|
435
|
+
});
|
|
436
|
+
this._harRouters.push(harRouter);
|
|
437
|
+
await harRouter.addPageRoute(this);
|
|
438
|
+
}
|
|
439
|
+
_disposeHarRouters() {
|
|
440
|
+
this._harRouters.forEach(router => router.dispose());
|
|
441
|
+
this._harRouters = [];
|
|
442
|
+
}
|
|
443
|
+
async unrouteAll(options) {
|
|
444
|
+
await this._unrouteInternal(this._routes, [], options === null || options === void 0 ? void 0 : options.behavior);
|
|
445
|
+
this._disposeHarRouters();
|
|
446
|
+
}
|
|
447
|
+
async unroute(url, handler) {
|
|
448
|
+
const removed = [];
|
|
449
|
+
const remaining = [];
|
|
450
|
+
for (const route of this._routes) {
|
|
451
|
+
if ((0, _utils.urlMatchesEqual)(route.url, url) && (!handler || route.handler === handler)) removed.push(route);else remaining.push(route);
|
|
452
|
+
}
|
|
453
|
+
await this._unrouteInternal(removed, remaining, 'default');
|
|
454
|
+
}
|
|
455
|
+
async _unrouteInternal(removed, remaining, behavior) {
|
|
456
|
+
this._routes = remaining;
|
|
457
|
+
await this._updateInterceptionPatterns();
|
|
458
|
+
if (!behavior || behavior === 'default') return;
|
|
459
|
+
const promises = removed.map(routeHandler => routeHandler.stop(behavior));
|
|
460
|
+
await Promise.all(promises);
|
|
461
|
+
}
|
|
462
|
+
async _updateInterceptionPatterns() {
|
|
463
|
+
const patterns = _network2.RouteHandler.prepareInterceptionPatterns(this._routes);
|
|
464
|
+
await this._channel.setNetworkInterceptionPatterns({
|
|
465
|
+
patterns
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
async screenshot(options = {}) {
|
|
469
|
+
const copy = {
|
|
470
|
+
...options,
|
|
471
|
+
mask: undefined
|
|
472
|
+
};
|
|
473
|
+
if (!copy.type) copy.type = (0, _elementHandle.determineScreenshotType)(options);
|
|
474
|
+
if (options.mask) {
|
|
475
|
+
copy.mask = options.mask.map(locator => ({
|
|
476
|
+
frame: locator._frame._channel,
|
|
477
|
+
selector: locator._selector
|
|
478
|
+
}));
|
|
479
|
+
}
|
|
480
|
+
const result = await this._channel.screenshot(copy);
|
|
481
|
+
if (options.path) {
|
|
482
|
+
await (0, _fileUtils.mkdirIfNeeded)(options.path);
|
|
483
|
+
await _fs.default.promises.writeFile(options.path, result.binary);
|
|
484
|
+
}
|
|
485
|
+
return result.binary;
|
|
486
|
+
}
|
|
487
|
+
async _expectScreenshot(options) {
|
|
488
|
+
var _options$screenshotOp, _options$screenshotOp2;
|
|
489
|
+
const mask = (_options$screenshotOp = options.screenshotOptions) !== null && _options$screenshotOp !== void 0 && _options$screenshotOp.mask ? (_options$screenshotOp2 = options.screenshotOptions) === null || _options$screenshotOp2 === void 0 ? void 0 : _options$screenshotOp2.mask.map(locator => ({
|
|
490
|
+
frame: locator._frame._channel,
|
|
491
|
+
selector: locator._selector
|
|
492
|
+
})) : undefined;
|
|
493
|
+
const locator = options.locator ? {
|
|
494
|
+
frame: options.locator._frame._channel,
|
|
495
|
+
selector: options.locator._selector
|
|
496
|
+
} : undefined;
|
|
497
|
+
return await this._channel.expectScreenshot({
|
|
498
|
+
...options,
|
|
499
|
+
isNot: !!options.isNot,
|
|
500
|
+
locator,
|
|
501
|
+
screenshotOptions: {
|
|
502
|
+
...options.screenshotOptions,
|
|
503
|
+
mask
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
async title() {
|
|
508
|
+
return await this._mainFrame.title();
|
|
509
|
+
}
|
|
510
|
+
async bringToFront() {
|
|
511
|
+
await this._channel.bringToFront();
|
|
512
|
+
}
|
|
513
|
+
async [_Symbol$asyncDispose]() {
|
|
514
|
+
await this.close();
|
|
515
|
+
}
|
|
516
|
+
async close(options = {}) {
|
|
517
|
+
this._closeReason = options.reason;
|
|
518
|
+
this._closeWasCalled = true;
|
|
519
|
+
try {
|
|
520
|
+
if (this._ownedContext) await this._ownedContext.close();else await this._channel.close(options);
|
|
521
|
+
} catch (e) {
|
|
522
|
+
if ((0, _errors.isTargetClosedError)(e) && !options.runBeforeUnload) return;
|
|
523
|
+
throw e;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
isClosed() {
|
|
527
|
+
return this._closed;
|
|
528
|
+
}
|
|
529
|
+
async click(selector, options) {
|
|
530
|
+
return await this._mainFrame.click(selector, options);
|
|
531
|
+
}
|
|
532
|
+
async dragAndDrop(source, target, options) {
|
|
533
|
+
return await this._mainFrame.dragAndDrop(source, target, options);
|
|
534
|
+
}
|
|
535
|
+
async dblclick(selector, options) {
|
|
536
|
+
return await this._mainFrame.dblclick(selector, options);
|
|
537
|
+
}
|
|
538
|
+
async tap(selector, options) {
|
|
539
|
+
return await this._mainFrame.tap(selector, options);
|
|
540
|
+
}
|
|
541
|
+
async fill(selector, value, options) {
|
|
542
|
+
return await this._mainFrame.fill(selector, value, options);
|
|
543
|
+
}
|
|
544
|
+
locator(selector, options) {
|
|
545
|
+
return this.mainFrame().locator(selector, options);
|
|
546
|
+
}
|
|
547
|
+
getByTestId(testId) {
|
|
548
|
+
return this.mainFrame().getByTestId(testId);
|
|
549
|
+
}
|
|
550
|
+
getByAltText(text, options) {
|
|
551
|
+
return this.mainFrame().getByAltText(text, options);
|
|
552
|
+
}
|
|
553
|
+
getByLabel(text, options) {
|
|
554
|
+
return this.mainFrame().getByLabel(text, options);
|
|
555
|
+
}
|
|
556
|
+
getByPlaceholder(text, options) {
|
|
557
|
+
return this.mainFrame().getByPlaceholder(text, options);
|
|
558
|
+
}
|
|
559
|
+
getByText(text, options) {
|
|
560
|
+
return this.mainFrame().getByText(text, options);
|
|
561
|
+
}
|
|
562
|
+
getByTitle(text, options) {
|
|
563
|
+
return this.mainFrame().getByTitle(text, options);
|
|
564
|
+
}
|
|
565
|
+
getByRole(role, options = {}) {
|
|
566
|
+
return this.mainFrame().getByRole(role, options);
|
|
567
|
+
}
|
|
568
|
+
frameLocator(selector) {
|
|
569
|
+
return this.mainFrame().frameLocator(selector);
|
|
570
|
+
}
|
|
571
|
+
async focus(selector, options) {
|
|
572
|
+
return await this._mainFrame.focus(selector, options);
|
|
573
|
+
}
|
|
574
|
+
async textContent(selector, options) {
|
|
575
|
+
return await this._mainFrame.textContent(selector, options);
|
|
576
|
+
}
|
|
577
|
+
async innerText(selector, options) {
|
|
578
|
+
return await this._mainFrame.innerText(selector, options);
|
|
579
|
+
}
|
|
580
|
+
async innerHTML(selector, options) {
|
|
581
|
+
return await this._mainFrame.innerHTML(selector, options);
|
|
582
|
+
}
|
|
583
|
+
async getAttribute(selector, name, options) {
|
|
584
|
+
return await this._mainFrame.getAttribute(selector, name, options);
|
|
585
|
+
}
|
|
586
|
+
async inputValue(selector, options) {
|
|
587
|
+
return await this._mainFrame.inputValue(selector, options);
|
|
588
|
+
}
|
|
589
|
+
async isChecked(selector, options) {
|
|
590
|
+
return await this._mainFrame.isChecked(selector, options);
|
|
591
|
+
}
|
|
592
|
+
async isDisabled(selector, options) {
|
|
593
|
+
return await this._mainFrame.isDisabled(selector, options);
|
|
594
|
+
}
|
|
595
|
+
async isEditable(selector, options) {
|
|
596
|
+
return await this._mainFrame.isEditable(selector, options);
|
|
597
|
+
}
|
|
598
|
+
async isEnabled(selector, options) {
|
|
599
|
+
return await this._mainFrame.isEnabled(selector, options);
|
|
600
|
+
}
|
|
601
|
+
async isHidden(selector, options) {
|
|
602
|
+
return await this._mainFrame.isHidden(selector, options);
|
|
603
|
+
}
|
|
604
|
+
async isVisible(selector, options) {
|
|
605
|
+
return await this._mainFrame.isVisible(selector, options);
|
|
606
|
+
}
|
|
607
|
+
async hover(selector, options) {
|
|
608
|
+
return await this._mainFrame.hover(selector, options);
|
|
609
|
+
}
|
|
610
|
+
async selectOption(selector, values, options) {
|
|
611
|
+
return await this._mainFrame.selectOption(selector, values, options);
|
|
612
|
+
}
|
|
613
|
+
async setInputFiles(selector, files, options) {
|
|
614
|
+
return await this._mainFrame.setInputFiles(selector, files, options);
|
|
615
|
+
}
|
|
616
|
+
async type(selector, text, options) {
|
|
617
|
+
return await this._mainFrame.type(selector, text, options);
|
|
618
|
+
}
|
|
619
|
+
async press(selector, key, options) {
|
|
620
|
+
return await this._mainFrame.press(selector, key, options);
|
|
621
|
+
}
|
|
622
|
+
async check(selector, options) {
|
|
623
|
+
return await this._mainFrame.check(selector, options);
|
|
624
|
+
}
|
|
625
|
+
async uncheck(selector, options) {
|
|
626
|
+
return await this._mainFrame.uncheck(selector, options);
|
|
627
|
+
}
|
|
628
|
+
async setChecked(selector, checked, options) {
|
|
629
|
+
return await this._mainFrame.setChecked(selector, checked, options);
|
|
630
|
+
}
|
|
631
|
+
async waitForTimeout(timeout) {
|
|
632
|
+
return await this._mainFrame.waitForTimeout(timeout);
|
|
633
|
+
}
|
|
634
|
+
async waitForFunction(pageFunction, arg, options) {
|
|
635
|
+
return await this._mainFrame.waitForFunction(pageFunction, arg, options);
|
|
636
|
+
}
|
|
637
|
+
workers() {
|
|
638
|
+
return [...this._workers];
|
|
639
|
+
}
|
|
640
|
+
async pause() {
|
|
641
|
+
var _this$_instrumentatio;
|
|
642
|
+
if (require('inspector').url()) return;
|
|
643
|
+
const defaultNavigationTimeout = this._browserContext._timeoutSettings.defaultNavigationTimeout();
|
|
644
|
+
const defaultTimeout = this._browserContext._timeoutSettings.defaultTimeout();
|
|
645
|
+
this._browserContext.setDefaultNavigationTimeout(0);
|
|
646
|
+
this._browserContext.setDefaultTimeout(0);
|
|
647
|
+
(_this$_instrumentatio = this._instrumentation) === null || _this$_instrumentatio === void 0 || _this$_instrumentatio.onWillPause();
|
|
648
|
+
await this._closedOrCrashedScope.safeRace(this.context()._channel.pause());
|
|
649
|
+
this._browserContext.setDefaultNavigationTimeout(defaultNavigationTimeout);
|
|
650
|
+
this._browserContext.setDefaultTimeout(defaultTimeout);
|
|
651
|
+
}
|
|
652
|
+
async pdf(options = {}) {
|
|
653
|
+
const transportOptions = {
|
|
654
|
+
...options
|
|
655
|
+
};
|
|
656
|
+
if (transportOptions.margin) transportOptions.margin = {
|
|
657
|
+
...transportOptions.margin
|
|
658
|
+
};
|
|
659
|
+
if (typeof options.width === 'number') transportOptions.width = options.width + 'px';
|
|
660
|
+
if (typeof options.height === 'number') transportOptions.height = options.height + 'px';
|
|
661
|
+
for (const margin of ['top', 'right', 'bottom', 'left']) {
|
|
662
|
+
const index = margin;
|
|
663
|
+
if (options.margin && typeof options.margin[index] === 'number') transportOptions.margin[index] = transportOptions.margin[index] + 'px';
|
|
664
|
+
}
|
|
665
|
+
const result = await this._channel.pdf(transportOptions);
|
|
666
|
+
if (options.path) {
|
|
667
|
+
await _fs.default.promises.mkdir(_path.default.dirname(options.path), {
|
|
668
|
+
recursive: true
|
|
669
|
+
});
|
|
670
|
+
await _fs.default.promises.writeFile(options.path, result.pdf);
|
|
671
|
+
}
|
|
672
|
+
return result.pdf;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
exports.Page = Page;
|
|
676
|
+
class BindingCall extends _channelOwner.ChannelOwner {
|
|
677
|
+
static from(channel) {
|
|
678
|
+
return channel._object;
|
|
679
|
+
}
|
|
680
|
+
constructor(parent, type, guid, initializer) {
|
|
681
|
+
super(parent, type, guid, initializer);
|
|
682
|
+
}
|
|
683
|
+
async call(func) {
|
|
684
|
+
try {
|
|
685
|
+
const frame = _frame.Frame.from(this._initializer.frame);
|
|
686
|
+
const source = {
|
|
687
|
+
context: frame._page.context(),
|
|
688
|
+
page: frame._page,
|
|
689
|
+
frame
|
|
690
|
+
};
|
|
691
|
+
let result;
|
|
692
|
+
if (this._initializer.handle) result = await func(source, _jsHandle.JSHandle.from(this._initializer.handle));else result = await func(source, ...this._initializer.args.map(_jsHandle.parseResult));
|
|
693
|
+
this._channel.resolve({
|
|
694
|
+
result: (0, _jsHandle.serializeArgument)(result)
|
|
695
|
+
}).catch(() => {});
|
|
696
|
+
} catch (e) {
|
|
697
|
+
this._channel.reject({
|
|
698
|
+
error: (0, _errors.serializeError)(e)
|
|
699
|
+
}).catch(() => {});
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
exports.BindingCall = BindingCall;
|
|
704
|
+
function trimUrl(param) {
|
|
705
|
+
if ((0, _utils.isRegExp)(param)) return `/${(0, _stringUtils.trimStringWithEllipsis)(param.source, 50)}/${param.flags}`;
|
|
706
|
+
if ((0, _utils.isString)(param)) return `"${(0, _stringUtils.trimStringWithEllipsis)(param, 50)}"`;
|
|
707
|
+
}
|