@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,509 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BrowserContext = void 0;
|
|
7
|
+
exports.prepareBrowserContextParams = prepareBrowserContextParams;
|
|
8
|
+
var _page = require("./page");
|
|
9
|
+
var _frame = require("./frame");
|
|
10
|
+
var network = _interopRequireWildcard(require("./network"));
|
|
11
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
12
|
+
var _path = _interopRequireDefault(require("path"));
|
|
13
|
+
var _channelOwner = require("./channelOwner");
|
|
14
|
+
var _clientHelper = require("./clientHelper");
|
|
15
|
+
var _browser = require("./browser");
|
|
16
|
+
var _worker = require("./worker");
|
|
17
|
+
var _events = require("./events");
|
|
18
|
+
var _timeoutSettings = require("../common/timeoutSettings");
|
|
19
|
+
var _waiter = require("./waiter");
|
|
20
|
+
var _utils = require("../utils");
|
|
21
|
+
var _fileUtils = require("../utils/fileUtils");
|
|
22
|
+
var _cdpSession = require("./cdpSession");
|
|
23
|
+
var _tracing = require("./tracing");
|
|
24
|
+
var _artifact = require("./artifact");
|
|
25
|
+
var _fetch = require("./fetch");
|
|
26
|
+
var _stackTrace = require("../utils/stackTrace");
|
|
27
|
+
var _harRouter = require("./harRouter");
|
|
28
|
+
var _consoleMessage = require("./consoleMessage");
|
|
29
|
+
var _dialog = require("./dialog");
|
|
30
|
+
var _webError = require("./webError");
|
|
31
|
+
var _errors = require("./errors");
|
|
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
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
51
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
52
|
+
_Symbol$asyncDispose = Symbol.asyncDispose;
|
|
53
|
+
class BrowserContext extends _channelOwner.ChannelOwner {
|
|
54
|
+
static from(context) {
|
|
55
|
+
return context._object;
|
|
56
|
+
}
|
|
57
|
+
static fromNullable(context) {
|
|
58
|
+
return context ? BrowserContext.from(context) : null;
|
|
59
|
+
}
|
|
60
|
+
constructor(parent, type, guid, initializer) {
|
|
61
|
+
var _this$_browser, _this$_browser2;
|
|
62
|
+
super(parent, type, guid, initializer);
|
|
63
|
+
this._pages = new Set();
|
|
64
|
+
this._routes = [];
|
|
65
|
+
this._browser = null;
|
|
66
|
+
this._browserType = void 0;
|
|
67
|
+
this._bindings = new Map();
|
|
68
|
+
this._timeoutSettings = new _timeoutSettings.TimeoutSettings();
|
|
69
|
+
this._ownerPage = void 0;
|
|
70
|
+
this._closedPromise = void 0;
|
|
71
|
+
this._options = {};
|
|
72
|
+
this.request = void 0;
|
|
73
|
+
this.tracing = void 0;
|
|
74
|
+
this._backgroundPages = new Set();
|
|
75
|
+
this._serviceWorkers = new Set();
|
|
76
|
+
this._isChromium = void 0;
|
|
77
|
+
this._harRecorders = new Map();
|
|
78
|
+
this._closeWasCalled = false;
|
|
79
|
+
this._closeReason = void 0;
|
|
80
|
+
this._harRouters = [];
|
|
81
|
+
if (parent instanceof _browser.Browser) this._browser = parent;
|
|
82
|
+
(_this$_browser = this._browser) === null || _this$_browser === void 0 || _this$_browser._contexts.add(this);
|
|
83
|
+
this._isChromium = ((_this$_browser2 = this._browser) === null || _this$_browser2 === void 0 ? void 0 : _this$_browser2._name) === 'chromium';
|
|
84
|
+
this.tracing = _tracing.Tracing.from(initializer.tracing);
|
|
85
|
+
this.request = _fetch.APIRequestContext.from(initializer.requestContext);
|
|
86
|
+
this._channel.on('bindingCall', ({
|
|
87
|
+
binding
|
|
88
|
+
}) => this._onBinding(_page.BindingCall.from(binding)));
|
|
89
|
+
this._channel.on('close', () => this._onClose());
|
|
90
|
+
this._channel.on('page', ({
|
|
91
|
+
page
|
|
92
|
+
}) => this._onPage(_page.Page.from(page)));
|
|
93
|
+
this._channel.on('route', ({
|
|
94
|
+
route
|
|
95
|
+
}) => this._onRoute(network.Route.from(route)));
|
|
96
|
+
this._channel.on('backgroundPage', ({
|
|
97
|
+
page
|
|
98
|
+
}) => {
|
|
99
|
+
const backgroundPage = _page.Page.from(page);
|
|
100
|
+
this._backgroundPages.add(backgroundPage);
|
|
101
|
+
this.emit(_events.Events.BrowserContext.BackgroundPage, backgroundPage);
|
|
102
|
+
});
|
|
103
|
+
this._channel.on('serviceWorker', ({
|
|
104
|
+
worker
|
|
105
|
+
}) => {
|
|
106
|
+
const serviceWorker = _worker.Worker.from(worker);
|
|
107
|
+
serviceWorker._context = this;
|
|
108
|
+
this._serviceWorkers.add(serviceWorker);
|
|
109
|
+
this.emit(_events.Events.BrowserContext.ServiceWorker, serviceWorker);
|
|
110
|
+
});
|
|
111
|
+
this._channel.on('console', event => {
|
|
112
|
+
const consoleMessage = new _consoleMessage.ConsoleMessage(event);
|
|
113
|
+
this.emit(_events.Events.BrowserContext.Console, consoleMessage);
|
|
114
|
+
const page = consoleMessage.page();
|
|
115
|
+
if (page) page.emit(_events.Events.Page.Console, consoleMessage);
|
|
116
|
+
});
|
|
117
|
+
this._channel.on('pageError', ({
|
|
118
|
+
error,
|
|
119
|
+
page
|
|
120
|
+
}) => {
|
|
121
|
+
const pageObject = _page.Page.from(page);
|
|
122
|
+
const parsedError = (0, _errors.parseError)(error);
|
|
123
|
+
this.emit(_events.Events.BrowserContext.WebError, new _webError.WebError(pageObject, parsedError));
|
|
124
|
+
if (pageObject) pageObject.emit(_events.Events.Page.PageError, parsedError);
|
|
125
|
+
});
|
|
126
|
+
this._channel.on('dialog', ({
|
|
127
|
+
dialog
|
|
128
|
+
}) => {
|
|
129
|
+
const dialogObject = _dialog.Dialog.from(dialog);
|
|
130
|
+
let hasListeners = this.emit(_events.Events.BrowserContext.Dialog, dialogObject);
|
|
131
|
+
const page = dialogObject.page();
|
|
132
|
+
if (page) hasListeners = page.emit(_events.Events.Page.Dialog, dialogObject) || hasListeners;
|
|
133
|
+
if (!hasListeners) {
|
|
134
|
+
// Although we do similar handling on the server side, we still need this logic
|
|
135
|
+
// on the client side due to a possible race condition between two async calls:
|
|
136
|
+
// a) removing "dialog" listener subscription (client->server)
|
|
137
|
+
// b) actual "dialog" event (server->client)
|
|
138
|
+
if (dialogObject.type() === 'beforeunload') dialog.accept({}).catch(() => {});else dialog.dismiss().catch(() => {});
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
this._channel.on('request', ({
|
|
142
|
+
request,
|
|
143
|
+
page
|
|
144
|
+
}) => this._onRequest(network.Request.from(request), _page.Page.fromNullable(page)));
|
|
145
|
+
this._channel.on('requestFailed', ({
|
|
146
|
+
request,
|
|
147
|
+
failureText,
|
|
148
|
+
responseEndTiming,
|
|
149
|
+
page
|
|
150
|
+
}) => this._onRequestFailed(network.Request.from(request), responseEndTiming, failureText, _page.Page.fromNullable(page)));
|
|
151
|
+
this._channel.on('requestFinished', params => this._onRequestFinished(params));
|
|
152
|
+
this._channel.on('response', ({
|
|
153
|
+
response,
|
|
154
|
+
page
|
|
155
|
+
}) => this._onResponse(network.Response.from(response), _page.Page.fromNullable(page)));
|
|
156
|
+
this._closedPromise = new Promise(f => this.once(_events.Events.BrowserContext.Close, f));
|
|
157
|
+
this._setEventToSubscriptionMapping(new Map([[_events.Events.BrowserContext.Console, 'console'], [_events.Events.BrowserContext.Dialog, 'dialog'], [_events.Events.BrowserContext.Request, 'request'], [_events.Events.BrowserContext.Response, 'response'], [_events.Events.BrowserContext.RequestFinished, 'requestFinished'], [_events.Events.BrowserContext.RequestFailed, 'requestFailed']]));
|
|
158
|
+
}
|
|
159
|
+
_setOptions(contextOptions, browserOptions) {
|
|
160
|
+
this._options = contextOptions;
|
|
161
|
+
if (this._options.recordHar) this._harRecorders.set('', {
|
|
162
|
+
path: this._options.recordHar.path,
|
|
163
|
+
content: this._options.recordHar.content
|
|
164
|
+
});
|
|
165
|
+
this.tracing._tracesDir = browserOptions.tracesDir;
|
|
166
|
+
}
|
|
167
|
+
_onPage(page) {
|
|
168
|
+
this._pages.add(page);
|
|
169
|
+
this.emit(_events.Events.BrowserContext.Page, page);
|
|
170
|
+
if (page._opener && !page._opener.isClosed()) page._opener.emit(_events.Events.Page.Popup, page);
|
|
171
|
+
}
|
|
172
|
+
_onRequest(request, page) {
|
|
173
|
+
this.emit(_events.Events.BrowserContext.Request, request);
|
|
174
|
+
if (page) page.emit(_events.Events.Page.Request, request);
|
|
175
|
+
}
|
|
176
|
+
_onResponse(response, page) {
|
|
177
|
+
this.emit(_events.Events.BrowserContext.Response, response);
|
|
178
|
+
if (page) page.emit(_events.Events.Page.Response, response);
|
|
179
|
+
}
|
|
180
|
+
_onRequestFailed(request, responseEndTiming, failureText, page) {
|
|
181
|
+
request._failureText = failureText || null;
|
|
182
|
+
request._setResponseEndTiming(responseEndTiming);
|
|
183
|
+
this.emit(_events.Events.BrowserContext.RequestFailed, request);
|
|
184
|
+
if (page) page.emit(_events.Events.Page.RequestFailed, request);
|
|
185
|
+
}
|
|
186
|
+
_onRequestFinished(params) {
|
|
187
|
+
const {
|
|
188
|
+
responseEndTiming
|
|
189
|
+
} = params;
|
|
190
|
+
const request = network.Request.from(params.request);
|
|
191
|
+
const response = network.Response.fromNullable(params.response);
|
|
192
|
+
const page = _page.Page.fromNullable(params.page);
|
|
193
|
+
request._setResponseEndTiming(responseEndTiming);
|
|
194
|
+
this.emit(_events.Events.BrowserContext.RequestFinished, request);
|
|
195
|
+
if (page) page.emit(_events.Events.Page.RequestFinished, request);
|
|
196
|
+
if (response) response._finishedPromise.resolve(null);
|
|
197
|
+
}
|
|
198
|
+
async _onRoute(route) {
|
|
199
|
+
route._context = this;
|
|
200
|
+
const page = route.request()._safePage();
|
|
201
|
+
const routeHandlers = this._routes.slice();
|
|
202
|
+
for (const routeHandler of routeHandlers) {
|
|
203
|
+
// If the page or the context was closed we stall all requests right away.
|
|
204
|
+
if (page !== null && page !== void 0 && page._closeWasCalled || this._closeWasCalled) return;
|
|
205
|
+
if (!routeHandler.matches(route.request().url())) continue;
|
|
206
|
+
const index = this._routes.indexOf(routeHandler);
|
|
207
|
+
if (index === -1) continue;
|
|
208
|
+
if (routeHandler.willExpire()) this._routes.splice(index, 1);
|
|
209
|
+
const handled = await routeHandler.handle(route);
|
|
210
|
+
if (!this._routes.length) this._wrapApiCall(() => this._updateInterceptionPatterns(), true).catch(() => {});
|
|
211
|
+
if (handled) return;
|
|
212
|
+
}
|
|
213
|
+
// If the page is closed or unrouteAll() was called without waiting and interception disabled,
|
|
214
|
+
// the method will throw an error - silence it.
|
|
215
|
+
await route._innerContinue(true).catch(() => {});
|
|
216
|
+
}
|
|
217
|
+
async _onBinding(bindingCall) {
|
|
218
|
+
const func = this._bindings.get(bindingCall._initializer.name);
|
|
219
|
+
if (!func) return;
|
|
220
|
+
await bindingCall.call(func);
|
|
221
|
+
}
|
|
222
|
+
setDefaultNavigationTimeout(timeout) {
|
|
223
|
+
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
|
|
224
|
+
this._wrapApiCall(async () => {
|
|
225
|
+
this._channel.setDefaultNavigationTimeoutNoReply({
|
|
226
|
+
timeout
|
|
227
|
+
}).catch(() => {});
|
|
228
|
+
}, true);
|
|
229
|
+
}
|
|
230
|
+
setDefaultTimeout(timeout) {
|
|
231
|
+
this._timeoutSettings.setDefaultTimeout(timeout);
|
|
232
|
+
this._wrapApiCall(async () => {
|
|
233
|
+
this._channel.setDefaultTimeoutNoReply({
|
|
234
|
+
timeout
|
|
235
|
+
}).catch(() => {});
|
|
236
|
+
}, true);
|
|
237
|
+
}
|
|
238
|
+
browser() {
|
|
239
|
+
return this._browser;
|
|
240
|
+
}
|
|
241
|
+
pages() {
|
|
242
|
+
return [...this._pages];
|
|
243
|
+
}
|
|
244
|
+
async newPage() {
|
|
245
|
+
if (this._ownerPage) throw new Error('Please use browser.newContext()');
|
|
246
|
+
return _page.Page.from((await this._channel.newPage()).page);
|
|
247
|
+
}
|
|
248
|
+
async cookies(urls) {
|
|
249
|
+
if (!urls) urls = [];
|
|
250
|
+
if (urls && typeof urls === 'string') urls = [urls];
|
|
251
|
+
return (await this._channel.cookies({
|
|
252
|
+
urls: urls
|
|
253
|
+
})).cookies;
|
|
254
|
+
}
|
|
255
|
+
async addCookies(cookies) {
|
|
256
|
+
await this._channel.addCookies({
|
|
257
|
+
cookies
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
async clearCookies() {
|
|
261
|
+
await this._channel.clearCookies();
|
|
262
|
+
}
|
|
263
|
+
async grantPermissions(permissions, options) {
|
|
264
|
+
await this._channel.grantPermissions({
|
|
265
|
+
permissions,
|
|
266
|
+
...options
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
async clearPermissions() {
|
|
270
|
+
await this._channel.clearPermissions();
|
|
271
|
+
}
|
|
272
|
+
async setGeolocation(geolocation) {
|
|
273
|
+
await this._channel.setGeolocation({
|
|
274
|
+
geolocation: geolocation || undefined
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
async setExtraHTTPHeaders(headers) {
|
|
278
|
+
network.validateHeaders(headers);
|
|
279
|
+
await this._channel.setExtraHTTPHeaders({
|
|
280
|
+
headers: (0, _utils.headersObjectToArray)(headers)
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
async setOffline(offline) {
|
|
284
|
+
await this._channel.setOffline({
|
|
285
|
+
offline
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
async setHTTPCredentials(httpCredentials) {
|
|
289
|
+
await this._channel.setHTTPCredentials({
|
|
290
|
+
httpCredentials: httpCredentials || undefined
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
async addInitScript(script, arg) {
|
|
294
|
+
const source = await (0, _clientHelper.evaluationScript)(script, arg);
|
|
295
|
+
await this._channel.addInitScript({
|
|
296
|
+
source
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
async exposeBinding(name, callback, options = {}) {
|
|
300
|
+
await this._channel.exposeBinding({
|
|
301
|
+
name,
|
|
302
|
+
needsHandle: options.handle
|
|
303
|
+
});
|
|
304
|
+
this._bindings.set(name, callback);
|
|
305
|
+
}
|
|
306
|
+
async exposeFunction(name, callback) {
|
|
307
|
+
await this._channel.exposeBinding({
|
|
308
|
+
name
|
|
309
|
+
});
|
|
310
|
+
const binding = (source, ...args) => callback(...args);
|
|
311
|
+
this._bindings.set(name, binding);
|
|
312
|
+
}
|
|
313
|
+
async route(url, handler, options = {}) {
|
|
314
|
+
this._routes.unshift(new network.RouteHandler(this._options.baseURL, url, handler, options.times));
|
|
315
|
+
await this._updateInterceptionPatterns();
|
|
316
|
+
}
|
|
317
|
+
async _recordIntoHAR(har, page, options = {}) {
|
|
318
|
+
var _options$updateConten, _options$updateMode, _options$updateConten2;
|
|
319
|
+
const {
|
|
320
|
+
harId
|
|
321
|
+
} = await this._channel.harStart({
|
|
322
|
+
page: page === null || page === void 0 ? void 0 : page._channel,
|
|
323
|
+
options: prepareRecordHarOptions({
|
|
324
|
+
path: har,
|
|
325
|
+
content: (_options$updateConten = options.updateContent) !== null && _options$updateConten !== void 0 ? _options$updateConten : 'attach',
|
|
326
|
+
mode: (_options$updateMode = options.updateMode) !== null && _options$updateMode !== void 0 ? _options$updateMode : 'minimal',
|
|
327
|
+
urlFilter: options.url
|
|
328
|
+
})
|
|
329
|
+
});
|
|
330
|
+
this._harRecorders.set(harId, {
|
|
331
|
+
path: har,
|
|
332
|
+
content: (_options$updateConten2 = options.updateContent) !== null && _options$updateConten2 !== void 0 ? _options$updateConten2 : 'attach'
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
async routeFromHAR(har, options = {}) {
|
|
336
|
+
if (options.update) {
|
|
337
|
+
await this._recordIntoHAR(har, null, options);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const harRouter = await _harRouter.HarRouter.create(this._connection.localUtils(), har, options.notFound || 'abort', {
|
|
341
|
+
urlMatch: options.url
|
|
342
|
+
});
|
|
343
|
+
this._harRouters.push(harRouter);
|
|
344
|
+
await harRouter.addContextRoute(this);
|
|
345
|
+
}
|
|
346
|
+
_disposeHarRouters() {
|
|
347
|
+
this._harRouters.forEach(router => router.dispose());
|
|
348
|
+
this._harRouters = [];
|
|
349
|
+
}
|
|
350
|
+
async unrouteAll(options) {
|
|
351
|
+
await this._unrouteInternal(this._routes, [], options === null || options === void 0 ? void 0 : options.behavior);
|
|
352
|
+
this._disposeHarRouters();
|
|
353
|
+
}
|
|
354
|
+
async unroute(url, handler) {
|
|
355
|
+
const removed = [];
|
|
356
|
+
const remaining = [];
|
|
357
|
+
for (const route of this._routes) {
|
|
358
|
+
if ((0, _utils.urlMatchesEqual)(route.url, url) && (!handler || route.handler === handler)) removed.push(route);else remaining.push(route);
|
|
359
|
+
}
|
|
360
|
+
await this._unrouteInternal(removed, remaining, 'default');
|
|
361
|
+
}
|
|
362
|
+
async _unrouteInternal(removed, remaining, behavior) {
|
|
363
|
+
this._routes = remaining;
|
|
364
|
+
await this._updateInterceptionPatterns();
|
|
365
|
+
if (!behavior || behavior === 'default') return;
|
|
366
|
+
const promises = removed.map(routeHandler => routeHandler.stop(behavior));
|
|
367
|
+
await Promise.all(promises);
|
|
368
|
+
}
|
|
369
|
+
async _updateInterceptionPatterns() {
|
|
370
|
+
const patterns = network.RouteHandler.prepareInterceptionPatterns(this._routes);
|
|
371
|
+
await this._channel.setNetworkInterceptionPatterns({
|
|
372
|
+
patterns
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
_effectiveCloseReason() {
|
|
376
|
+
var _this$_browser3;
|
|
377
|
+
return this._closeReason || ((_this$_browser3 = this._browser) === null || _this$_browser3 === void 0 ? void 0 : _this$_browser3._closeReason);
|
|
378
|
+
}
|
|
379
|
+
async waitForEvent(event, optionsOrPredicate = {}) {
|
|
380
|
+
return await this._wrapApiCall(async () => {
|
|
381
|
+
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === 'function' ? {} : optionsOrPredicate);
|
|
382
|
+
const predicate = typeof optionsOrPredicate === 'function' ? optionsOrPredicate : optionsOrPredicate.predicate;
|
|
383
|
+
const waiter = _waiter.Waiter.createForEvent(this, event);
|
|
384
|
+
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
|
|
385
|
+
if (event !== _events.Events.BrowserContext.Close) waiter.rejectOnEvent(this, _events.Events.BrowserContext.Close, () => new _errors.TargetClosedError(this._effectiveCloseReason()));
|
|
386
|
+
const result = await waiter.waitForEvent(this, event, predicate);
|
|
387
|
+
waiter.dispose();
|
|
388
|
+
return result;
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
async storageState(options = {}) {
|
|
392
|
+
const state = await this._channel.storageState();
|
|
393
|
+
if (options.path) {
|
|
394
|
+
await (0, _fileUtils.mkdirIfNeeded)(options.path);
|
|
395
|
+
await _fs.default.promises.writeFile(options.path, JSON.stringify(state, undefined, 2), 'utf8');
|
|
396
|
+
}
|
|
397
|
+
return state;
|
|
398
|
+
}
|
|
399
|
+
backgroundPages() {
|
|
400
|
+
return [...this._backgroundPages];
|
|
401
|
+
}
|
|
402
|
+
serviceWorkers() {
|
|
403
|
+
return [...this._serviceWorkers];
|
|
404
|
+
}
|
|
405
|
+
async newCDPSession(page) {
|
|
406
|
+
// channelOwner.ts's validation messages don't handle the pseudo-union type, so we're explicit here
|
|
407
|
+
if (!(page instanceof _page.Page) && !(page instanceof _frame.Frame)) throw new Error('page: expected Page or Frame');
|
|
408
|
+
const result = await this._channel.newCDPSession(page instanceof _page.Page ? {
|
|
409
|
+
page: page._channel
|
|
410
|
+
} : {
|
|
411
|
+
frame: page._channel
|
|
412
|
+
});
|
|
413
|
+
return _cdpSession.CDPSession.from(result.session);
|
|
414
|
+
}
|
|
415
|
+
_onClose() {
|
|
416
|
+
var _this$_browserType;
|
|
417
|
+
if (this._browser) this._browser._contexts.delete(this);
|
|
418
|
+
(_this$_browserType = this._browserType) === null || _this$_browserType === void 0 || (_this$_browserType = _this$_browserType._contexts) === null || _this$_browserType === void 0 || _this$_browserType.delete(this);
|
|
419
|
+
this._disposeHarRouters();
|
|
420
|
+
this.emit(_events.Events.BrowserContext.Close, this);
|
|
421
|
+
}
|
|
422
|
+
async [_Symbol$asyncDispose]() {
|
|
423
|
+
await this.close();
|
|
424
|
+
}
|
|
425
|
+
async close(options = {}) {
|
|
426
|
+
if (this._closeWasCalled) return;
|
|
427
|
+
this._closeReason = options.reason;
|
|
428
|
+
this._closeWasCalled = true;
|
|
429
|
+
await this._wrapApiCall(async () => {
|
|
430
|
+
var _this$_browserType2;
|
|
431
|
+
await ((_this$_browserType2 = this._browserType) === null || _this$_browserType2 === void 0 ? void 0 : _this$_browserType2._willCloseContext(this));
|
|
432
|
+
for (const [harId, harParams] of this._harRecorders) {
|
|
433
|
+
const har = await this._channel.harExport({
|
|
434
|
+
harId
|
|
435
|
+
});
|
|
436
|
+
const artifact = _artifact.Artifact.from(har.artifact);
|
|
437
|
+
// Server side will compress artifact if content is attach or if file is .zip.
|
|
438
|
+
const isCompressed = harParams.content === 'attach' || harParams.path.endsWith('.zip');
|
|
439
|
+
const needCompressed = harParams.path.endsWith('.zip');
|
|
440
|
+
if (isCompressed && !needCompressed) {
|
|
441
|
+
await artifact.saveAs(harParams.path + '.tmp');
|
|
442
|
+
await this._connection.localUtils()._channel.harUnzip({
|
|
443
|
+
zipFile: harParams.path + '.tmp',
|
|
444
|
+
harFile: harParams.path
|
|
445
|
+
});
|
|
446
|
+
} else {
|
|
447
|
+
await artifact.saveAs(harParams.path);
|
|
448
|
+
}
|
|
449
|
+
await artifact.delete();
|
|
450
|
+
}
|
|
451
|
+
}, true);
|
|
452
|
+
await this._channel.close(options);
|
|
453
|
+
await this._closedPromise;
|
|
454
|
+
}
|
|
455
|
+
async _enableRecorder(params) {
|
|
456
|
+
await this._channel.recorderSupplementEnable(params);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
exports.BrowserContext = BrowserContext;
|
|
460
|
+
async function prepareStorageState(options) {
|
|
461
|
+
if (typeof options.storageState !== 'string') return options.storageState;
|
|
462
|
+
try {
|
|
463
|
+
return JSON.parse(await _fs.default.promises.readFile(options.storageState, 'utf8'));
|
|
464
|
+
} catch (e) {
|
|
465
|
+
(0, _stackTrace.rewriteErrorMessage)(e, `Error reading storage state from ${options.storageState}:\n` + e.message);
|
|
466
|
+
throw e;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
function prepareRecordHarOptions(options) {
|
|
470
|
+
if (!options) return;
|
|
471
|
+
return {
|
|
472
|
+
path: options.path,
|
|
473
|
+
content: options.content || (options.omitContent ? 'omit' : undefined),
|
|
474
|
+
urlGlob: (0, _utils.isString)(options.urlFilter) ? options.urlFilter : undefined,
|
|
475
|
+
urlRegexSource: (0, _utils.isRegExp)(options.urlFilter) ? options.urlFilter.source : undefined,
|
|
476
|
+
urlRegexFlags: (0, _utils.isRegExp)(options.urlFilter) ? options.urlFilter.flags : undefined,
|
|
477
|
+
mode: options.mode
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
async function prepareBrowserContextParams(options) {
|
|
481
|
+
if (options.videoSize && !options.videosPath) throw new Error(`"videoSize" option requires "videosPath" to be specified`);
|
|
482
|
+
if (options.extraHTTPHeaders) network.validateHeaders(options.extraHTTPHeaders);
|
|
483
|
+
const contextParams = {
|
|
484
|
+
...options,
|
|
485
|
+
viewport: options.viewport === null ? undefined : options.viewport,
|
|
486
|
+
noDefaultViewport: options.viewport === null,
|
|
487
|
+
extraHTTPHeaders: options.extraHTTPHeaders ? (0, _utils.headersObjectToArray)(options.extraHTTPHeaders) : undefined,
|
|
488
|
+
storageState: await prepareStorageState(options),
|
|
489
|
+
serviceWorkers: options.serviceWorkers,
|
|
490
|
+
recordHar: prepareRecordHarOptions(options.recordHar),
|
|
491
|
+
colorScheme: options.colorScheme === null ? 'no-override' : options.colorScheme,
|
|
492
|
+
reducedMotion: options.reducedMotion === null ? 'no-override' : options.reducedMotion,
|
|
493
|
+
forcedColors: options.forcedColors === null ? 'no-override' : options.forcedColors,
|
|
494
|
+
acceptDownloads: toAcceptDownloadsProtocol(options.acceptDownloads)
|
|
495
|
+
};
|
|
496
|
+
if (!contextParams.recordVideo && options.videosPath) {
|
|
497
|
+
contextParams.recordVideo = {
|
|
498
|
+
dir: options.videosPath,
|
|
499
|
+
size: options.videoSize
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
if (contextParams.recordVideo && contextParams.recordVideo.dir) contextParams.recordVideo.dir = _path.default.resolve(process.cwd(), contextParams.recordVideo.dir);
|
|
503
|
+
return contextParams;
|
|
504
|
+
}
|
|
505
|
+
function toAcceptDownloadsProtocol(acceptDownloads) {
|
|
506
|
+
if (acceptDownloads === undefined) return undefined;
|
|
507
|
+
if (acceptDownloads === true) return 'accept';
|
|
508
|
+
return 'deny';
|
|
509
|
+
}
|