@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,925 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Registry = void 0;
|
|
7
|
+
exports.browserDirectoryToMarkerFilePath = browserDirectoryToMarkerFilePath;
|
|
8
|
+
exports.buildPlaywrightCLICommand = buildPlaywrightCLICommand;
|
|
9
|
+
exports.findChromiumChannel = findChromiumChannel;
|
|
10
|
+
exports.installBrowsersForNpmInstall = installBrowsersForNpmInstall;
|
|
11
|
+
exports.installDefaultBrowsersForNpmInstall = installDefaultBrowsersForNpmInstall;
|
|
12
|
+
exports.registryDirectory = exports.registry = void 0;
|
|
13
|
+
Object.defineProperty(exports, "writeDockerVersion", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _dependencies.writeDockerVersion;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var os = _interopRequireWildcard(require("os"));
|
|
20
|
+
var _path = _interopRequireDefault(require("path"));
|
|
21
|
+
var util = _interopRequireWildcard(require("util"));
|
|
22
|
+
var fs = _interopRequireWildcard(require("fs"));
|
|
23
|
+
var _utilsBundle = require("../../utilsBundle");
|
|
24
|
+
var _network = require("../../utils/network");
|
|
25
|
+
var _userAgent = require("../../utils/userAgent");
|
|
26
|
+
var _utils = require("../../utils");
|
|
27
|
+
var _fileUtils = require("../../utils/fileUtils");
|
|
28
|
+
var _hostPlatform = require("../../utils/hostPlatform");
|
|
29
|
+
var _spawnAsync = require("../../utils/spawnAsync");
|
|
30
|
+
var _dependencies = require("./dependencies");
|
|
31
|
+
var _browserFetcher = require("./browserFetcher");
|
|
32
|
+
var _debugLogger = require("../../utils/debugLogger");
|
|
33
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
34
|
+
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); }
|
|
35
|
+
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; }
|
|
36
|
+
/**
|
|
37
|
+
* Copyright 2017 Google Inc. All rights reserved.
|
|
38
|
+
* Modifications copyright (c) Microsoft Corporation.
|
|
39
|
+
*
|
|
40
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
41
|
+
* you may not use this file except in compliance with the License.
|
|
42
|
+
* You may obtain a copy of the License at
|
|
43
|
+
*
|
|
44
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
45
|
+
*
|
|
46
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
47
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
48
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
49
|
+
* See the License for the specific language governing permissions and
|
|
50
|
+
* limitations under the License.
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
const PACKAGE_PATH = _path.default.join(__dirname, '..', '..', '..');
|
|
54
|
+
const BIN_PATH = _path.default.join(__dirname, '..', '..', '..', 'bin');
|
|
55
|
+
const PLAYWRIGHT_CDN_MIRRORS = ['https://playwright.azureedge.net', 'https://playwright-akamai.azureedge.net', 'https://playwright-verizon.azureedge.net'];
|
|
56
|
+
if (process.env.PW_TEST_CDN_THAT_SHOULD_WORK) {
|
|
57
|
+
for (let i = 0; i < PLAYWRIGHT_CDN_MIRRORS.length; i++) {
|
|
58
|
+
const cdn = PLAYWRIGHT_CDN_MIRRORS[i];
|
|
59
|
+
if (cdn !== process.env.PW_TEST_CDN_THAT_SHOULD_WORK) PLAYWRIGHT_CDN_MIRRORS[i] = cdn + '.does-not-resolve.playwright.dev';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const EXECUTABLE_PATHS = {
|
|
63
|
+
'chromium': {
|
|
64
|
+
'linux': ['chrome-linux', 'chrome'],
|
|
65
|
+
'mac': ['chrome-mac', 'Chromium.app', 'Contents', 'MacOS', 'Chromium'],
|
|
66
|
+
'win': ['chrome-win', 'chrome.exe']
|
|
67
|
+
},
|
|
68
|
+
'firefox': {
|
|
69
|
+
'linux': ['firefox', 'firefox'],
|
|
70
|
+
'mac': ['firefox', 'Nightly.app', 'Contents', 'MacOS', 'firefox'],
|
|
71
|
+
'win': ['firefox', 'firefox.exe']
|
|
72
|
+
},
|
|
73
|
+
'webkit': {
|
|
74
|
+
'linux': ['pw_run.sh'],
|
|
75
|
+
'mac': ['pw_run.sh'],
|
|
76
|
+
'win': ['Playwright.exe']
|
|
77
|
+
},
|
|
78
|
+
'ffmpeg': {
|
|
79
|
+
'linux': ['ffmpeg-linux'],
|
|
80
|
+
'mac': ['ffmpeg-mac'],
|
|
81
|
+
'win': ['ffmpeg-win64.exe']
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const DOWNLOAD_PATHS = {
|
|
85
|
+
'chromium': {
|
|
86
|
+
'<unknown>': undefined,
|
|
87
|
+
'ubuntu18.04-x64': undefined,
|
|
88
|
+
'ubuntu20.04-x64': 'builds/chromium/%s/chromium-linux.zip',
|
|
89
|
+
'ubuntu22.04-x64': 'builds/chromium/%s/chromium-linux.zip',
|
|
90
|
+
'ubuntu18.04-arm64': undefined,
|
|
91
|
+
'ubuntu20.04-arm64': 'builds/chromium/%s/chromium-linux-arm64.zip',
|
|
92
|
+
'ubuntu22.04-arm64': 'builds/chromium/%s/chromium-linux-arm64.zip',
|
|
93
|
+
'debian11-x64': 'builds/chromium/%s/chromium-linux.zip',
|
|
94
|
+
'debian11-arm64': 'builds/chromium/%s/chromium-linux-arm64.zip',
|
|
95
|
+
'debian12-x64': 'builds/chromium/%s/chromium-linux.zip',
|
|
96
|
+
'debian12-arm64': 'builds/chromium/%s/chromium-linux-arm64.zip',
|
|
97
|
+
'mac10.13': 'builds/chromium/%s/chromium-mac.zip',
|
|
98
|
+
'mac10.14': 'builds/chromium/%s/chromium-mac.zip',
|
|
99
|
+
'mac10.15': 'builds/chromium/%s/chromium-mac.zip',
|
|
100
|
+
'mac11': 'builds/chromium/%s/chromium-mac.zip',
|
|
101
|
+
'mac11-arm64': 'builds/chromium/%s/chromium-mac-arm64.zip',
|
|
102
|
+
'mac12': 'builds/chromium/%s/chromium-mac.zip',
|
|
103
|
+
'mac12-arm64': 'builds/chromium/%s/chromium-mac-arm64.zip',
|
|
104
|
+
'mac13': 'builds/chromium/%s/chromium-mac.zip',
|
|
105
|
+
'mac13-arm64': 'builds/chromium/%s/chromium-mac-arm64.zip',
|
|
106
|
+
'win64': 'builds/chromium/%s/chromium-win64.zip'
|
|
107
|
+
},
|
|
108
|
+
'chromium-tip-of-tree': {
|
|
109
|
+
'<unknown>': undefined,
|
|
110
|
+
'ubuntu18.04-x64': undefined,
|
|
111
|
+
'ubuntu20.04-x64': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-linux.zip',
|
|
112
|
+
'ubuntu22.04-x64': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-linux.zip',
|
|
113
|
+
'ubuntu18.04-arm64': undefined,
|
|
114
|
+
'ubuntu20.04-arm64': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-linux-arm64.zip',
|
|
115
|
+
'ubuntu22.04-arm64': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-linux-arm64.zip',
|
|
116
|
+
'debian11-x64': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-linux.zip',
|
|
117
|
+
'debian11-arm64': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-linux-arm64.zip',
|
|
118
|
+
'debian12-x64': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-linux.zip',
|
|
119
|
+
'debian12-arm64': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-linux-arm64.zip',
|
|
120
|
+
'mac10.13': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-mac.zip',
|
|
121
|
+
'mac10.14': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-mac.zip',
|
|
122
|
+
'mac10.15': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-mac.zip',
|
|
123
|
+
'mac11': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-mac.zip',
|
|
124
|
+
'mac11-arm64': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-mac-arm64.zip',
|
|
125
|
+
'mac12': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-mac.zip',
|
|
126
|
+
'mac12-arm64': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-mac-arm64.zip',
|
|
127
|
+
'mac13': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-mac.zip',
|
|
128
|
+
'mac13-arm64': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-mac-arm64.zip',
|
|
129
|
+
'win64': 'builds/chromium-tip-of-tree/%s/chromium-tip-of-tree-win64.zip'
|
|
130
|
+
},
|
|
131
|
+
'chromium-with-symbols': {
|
|
132
|
+
'<unknown>': undefined,
|
|
133
|
+
'ubuntu18.04-x64': undefined,
|
|
134
|
+
'ubuntu20.04-x64': 'builds/chromium/%s/chromium-with-symbols-linux.zip',
|
|
135
|
+
'ubuntu22.04-x64': 'builds/chromium/%s/chromium-with-symbols-linux.zip',
|
|
136
|
+
'ubuntu18.04-arm64': undefined,
|
|
137
|
+
'ubuntu20.04-arm64': 'builds/chromium/%s/chromium-with-symbols-linux-arm64.zip',
|
|
138
|
+
'ubuntu22.04-arm64': 'builds/chromium/%s/chromium-with-symbols-linux-arm64.zip',
|
|
139
|
+
'debian11-x64': 'builds/chromium/%s/chromium-with-symbols-linux.zip',
|
|
140
|
+
'debian11-arm64': 'builds/chromium/%s/chromium-with-symbols-linux-arm64.zip',
|
|
141
|
+
'debian12-x64': 'builds/chromium/%s/chromium-with-symbols-linux.zip',
|
|
142
|
+
'debian12-arm64': 'builds/chromium/%s/chromium-with-symbols-linux-arm64.zip',
|
|
143
|
+
'mac10.13': 'builds/chromium/%s/chromium-with-symbols-mac.zip',
|
|
144
|
+
'mac10.14': 'builds/chromium/%s/chromium-with-symbols-mac.zip',
|
|
145
|
+
'mac10.15': 'builds/chromium/%s/chromium-with-symbols-mac.zip',
|
|
146
|
+
'mac11': 'builds/chromium/%s/chromium-with-symbols-mac.zip',
|
|
147
|
+
'mac11-arm64': 'builds/chromium/%s/chromium-with-symbols-mac-arm64.zip',
|
|
148
|
+
'mac12': 'builds/chromium/%s/chromium-with-symbols-mac.zip',
|
|
149
|
+
'mac12-arm64': 'builds/chromium/%s/chromium-with-symbols-mac-arm64.zip',
|
|
150
|
+
'mac13': 'builds/chromium/%s/chromium-with-symbols-mac.zip',
|
|
151
|
+
'mac13-arm64': 'builds/chromium/%s/chromium-with-symbols-mac-arm64.zip',
|
|
152
|
+
'win64': 'builds/chromium/%s/chromium-with-symbols-win64.zip'
|
|
153
|
+
},
|
|
154
|
+
'firefox': {
|
|
155
|
+
'<unknown>': undefined,
|
|
156
|
+
'ubuntu18.04-x64': undefined,
|
|
157
|
+
'ubuntu20.04-x64': 'builds/firefox/%s/firefox-ubuntu-20.04.zip',
|
|
158
|
+
'ubuntu22.04-x64': 'builds/firefox/%s/firefox-ubuntu-22.04.zip',
|
|
159
|
+
'ubuntu18.04-arm64': undefined,
|
|
160
|
+
'ubuntu20.04-arm64': 'builds/firefox/%s/firefox-ubuntu-20.04-arm64.zip',
|
|
161
|
+
'ubuntu22.04-arm64': 'builds/firefox/%s/firefox-ubuntu-22.04-arm64.zip',
|
|
162
|
+
'debian11-x64': 'builds/firefox/%s/firefox-debian-11.zip',
|
|
163
|
+
'debian11-arm64': 'builds/firefox/%s/firefox-debian-11-arm64.zip',
|
|
164
|
+
'debian12-x64': 'builds/firefox/%s/firefox-debian-12.zip',
|
|
165
|
+
'debian12-arm64': 'builds/firefox/%s/firefox-debian-12-arm64.zip',
|
|
166
|
+
'mac10.13': 'builds/firefox/%s/firefox-mac-13.zip',
|
|
167
|
+
'mac10.14': 'builds/firefox/%s/firefox-mac-13.zip',
|
|
168
|
+
'mac10.15': 'builds/firefox/%s/firefox-mac-13.zip',
|
|
169
|
+
'mac11': 'builds/firefox/%s/firefox-mac-13.zip',
|
|
170
|
+
'mac11-arm64': 'builds/firefox/%s/firefox-mac-13-arm64.zip',
|
|
171
|
+
'mac12': 'builds/firefox/%s/firefox-mac-13.zip',
|
|
172
|
+
'mac12-arm64': 'builds/firefox/%s/firefox-mac-13-arm64.zip',
|
|
173
|
+
'mac13': 'builds/firefox/%s/firefox-mac-13.zip',
|
|
174
|
+
'mac13-arm64': 'builds/firefox/%s/firefox-mac-13-arm64.zip',
|
|
175
|
+
'win64': 'builds/firefox/%s/firefox-win64.zip'
|
|
176
|
+
},
|
|
177
|
+
'firefox-beta': {
|
|
178
|
+
'<unknown>': undefined,
|
|
179
|
+
'ubuntu18.04-x64': undefined,
|
|
180
|
+
'ubuntu20.04-x64': 'builds/firefox-beta/%s/firefox-beta-ubuntu-20.04.zip',
|
|
181
|
+
'ubuntu22.04-x64': 'builds/firefox-beta/%s/firefox-beta-ubuntu-22.04.zip',
|
|
182
|
+
'ubuntu18.04-arm64': undefined,
|
|
183
|
+
'ubuntu20.04-arm64': undefined,
|
|
184
|
+
'ubuntu22.04-arm64': 'builds/firefox-beta/%s/firefox-beta-ubuntu-22.04-arm64.zip',
|
|
185
|
+
'debian11-x64': 'builds/firefox-beta/%s/firefox-beta-debian-11.zip',
|
|
186
|
+
'debian11-arm64': 'builds/firefox-beta/%s/firefox-beta-debian-11-arm64.zip',
|
|
187
|
+
'debian12-x64': 'builds/firefox-beta/%s/firefox-beta-debian-12.zip',
|
|
188
|
+
'debian12-arm64': 'builds/firefox-beta/%s/firefox-beta-debian-12-arm64.zip',
|
|
189
|
+
'mac10.13': 'builds/firefox-beta/%s/firefox-beta-mac-13.zip',
|
|
190
|
+
'mac10.14': 'builds/firefox-beta/%s/firefox-beta-mac-13.zip',
|
|
191
|
+
'mac10.15': 'builds/firefox-beta/%s/firefox-beta-mac-13.zip',
|
|
192
|
+
'mac11': 'builds/firefox-beta/%s/firefox-beta-mac-13.zip',
|
|
193
|
+
'mac11-arm64': 'builds/firefox-beta/%s/firefox-beta-mac-13-arm64.zip',
|
|
194
|
+
'mac12': 'builds/firefox-beta/%s/firefox-beta-mac-13.zip',
|
|
195
|
+
'mac12-arm64': 'builds/firefox-beta/%s/firefox-beta-mac-13-arm64.zip',
|
|
196
|
+
'mac13': 'builds/firefox-beta/%s/firefox-beta-mac-13.zip',
|
|
197
|
+
'mac13-arm64': 'builds/firefox-beta/%s/firefox-beta-mac-13-arm64.zip',
|
|
198
|
+
'win64': 'builds/firefox-beta/%s/firefox-beta-win64.zip'
|
|
199
|
+
},
|
|
200
|
+
'firefox-asan': {
|
|
201
|
+
'<unknown>': undefined,
|
|
202
|
+
'ubuntu18.04-x64': undefined,
|
|
203
|
+
'ubuntu20.04-x64': undefined,
|
|
204
|
+
'ubuntu22.04-x64': 'builds/firefox/%s/firefox-asan-ubuntu-22.04.zip',
|
|
205
|
+
'ubuntu18.04-arm64': undefined,
|
|
206
|
+
'ubuntu20.04-arm64': undefined,
|
|
207
|
+
'ubuntu22.04-arm64': undefined,
|
|
208
|
+
'debian11-x64': undefined,
|
|
209
|
+
'debian11-arm64': undefined,
|
|
210
|
+
'debian12-x64': undefined,
|
|
211
|
+
'debian12-arm64': undefined,
|
|
212
|
+
'mac10.13': 'builds/firefox/%s/firefox-asan-mac-13.zip',
|
|
213
|
+
'mac10.14': 'builds/firefox/%s/firefox-asan-mac-13.zip',
|
|
214
|
+
'mac10.15': 'builds/firefox/%s/firefox-asan-mac-13.zip',
|
|
215
|
+
'mac11': 'builds/firefox/%s/firefox-asan-mac-13.zip',
|
|
216
|
+
'mac11-arm64': undefined,
|
|
217
|
+
'mac12': 'builds/firefox/%s/firefox-asan-mac-13.zip',
|
|
218
|
+
'mac12-arm64': undefined,
|
|
219
|
+
'mac13': 'builds/firefox/%s/firefox-asan-mac-13.zip',
|
|
220
|
+
'mac13-arm64': undefined,
|
|
221
|
+
'win64': undefined
|
|
222
|
+
},
|
|
223
|
+
'webkit': {
|
|
224
|
+
'<unknown>': undefined,
|
|
225
|
+
'ubuntu18.04-x64': undefined,
|
|
226
|
+
'ubuntu20.04-x64': 'builds/webkit/%s/webkit-ubuntu-20.04.zip',
|
|
227
|
+
'ubuntu22.04-x64': 'builds/webkit/%s/webkit-ubuntu-22.04.zip',
|
|
228
|
+
'ubuntu18.04-arm64': undefined,
|
|
229
|
+
'ubuntu20.04-arm64': 'builds/webkit/%s/webkit-ubuntu-20.04-arm64.zip',
|
|
230
|
+
'ubuntu22.04-arm64': 'builds/webkit/%s/webkit-ubuntu-22.04-arm64.zip',
|
|
231
|
+
'debian11-x64': 'builds/webkit/%s/webkit-debian-11.zip',
|
|
232
|
+
'debian11-arm64': 'builds/webkit/%s/webkit-debian-11-arm64.zip',
|
|
233
|
+
'debian12-x64': 'builds/webkit/%s/webkit-debian-12.zip',
|
|
234
|
+
'debian12-arm64': 'builds/webkit/%s/webkit-debian-12-arm64.zip',
|
|
235
|
+
'mac10.13': undefined,
|
|
236
|
+
'mac10.14': 'builds/deprecated-webkit-mac-10.14/%s/deprecated-webkit-mac-10.14.zip',
|
|
237
|
+
'mac10.15': 'builds/deprecated-webkit-mac-10.15/%s/deprecated-webkit-mac-10.15.zip',
|
|
238
|
+
'mac11': 'builds/webkit/%s/webkit-mac-11.zip',
|
|
239
|
+
'mac11-arm64': 'builds/webkit/%s/webkit-mac-11-arm64.zip',
|
|
240
|
+
'mac12': 'builds/webkit/%s/webkit-mac-12.zip',
|
|
241
|
+
'mac12-arm64': 'builds/webkit/%s/webkit-mac-12-arm64.zip',
|
|
242
|
+
'mac13': 'builds/webkit/%s/webkit-mac-13.zip',
|
|
243
|
+
'mac13-arm64': 'builds/webkit/%s/webkit-mac-13-arm64.zip',
|
|
244
|
+
'win64': 'builds/webkit/%s/webkit-win64.zip'
|
|
245
|
+
},
|
|
246
|
+
'ffmpeg': {
|
|
247
|
+
'<unknown>': undefined,
|
|
248
|
+
'ubuntu18.04-x64': undefined,
|
|
249
|
+
'ubuntu20.04-x64': 'builds/ffmpeg/%s/ffmpeg-linux.zip',
|
|
250
|
+
'ubuntu22.04-x64': 'builds/ffmpeg/%s/ffmpeg-linux.zip',
|
|
251
|
+
'ubuntu18.04-arm64': undefined,
|
|
252
|
+
'ubuntu20.04-arm64': 'builds/ffmpeg/%s/ffmpeg-linux-arm64.zip',
|
|
253
|
+
'ubuntu22.04-arm64': 'builds/ffmpeg/%s/ffmpeg-linux-arm64.zip',
|
|
254
|
+
'debian11-x64': 'builds/ffmpeg/%s/ffmpeg-linux.zip',
|
|
255
|
+
'debian11-arm64': 'builds/ffmpeg/%s/ffmpeg-linux-arm64.zip',
|
|
256
|
+
'debian12-x64': 'builds/ffmpeg/%s/ffmpeg-linux.zip',
|
|
257
|
+
'debian12-arm64': 'builds/ffmpeg/%s/ffmpeg-linux-arm64.zip',
|
|
258
|
+
'mac10.13': 'builds/ffmpeg/%s/ffmpeg-mac.zip',
|
|
259
|
+
'mac10.14': 'builds/ffmpeg/%s/ffmpeg-mac.zip',
|
|
260
|
+
'mac10.15': 'builds/ffmpeg/%s/ffmpeg-mac.zip',
|
|
261
|
+
'mac11': 'builds/ffmpeg/%s/ffmpeg-mac.zip',
|
|
262
|
+
'mac11-arm64': 'builds/ffmpeg/%s/ffmpeg-mac-arm64.zip',
|
|
263
|
+
'mac12': 'builds/ffmpeg/%s/ffmpeg-mac.zip',
|
|
264
|
+
'mac12-arm64': 'builds/ffmpeg/%s/ffmpeg-mac-arm64.zip',
|
|
265
|
+
'mac13': 'builds/ffmpeg/%s/ffmpeg-mac.zip',
|
|
266
|
+
'mac13-arm64': 'builds/ffmpeg/%s/ffmpeg-mac-arm64.zip',
|
|
267
|
+
'win64': 'builds/ffmpeg/%s/ffmpeg-win64.zip'
|
|
268
|
+
},
|
|
269
|
+
'android': {
|
|
270
|
+
'<unknown>': 'builds/android/%s/android.zip',
|
|
271
|
+
'ubuntu18.04-x64': undefined,
|
|
272
|
+
'ubuntu20.04-x64': 'builds/android/%s/android.zip',
|
|
273
|
+
'ubuntu22.04-x64': 'builds/android/%s/android.zip',
|
|
274
|
+
'ubuntu18.04-arm64': undefined,
|
|
275
|
+
'ubuntu20.04-arm64': 'builds/android/%s/android.zip',
|
|
276
|
+
'ubuntu22.04-arm64': 'builds/android/%s/android.zip',
|
|
277
|
+
'debian11-x64': 'builds/android/%s/android.zip',
|
|
278
|
+
'debian11-arm64': 'builds/android/%s/android.zip',
|
|
279
|
+
'debian12-x64': 'builds/android/%s/android.zip',
|
|
280
|
+
'debian12-arm64': 'builds/android/%s/android.zip',
|
|
281
|
+
'mac10.13': 'builds/android/%s/android.zip',
|
|
282
|
+
'mac10.14': 'builds/android/%s/android.zip',
|
|
283
|
+
'mac10.15': 'builds/android/%s/android.zip',
|
|
284
|
+
'mac11': 'builds/android/%s/android.zip',
|
|
285
|
+
'mac11-arm64': 'builds/android/%s/android.zip',
|
|
286
|
+
'mac12': 'builds/android/%s/android.zip',
|
|
287
|
+
'mac12-arm64': 'builds/android/%s/android.zip',
|
|
288
|
+
'mac13': 'builds/android/%s/android.zip',
|
|
289
|
+
'mac13-arm64': 'builds/android/%s/android.zip',
|
|
290
|
+
'win64': 'builds/android/%s/android.zip'
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
const registryDirectory = exports.registryDirectory = (() => {
|
|
294
|
+
let result;
|
|
295
|
+
const envDefined = (0, _utils.getFromENV)('PLAYWRIGHT_BROWSERS_PATH');
|
|
296
|
+
if (envDefined === '0') {
|
|
297
|
+
result = _path.default.join(__dirname, '..', '..', '..', '.local-browsers');
|
|
298
|
+
} else if (envDefined) {
|
|
299
|
+
result = envDefined;
|
|
300
|
+
} else {
|
|
301
|
+
let cacheDirectory;
|
|
302
|
+
if (process.platform === 'linux') cacheDirectory = process.env.XDG_CACHE_HOME || _path.default.join(os.homedir(), '.cache');else if (process.platform === 'darwin') cacheDirectory = _path.default.join(os.homedir(), 'Library', 'Caches');else if (process.platform === 'win32') cacheDirectory = process.env.LOCALAPPDATA || _path.default.join(os.homedir(), 'AppData', 'Local');else throw new Error('Unsupported platform: ' + process.platform);
|
|
303
|
+
result = _path.default.join(cacheDirectory, 'ms-playwright');
|
|
304
|
+
}
|
|
305
|
+
if (!_path.default.isAbsolute(result)) {
|
|
306
|
+
// It is important to resolve to the absolute path:
|
|
307
|
+
// - for unzipping to work correctly;
|
|
308
|
+
// - so that registry directory matches between installation and execution.
|
|
309
|
+
// INIT_CWD points to the root of `npm/yarn install` and is probably what
|
|
310
|
+
// the user meant when typing the relative path.
|
|
311
|
+
result = _path.default.resolve((0, _utils.getFromENV)('INIT_CWD') || process.cwd(), result);
|
|
312
|
+
}
|
|
313
|
+
return result;
|
|
314
|
+
})();
|
|
315
|
+
function isBrowserDirectory(browserDirectory) {
|
|
316
|
+
const baseName = _path.default.basename(browserDirectory);
|
|
317
|
+
for (const browserName of allDownloadable) {
|
|
318
|
+
if (baseName.startsWith(browserName + '-')) return true;
|
|
319
|
+
}
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
function readDescriptors(browsersJSON) {
|
|
323
|
+
return browsersJSON['browsers'].map(obj => {
|
|
324
|
+
const name = obj.name;
|
|
325
|
+
const revisionOverride = (obj.revisionOverrides || {})[_hostPlatform.hostPlatform];
|
|
326
|
+
const revision = revisionOverride || obj.revision;
|
|
327
|
+
const browserDirectoryPrefix = revisionOverride ? `${name}_${_hostPlatform.hostPlatform}_special` : `${name}`;
|
|
328
|
+
const descriptor = {
|
|
329
|
+
name,
|
|
330
|
+
revision,
|
|
331
|
+
// We only put browser version for the supported operating systems.
|
|
332
|
+
browserVersion: revisionOverride ? undefined : obj.browserVersion,
|
|
333
|
+
installByDefault: !!obj.installByDefault,
|
|
334
|
+
// Method `isBrowserDirectory` determines directory to be browser iff
|
|
335
|
+
// it starts with some browser name followed by '-'. Some browser names
|
|
336
|
+
// are prefixes of others, e.g. 'webkit' is a prefix of `webkit-technology-preview`.
|
|
337
|
+
// To avoid older registries erroneously removing 'webkit-technology-preview', we have to
|
|
338
|
+
// ensure that browser folders to never include dashes inside.
|
|
339
|
+
dir: _path.default.join(registryDirectory, browserDirectoryPrefix.replace(/-/g, '_') + '-' + revision)
|
|
340
|
+
};
|
|
341
|
+
return descriptor;
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
const allDownloadable = ['chromium', 'firefox', 'webkit', 'ffmpeg', 'firefox-beta', 'chromium-with-symbols', 'chromium-tip-of-tree'];
|
|
345
|
+
class Registry {
|
|
346
|
+
constructor(browsersJSON) {
|
|
347
|
+
this._executables = void 0;
|
|
348
|
+
const descriptors = readDescriptors(browsersJSON);
|
|
349
|
+
const findExecutablePath = (dir, name) => {
|
|
350
|
+
let tokens = undefined;
|
|
351
|
+
if (process.platform === 'linux') tokens = EXECUTABLE_PATHS[name]['linux'];else if (process.platform === 'darwin') tokens = EXECUTABLE_PATHS[name]['mac'];else if (process.platform === 'win32') tokens = EXECUTABLE_PATHS[name]['win'];
|
|
352
|
+
return tokens ? _path.default.join(dir, ...tokens) : undefined;
|
|
353
|
+
};
|
|
354
|
+
const executablePathOrDie = (name, e, installByDefault, sdkLanguage) => {
|
|
355
|
+
if (!e) throw new Error(`${name} is not supported on ${_hostPlatform.hostPlatform}`);
|
|
356
|
+
const installCommand = buildPlaywrightCLICommand(sdkLanguage, `install${installByDefault ? '' : ' ' + name}`);
|
|
357
|
+
if (!(0, _fileUtils.canAccessFile)(e)) {
|
|
358
|
+
const currentDockerVersion = (0, _dependencies.readDockerVersionSync)();
|
|
359
|
+
const preferredDockerVersion = currentDockerVersion ? (0, _dependencies.dockerVersion)(currentDockerVersion.dockerImageNameTemplate) : null;
|
|
360
|
+
const isOutdatedDockerImage = currentDockerVersion && preferredDockerVersion && currentDockerVersion.dockerImageName !== preferredDockerVersion.dockerImageName;
|
|
361
|
+
const prettyMessage = isOutdatedDockerImage ? [`Looks like ${sdkLanguage === 'javascript' ? 'Playwright Test or ' : ''}Playwright was just updated to ${preferredDockerVersion.driverVersion}.`, `Please update docker image as well.`, `- current: ${currentDockerVersion.dockerImageName}`, `- required: ${preferredDockerVersion.dockerImageName}`, ``, `<3 Playwright Team`].join('\n') : [`Looks like ${sdkLanguage === 'javascript' ? 'Playwright Test or ' : ''}Playwright was just installed or updated.`, `Please run the following command to download new browser${installByDefault ? 's' : ''}:`, ``, ` ${installCommand}`, ``, `<3 Playwright Team`].join('\n');
|
|
362
|
+
throw new Error(`Executable doesn't exist at ${e}\n${(0, _utils.wrapInASCIIBox)(prettyMessage, 1)}`);
|
|
363
|
+
}
|
|
364
|
+
return e;
|
|
365
|
+
};
|
|
366
|
+
this._executables = [];
|
|
367
|
+
const chromium = descriptors.find(d => d.name === 'chromium');
|
|
368
|
+
const chromiumExecutable = findExecutablePath(chromium.dir, 'chromium');
|
|
369
|
+
this._executables.push({
|
|
370
|
+
type: 'browser',
|
|
371
|
+
name: 'chromium',
|
|
372
|
+
browserName: 'chromium',
|
|
373
|
+
directory: chromium.dir,
|
|
374
|
+
executablePath: () => chromiumExecutable,
|
|
375
|
+
executablePathOrDie: sdkLanguage => executablePathOrDie('chromium', chromiumExecutable, chromium.installByDefault, sdkLanguage),
|
|
376
|
+
installType: chromium.installByDefault ? 'download-by-default' : 'download-on-demand',
|
|
377
|
+
_validateHostRequirements: sdkLanguage => this._validateHostRequirements(sdkLanguage, 'chromium', chromium.dir, ['chrome-linux'], [], ['chrome-win']),
|
|
378
|
+
downloadURLs: this._downloadURLs(chromium),
|
|
379
|
+
browserVersion: chromium.browserVersion,
|
|
380
|
+
_install: () => this._downloadExecutable(chromium, chromiumExecutable),
|
|
381
|
+
_dependencyGroup: 'chromium',
|
|
382
|
+
_isHermeticInstallation: true
|
|
383
|
+
});
|
|
384
|
+
const chromiumWithSymbols = descriptors.find(d => d.name === 'chromium-with-symbols');
|
|
385
|
+
const chromiumWithSymbolsExecutable = findExecutablePath(chromiumWithSymbols.dir, 'chromium');
|
|
386
|
+
this._executables.push({
|
|
387
|
+
type: 'tool',
|
|
388
|
+
name: 'chromium-with-symbols',
|
|
389
|
+
browserName: 'chromium',
|
|
390
|
+
directory: chromiumWithSymbols.dir,
|
|
391
|
+
executablePath: () => chromiumWithSymbolsExecutable,
|
|
392
|
+
executablePathOrDie: sdkLanguage => executablePathOrDie('chromium-with-symbols', chromiumWithSymbolsExecutable, chromiumWithSymbols.installByDefault, sdkLanguage),
|
|
393
|
+
installType: chromiumWithSymbols.installByDefault ? 'download-by-default' : 'download-on-demand',
|
|
394
|
+
_validateHostRequirements: sdkLanguage => this._validateHostRequirements(sdkLanguage, 'chromium', chromiumWithSymbols.dir, ['chrome-linux'], [], ['chrome-win']),
|
|
395
|
+
downloadURLs: this._downloadURLs(chromiumWithSymbols),
|
|
396
|
+
browserVersion: chromiumWithSymbols.browserVersion,
|
|
397
|
+
_install: () => this._downloadExecutable(chromiumWithSymbols, chromiumWithSymbolsExecutable),
|
|
398
|
+
_dependencyGroup: 'chromium',
|
|
399
|
+
_isHermeticInstallation: true
|
|
400
|
+
});
|
|
401
|
+
const chromiumTipOfTree = descriptors.find(d => d.name === 'chromium-tip-of-tree');
|
|
402
|
+
const chromiumTipOfTreeExecutable = findExecutablePath(chromiumTipOfTree.dir, 'chromium');
|
|
403
|
+
this._executables.push({
|
|
404
|
+
type: 'tool',
|
|
405
|
+
name: 'chromium-tip-of-tree',
|
|
406
|
+
browserName: 'chromium',
|
|
407
|
+
directory: chromiumTipOfTree.dir,
|
|
408
|
+
executablePath: () => chromiumTipOfTreeExecutable,
|
|
409
|
+
executablePathOrDie: sdkLanguage => executablePathOrDie('chromium-tip-of-tree', chromiumTipOfTreeExecutable, chromiumTipOfTree.installByDefault, sdkLanguage),
|
|
410
|
+
installType: chromiumTipOfTree.installByDefault ? 'download-by-default' : 'download-on-demand',
|
|
411
|
+
_validateHostRequirements: sdkLanguage => this._validateHostRequirements(sdkLanguage, 'chromium', chromiumTipOfTree.dir, ['chrome-linux'], [], ['chrome-win']),
|
|
412
|
+
downloadURLs: this._downloadURLs(chromiumTipOfTree),
|
|
413
|
+
browserVersion: chromiumTipOfTree.browserVersion,
|
|
414
|
+
_install: () => this._downloadExecutable(chromiumTipOfTree, chromiumTipOfTreeExecutable),
|
|
415
|
+
_dependencyGroup: 'chromium',
|
|
416
|
+
_isHermeticInstallation: true
|
|
417
|
+
});
|
|
418
|
+
this._executables.push(this._createChromiumChannel('chrome', {
|
|
419
|
+
'linux': '/opt/google/chrome/chrome',
|
|
420
|
+
'darwin': '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
421
|
+
'win32': `\\Google\\Chrome\\Application\\chrome.exe`
|
|
422
|
+
}, () => this._installChromiumChannel('chrome', {
|
|
423
|
+
'linux': 'reinstall_chrome_stable_linux.sh',
|
|
424
|
+
'darwin': 'reinstall_chrome_stable_mac.sh',
|
|
425
|
+
'win32': 'reinstall_chrome_stable_win.ps1'
|
|
426
|
+
})));
|
|
427
|
+
this._executables.push(this._createChromiumChannel('chrome-beta', {
|
|
428
|
+
'linux': '/opt/google/chrome-beta/chrome',
|
|
429
|
+
'darwin': '/Applications/Google Chrome Beta.app/Contents/MacOS/Google Chrome Beta',
|
|
430
|
+
'win32': `\\Google\\Chrome Beta\\Application\\chrome.exe`
|
|
431
|
+
}, () => this._installChromiumChannel('chrome-beta', {
|
|
432
|
+
'linux': 'reinstall_chrome_beta_linux.sh',
|
|
433
|
+
'darwin': 'reinstall_chrome_beta_mac.sh',
|
|
434
|
+
'win32': 'reinstall_chrome_beta_win.ps1'
|
|
435
|
+
})));
|
|
436
|
+
this._executables.push(this._createChromiumChannel('chrome-dev', {
|
|
437
|
+
'linux': '/opt/google/chrome-unstable/chrome',
|
|
438
|
+
'darwin': '/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev',
|
|
439
|
+
'win32': `\\Google\\Chrome Dev\\Application\\chrome.exe`
|
|
440
|
+
}));
|
|
441
|
+
this._executables.push(this._createChromiumChannel('chrome-canary', {
|
|
442
|
+
'linux': '',
|
|
443
|
+
'darwin': '/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary',
|
|
444
|
+
'win32': `\\Google\\Chrome SxS\\Application\\chrome.exe`
|
|
445
|
+
}));
|
|
446
|
+
this._executables.push(this._createChromiumChannel('msedge', {
|
|
447
|
+
'linux': '/opt/microsoft/msedge/msedge',
|
|
448
|
+
'darwin': '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
|
|
449
|
+
'win32': `\\Microsoft\\Edge\\Application\\msedge.exe`
|
|
450
|
+
}, () => this._installMSEdgeChannel('msedge', {
|
|
451
|
+
'linux': 'reinstall_msedge_stable_linux.sh',
|
|
452
|
+
'darwin': 'reinstall_msedge_stable_mac.sh',
|
|
453
|
+
'win32': 'reinstall_msedge_stable_win.ps1'
|
|
454
|
+
})));
|
|
455
|
+
this._executables.push(this._createChromiumChannel('msedge-beta', {
|
|
456
|
+
'linux': '/opt/microsoft/msedge-beta/msedge',
|
|
457
|
+
'darwin': '/Applications/Microsoft Edge Beta.app/Contents/MacOS/Microsoft Edge Beta',
|
|
458
|
+
'win32': `\\Microsoft\\Edge Beta\\Application\\msedge.exe`
|
|
459
|
+
}, () => this._installMSEdgeChannel('msedge-beta', {
|
|
460
|
+
'darwin': 'reinstall_msedge_beta_mac.sh',
|
|
461
|
+
'linux': 'reinstall_msedge_beta_linux.sh',
|
|
462
|
+
'win32': 'reinstall_msedge_beta_win.ps1'
|
|
463
|
+
})));
|
|
464
|
+
this._executables.push(this._createChromiumChannel('msedge-dev', {
|
|
465
|
+
'linux': '/opt/microsoft/msedge-dev/msedge',
|
|
466
|
+
'darwin': '/Applications/Microsoft Edge Dev.app/Contents/MacOS/Microsoft Edge Dev',
|
|
467
|
+
'win32': `\\Microsoft\\Edge Dev\\Application\\msedge.exe`
|
|
468
|
+
}, () => this._installMSEdgeChannel('msedge-dev', {
|
|
469
|
+
'darwin': 'reinstall_msedge_dev_mac.sh',
|
|
470
|
+
'linux': 'reinstall_msedge_dev_linux.sh',
|
|
471
|
+
'win32': 'reinstall_msedge_dev_win.ps1'
|
|
472
|
+
})));
|
|
473
|
+
this._executables.push(this._createChromiumChannel('msedge-canary', {
|
|
474
|
+
'linux': '',
|
|
475
|
+
'darwin': '/Applications/Microsoft Edge Canary.app/Contents/MacOS/Microsoft Edge Canary',
|
|
476
|
+
'win32': `\\Microsoft\\Edge SxS\\Application\\msedge.exe`
|
|
477
|
+
}));
|
|
478
|
+
const firefox = descriptors.find(d => d.name === 'firefox');
|
|
479
|
+
const firefoxExecutable = findExecutablePath(firefox.dir, 'firefox');
|
|
480
|
+
this._executables.push({
|
|
481
|
+
type: 'browser',
|
|
482
|
+
name: 'firefox',
|
|
483
|
+
browserName: 'firefox',
|
|
484
|
+
directory: firefox.dir,
|
|
485
|
+
executablePath: () => firefoxExecutable,
|
|
486
|
+
executablePathOrDie: sdkLanguage => executablePathOrDie('firefox', firefoxExecutable, firefox.installByDefault, sdkLanguage),
|
|
487
|
+
installType: firefox.installByDefault ? 'download-by-default' : 'download-on-demand',
|
|
488
|
+
_validateHostRequirements: sdkLanguage => this._validateHostRequirements(sdkLanguage, 'firefox', firefox.dir, ['firefox'], [], ['firefox']),
|
|
489
|
+
downloadURLs: this._downloadURLs(firefox),
|
|
490
|
+
browserVersion: firefox.browserVersion,
|
|
491
|
+
_install: () => this._downloadExecutable(firefox, firefoxExecutable),
|
|
492
|
+
_dependencyGroup: 'firefox',
|
|
493
|
+
_isHermeticInstallation: true
|
|
494
|
+
});
|
|
495
|
+
const firefoxAsan = descriptors.find(d => d.name === 'firefox-asan');
|
|
496
|
+
const firefoxAsanExecutable = findExecutablePath(firefoxAsan.dir, 'firefox');
|
|
497
|
+
this._executables.push({
|
|
498
|
+
type: 'browser',
|
|
499
|
+
name: 'firefox-asan',
|
|
500
|
+
browserName: 'firefox',
|
|
501
|
+
directory: firefoxAsan.dir,
|
|
502
|
+
executablePath: () => firefoxAsanExecutable,
|
|
503
|
+
executablePathOrDie: sdkLanguage => executablePathOrDie('firefox-asan', firefoxAsanExecutable, firefoxAsan.installByDefault, sdkLanguage),
|
|
504
|
+
installType: firefoxAsan.installByDefault ? 'download-by-default' : 'download-on-demand',
|
|
505
|
+
_validateHostRequirements: sdkLanguage => this._validateHostRequirements(sdkLanguage, 'firefox', firefoxAsan.dir, ['firefox'], [], ['firefox']),
|
|
506
|
+
downloadURLs: this._downloadURLs(firefoxAsan),
|
|
507
|
+
browserVersion: firefoxAsan.browserVersion,
|
|
508
|
+
_install: () => this._downloadExecutable(firefoxAsan, firefoxAsanExecutable),
|
|
509
|
+
_dependencyGroup: 'firefox',
|
|
510
|
+
_isHermeticInstallation: true
|
|
511
|
+
});
|
|
512
|
+
const firefoxBeta = descriptors.find(d => d.name === 'firefox-beta');
|
|
513
|
+
const firefoxBetaExecutable = findExecutablePath(firefoxBeta.dir, 'firefox');
|
|
514
|
+
this._executables.push({
|
|
515
|
+
type: 'tool',
|
|
516
|
+
name: 'firefox-beta',
|
|
517
|
+
browserName: 'firefox',
|
|
518
|
+
directory: firefoxBeta.dir,
|
|
519
|
+
executablePath: () => firefoxBetaExecutable,
|
|
520
|
+
executablePathOrDie: sdkLanguage => executablePathOrDie('firefox-beta', firefoxBetaExecutable, firefoxBeta.installByDefault, sdkLanguage),
|
|
521
|
+
installType: firefoxBeta.installByDefault ? 'download-by-default' : 'download-on-demand',
|
|
522
|
+
_validateHostRequirements: sdkLanguage => this._validateHostRequirements(sdkLanguage, 'firefox', firefoxBeta.dir, ['firefox'], [], ['firefox']),
|
|
523
|
+
downloadURLs: this._downloadURLs(firefoxBeta),
|
|
524
|
+
browserVersion: firefoxBeta.browserVersion,
|
|
525
|
+
_install: () => this._downloadExecutable(firefoxBeta, firefoxBetaExecutable),
|
|
526
|
+
_dependencyGroup: 'firefox',
|
|
527
|
+
_isHermeticInstallation: true
|
|
528
|
+
});
|
|
529
|
+
const webkit = descriptors.find(d => d.name === 'webkit');
|
|
530
|
+
const webkitExecutable = findExecutablePath(webkit.dir, 'webkit');
|
|
531
|
+
const webkitLinuxLddDirectories = [_path.default.join('minibrowser-gtk'), _path.default.join('minibrowser-gtk', 'bin'), _path.default.join('minibrowser-gtk', 'lib'), _path.default.join('minibrowser-gtk', 'sys', 'lib'), _path.default.join('minibrowser-wpe'), _path.default.join('minibrowser-wpe', 'bin'), _path.default.join('minibrowser-wpe', 'lib'), _path.default.join('minibrowser-wpe', 'sys', 'lib')];
|
|
532
|
+
this._executables.push({
|
|
533
|
+
type: 'browser',
|
|
534
|
+
name: 'webkit',
|
|
535
|
+
browserName: 'webkit',
|
|
536
|
+
directory: webkit.dir,
|
|
537
|
+
executablePath: () => webkitExecutable,
|
|
538
|
+
executablePathOrDie: sdkLanguage => executablePathOrDie('webkit', webkitExecutable, webkit.installByDefault, sdkLanguage),
|
|
539
|
+
installType: webkit.installByDefault ? 'download-by-default' : 'download-on-demand',
|
|
540
|
+
_validateHostRequirements: sdkLanguage => this._validateHostRequirements(sdkLanguage, 'webkit', webkit.dir, webkitLinuxLddDirectories, ['libGLESv2.so.2', 'libx264.so'], ['']),
|
|
541
|
+
downloadURLs: this._downloadURLs(webkit),
|
|
542
|
+
browserVersion: webkit.browserVersion,
|
|
543
|
+
_install: () => this._downloadExecutable(webkit, webkitExecutable),
|
|
544
|
+
_dependencyGroup: 'webkit',
|
|
545
|
+
_isHermeticInstallation: true
|
|
546
|
+
});
|
|
547
|
+
const ffmpeg = descriptors.find(d => d.name === 'ffmpeg');
|
|
548
|
+
const ffmpegExecutable = findExecutablePath(ffmpeg.dir, 'ffmpeg');
|
|
549
|
+
this._executables.push({
|
|
550
|
+
type: 'tool',
|
|
551
|
+
name: 'ffmpeg',
|
|
552
|
+
browserName: undefined,
|
|
553
|
+
directory: ffmpeg.dir,
|
|
554
|
+
executablePath: () => ffmpegExecutable,
|
|
555
|
+
executablePathOrDie: sdkLanguage => executablePathOrDie('ffmpeg', ffmpegExecutable, ffmpeg.installByDefault, sdkLanguage),
|
|
556
|
+
installType: ffmpeg.installByDefault ? 'download-by-default' : 'download-on-demand',
|
|
557
|
+
_validateHostRequirements: () => Promise.resolve(),
|
|
558
|
+
downloadURLs: this._downloadURLs(ffmpeg),
|
|
559
|
+
_install: () => this._downloadExecutable(ffmpeg, ffmpegExecutable),
|
|
560
|
+
_dependencyGroup: 'tools',
|
|
561
|
+
_isHermeticInstallation: true
|
|
562
|
+
});
|
|
563
|
+
const android = descriptors.find(d => d.name === 'android');
|
|
564
|
+
this._executables.push({
|
|
565
|
+
type: 'tool',
|
|
566
|
+
name: 'android',
|
|
567
|
+
browserName: undefined,
|
|
568
|
+
directory: android.dir,
|
|
569
|
+
executablePath: () => undefined,
|
|
570
|
+
executablePathOrDie: () => '',
|
|
571
|
+
installType: 'download-on-demand',
|
|
572
|
+
_validateHostRequirements: () => Promise.resolve(),
|
|
573
|
+
downloadURLs: this._downloadURLs(android),
|
|
574
|
+
_install: () => this._downloadExecutable(android),
|
|
575
|
+
_dependencyGroup: 'tools',
|
|
576
|
+
_isHermeticInstallation: true
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
_createChromiumChannel(name, lookAt, install) {
|
|
580
|
+
const executablePath = (sdkLanguage, shouldThrow) => {
|
|
581
|
+
const suffix = lookAt[process.platform];
|
|
582
|
+
if (!suffix) {
|
|
583
|
+
if (shouldThrow) throw new Error(`Chromium distribution '${name}' is not supported on ${process.platform}`);
|
|
584
|
+
return undefined;
|
|
585
|
+
}
|
|
586
|
+
const prefixes = process.platform === 'win32' ? [process.env.LOCALAPPDATA, process.env.PROGRAMFILES, process.env['PROGRAMFILES(X86)']].filter(Boolean) : [''];
|
|
587
|
+
for (const prefix of prefixes) {
|
|
588
|
+
const executablePath = _path.default.join(prefix, suffix);
|
|
589
|
+
if ((0, _fileUtils.canAccessFile)(executablePath)) return executablePath;
|
|
590
|
+
}
|
|
591
|
+
if (!shouldThrow) return undefined;
|
|
592
|
+
const location = prefixes.length ? ` at ${_path.default.join(prefixes[0], suffix)}` : ``;
|
|
593
|
+
const installation = install ? `\nRun "${buildPlaywrightCLICommand(sdkLanguage, 'install ' + name)}"` : '';
|
|
594
|
+
throw new Error(`Chromium distribution '${name}' is not found${location}${installation}`);
|
|
595
|
+
};
|
|
596
|
+
return {
|
|
597
|
+
type: 'channel',
|
|
598
|
+
name,
|
|
599
|
+
browserName: 'chromium',
|
|
600
|
+
directory: undefined,
|
|
601
|
+
executablePath: sdkLanguage => executablePath(sdkLanguage, false),
|
|
602
|
+
executablePathOrDie: sdkLanguage => executablePath(sdkLanguage, true),
|
|
603
|
+
installType: install ? 'install-script' : 'none',
|
|
604
|
+
_validateHostRequirements: () => Promise.resolve(),
|
|
605
|
+
_isHermeticInstallation: false,
|
|
606
|
+
_install: install
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
executables() {
|
|
610
|
+
return this._executables;
|
|
611
|
+
}
|
|
612
|
+
findExecutable(name) {
|
|
613
|
+
return this._executables.find(b => b.name === name);
|
|
614
|
+
}
|
|
615
|
+
defaultExecutables() {
|
|
616
|
+
return this._executables.filter(e => e.installType === 'download-by-default');
|
|
617
|
+
}
|
|
618
|
+
_addRequirementsAndDedupe(executables) {
|
|
619
|
+
const set = new Set();
|
|
620
|
+
for (const executable of executables) {
|
|
621
|
+
set.add(executable);
|
|
622
|
+
if (executable.browserName === 'chromium') set.add(this.findExecutable('ffmpeg'));
|
|
623
|
+
}
|
|
624
|
+
return Array.from(set);
|
|
625
|
+
}
|
|
626
|
+
async _validateHostRequirements(sdkLanguage, browserName, browserDirectory, linuxLddDirectories, dlOpenLibraries, windowsExeAndDllDirectories) {
|
|
627
|
+
if (os.platform() === 'linux') return await (0, _dependencies.validateDependenciesLinux)(sdkLanguage, linuxLddDirectories.map(d => _path.default.join(browserDirectory, d)), dlOpenLibraries);
|
|
628
|
+
if (os.platform() === 'win32' && os.arch() === 'x64') return await (0, _dependencies.validateDependenciesWindows)(windowsExeAndDllDirectories.map(d => _path.default.join(browserDirectory, d)));
|
|
629
|
+
}
|
|
630
|
+
async installDeps(executablesToInstallDeps, dryRun) {
|
|
631
|
+
const executables = this._addRequirementsAndDedupe(executablesToInstallDeps);
|
|
632
|
+
const targets = new Set();
|
|
633
|
+
for (const executable of executables) {
|
|
634
|
+
if (executable._dependencyGroup) targets.add(executable._dependencyGroup);
|
|
635
|
+
}
|
|
636
|
+
targets.add('tools');
|
|
637
|
+
if (os.platform() === 'win32') return await (0, _dependencies.installDependenciesWindows)(targets, dryRun);
|
|
638
|
+
if (os.platform() === 'linux') return await (0, _dependencies.installDependenciesLinux)(targets, dryRun);
|
|
639
|
+
}
|
|
640
|
+
async install(executablesToInstall, forceReinstall) {
|
|
641
|
+
const executables = this._addRequirementsAndDedupe(executablesToInstall);
|
|
642
|
+
await fs.promises.mkdir(registryDirectory, {
|
|
643
|
+
recursive: true
|
|
644
|
+
});
|
|
645
|
+
const lockfilePath = _path.default.join(registryDirectory, '__dirlock');
|
|
646
|
+
const linksDir = _path.default.join(registryDirectory, '.links');
|
|
647
|
+
let releaseLock;
|
|
648
|
+
try {
|
|
649
|
+
releaseLock = await _utilsBundle.lockfile.lock(registryDirectory, {
|
|
650
|
+
retries: {
|
|
651
|
+
// Retry 20 times during 10 minutes with
|
|
652
|
+
// exponential back-off.
|
|
653
|
+
// See documentation at: https://www.npmjs.com/package/retry#retrytimeoutsoptions
|
|
654
|
+
retries: 20,
|
|
655
|
+
factor: 1.27579
|
|
656
|
+
},
|
|
657
|
+
onCompromised: err => {
|
|
658
|
+
throw new Error(`${err.message} Path: ${lockfilePath}`);
|
|
659
|
+
},
|
|
660
|
+
lockfilePath
|
|
661
|
+
});
|
|
662
|
+
// Create a link first, so that cache validation does not remove our own browsers.
|
|
663
|
+
await fs.promises.mkdir(linksDir, {
|
|
664
|
+
recursive: true
|
|
665
|
+
});
|
|
666
|
+
await fs.promises.writeFile(_path.default.join(linksDir, (0, _utils.calculateSha1)(PACKAGE_PATH)), PACKAGE_PATH);
|
|
667
|
+
|
|
668
|
+
// Remove stale browsers.
|
|
669
|
+
await this._validateInstallationCache(linksDir);
|
|
670
|
+
|
|
671
|
+
// Install browsers for this package.
|
|
672
|
+
for (const executable of executables) {
|
|
673
|
+
if (!executable._install) throw new Error(`ERROR: Playwright does not support installing ${executable.name}`);
|
|
674
|
+
const {
|
|
675
|
+
embedderName
|
|
676
|
+
} = (0, _userAgent.getEmbedderName)();
|
|
677
|
+
if (!(0, _utils.getAsBooleanFromENV)('CI') && !executable._isHermeticInstallation && !forceReinstall && executable.executablePath(embedderName)) {
|
|
678
|
+
const command = buildPlaywrightCLICommand(embedderName, 'install --force ' + executable.name);
|
|
679
|
+
throw new Error('\n' + (0, _utils.wrapInASCIIBox)([`ATTENTION: "${executable.name}" is already installed on the system!`, ``, `"${executable.name}" installation is not hermetic; installing newer version`, `requires *removal* of a current installation first.`, ``, `To *uninstall* current version and re-install latest "${executable.name}":`, ``, `- Close all running instances of "${executable.name}", if any`, `- Use "--force" to install browser:`, ``, ` ${command}`, ``, `<3 Playwright Team`].join('\n'), 1));
|
|
680
|
+
}
|
|
681
|
+
await executable._install();
|
|
682
|
+
}
|
|
683
|
+
} catch (e) {
|
|
684
|
+
if (e.code === 'ELOCKED') {
|
|
685
|
+
const rmCommand = process.platform === 'win32' ? 'rm -R' : 'rm -rf';
|
|
686
|
+
throw new Error('\n' + (0, _utils.wrapInASCIIBox)([`An active lockfile is found at:`, ``, ` ${lockfilePath}`, ``, `Either:`, `- wait a few minutes if other Playwright is installing browsers in parallel`, `- remove lock manually with:`, ``, ` ${rmCommand} ${lockfilePath}`, ``, `<3 Playwright Team`].join('\n'), 1));
|
|
687
|
+
} else {
|
|
688
|
+
throw e;
|
|
689
|
+
}
|
|
690
|
+
} finally {
|
|
691
|
+
if (releaseLock) await releaseLock();
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
async uninstall(all) {
|
|
695
|
+
const linksDir = _path.default.join(registryDirectory, '.links');
|
|
696
|
+
if (all) {
|
|
697
|
+
const links = await fs.promises.readdir(linksDir).catch(() => []);
|
|
698
|
+
for (const link of links) await fs.promises.unlink(_path.default.join(linksDir, link));
|
|
699
|
+
} else {
|
|
700
|
+
await fs.promises.unlink(_path.default.join(linksDir, (0, _utils.calculateSha1)(PACKAGE_PATH))).catch(() => {});
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
// Remove stale browsers.
|
|
704
|
+
await this._validateInstallationCache(linksDir);
|
|
705
|
+
return {
|
|
706
|
+
numberOfBrowsersLeft: (await fs.promises.readdir(registryDirectory).catch(() => [])).filter(browserDirectory => isBrowserDirectory(browserDirectory)).length
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
async validateHostRequirementsForExecutablesIfNeeded(executables, sdkLanguage) {
|
|
710
|
+
if ((0, _utils.getAsBooleanFromENV)('PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS')) {
|
|
711
|
+
process.stderr.write('Skipping host requirements validation logic because `PLAYWRIGHT_SKIP_VALIDATE_HOST_REQUIREMENTS` env variable is set.\n');
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
for (const executable of executables) await this._validateHostRequirementsForExecutableIfNeeded(executable, sdkLanguage);
|
|
715
|
+
}
|
|
716
|
+
async _validateHostRequirementsForExecutableIfNeeded(executable, sdkLanguage) {
|
|
717
|
+
const kMaximumReValidationPeriod = 30 * 24 * 60 * 60 * 1000; // 30 days
|
|
718
|
+
// Executable does not require validation.
|
|
719
|
+
if (!executable.directory) return;
|
|
720
|
+
const markerFile = _path.default.join(executable.directory, 'DEPENDENCIES_VALIDATED');
|
|
721
|
+
// Executable is already validated.
|
|
722
|
+
if (await fs.promises.stat(markerFile).then(stat => Date.now() - stat.mtime.getTime() < kMaximumReValidationPeriod).catch(() => false)) return;
|
|
723
|
+
_debugLogger.debugLogger.log('install', `validating host requirements for "${executable.name}"`);
|
|
724
|
+
try {
|
|
725
|
+
await executable._validateHostRequirements(sdkLanguage);
|
|
726
|
+
_debugLogger.debugLogger.log('install', `validation passed for ${executable.name}`);
|
|
727
|
+
} catch (error) {
|
|
728
|
+
_debugLogger.debugLogger.log('install', `validation failed for ${executable.name}`);
|
|
729
|
+
throw error;
|
|
730
|
+
}
|
|
731
|
+
await fs.promises.writeFile(markerFile, '').catch(() => {});
|
|
732
|
+
}
|
|
733
|
+
_downloadURLs(descriptor) {
|
|
734
|
+
const paths = DOWNLOAD_PATHS[descriptor.name];
|
|
735
|
+
const downloadPathTemplate = paths[_hostPlatform.hostPlatform] || paths['<unknown>'];
|
|
736
|
+
if (!downloadPathTemplate) return [];
|
|
737
|
+
const downloadPath = util.format(downloadPathTemplate, descriptor.revision);
|
|
738
|
+
let downloadURLs = PLAYWRIGHT_CDN_MIRRORS.map(mirror => `${mirror}/${downloadPath}`);
|
|
739
|
+
let downloadHostEnv;
|
|
740
|
+
if (descriptor.name.startsWith('chromium')) downloadHostEnv = 'PLAYWRIGHT_CHROMIUM_DOWNLOAD_HOST';else if (descriptor.name.startsWith('firefox')) downloadHostEnv = 'PLAYWRIGHT_FIREFOX_DOWNLOAD_HOST';else if (descriptor.name.startsWith('webkit')) downloadHostEnv = 'PLAYWRIGHT_WEBKIT_DOWNLOAD_HOST';
|
|
741
|
+
const customHostOverride = downloadHostEnv && (0, _utils.getFromENV)(downloadHostEnv) || (0, _utils.getFromENV)('PLAYWRIGHT_DOWNLOAD_HOST');
|
|
742
|
+
if (customHostOverride) downloadURLs = [`${customHostOverride}/${downloadPath}`];
|
|
743
|
+
return downloadURLs;
|
|
744
|
+
}
|
|
745
|
+
async _downloadExecutable(descriptor, executablePath) {
|
|
746
|
+
const downloadURLs = this._downloadURLs(descriptor);
|
|
747
|
+
if (!downloadURLs.length) throw new Error(`ERROR: Playwright does not support ${descriptor.name} on ${_hostPlatform.hostPlatform}`);
|
|
748
|
+
if (!_hostPlatform.isOfficiallySupportedPlatform) (0, _browserFetcher.logPolitely)(`BEWARE: your OS is not officially supported by Playwright; downloading fallback build for ${_hostPlatform.hostPlatform}.`);
|
|
749
|
+
const displayName = descriptor.name.split('-').map(word => {
|
|
750
|
+
return word === 'ffmpeg' ? 'FFMPEG' : word.charAt(0).toUpperCase() + word.slice(1);
|
|
751
|
+
}).join(' ');
|
|
752
|
+
const title = descriptor.browserVersion ? `${displayName} ${descriptor.browserVersion} (playwright build v${descriptor.revision})` : `${displayName} playwright build v${descriptor.revision}`;
|
|
753
|
+
const downloadFileName = `playwright-download-${descriptor.name}-${_hostPlatform.hostPlatform}-${descriptor.revision}.zip`;
|
|
754
|
+
const downloadConnectionTimeoutEnv = (0, _utils.getFromENV)('PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT');
|
|
755
|
+
const downloadConnectionTimeout = +(downloadConnectionTimeoutEnv || '0') || 30_000;
|
|
756
|
+
await (0, _browserFetcher.downloadBrowserWithProgressBar)(title, descriptor.dir, executablePath, downloadURLs, downloadFileName, downloadConnectionTimeout).catch(e => {
|
|
757
|
+
throw new Error(`Failed to download ${title}, caused by\n${e.stack}`);
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
async _installMSEdgeChannel(channel, scripts) {
|
|
761
|
+
const scriptArgs = [];
|
|
762
|
+
if (process.platform !== 'linux') {
|
|
763
|
+
const products = lowercaseAllKeys(JSON.parse(await (0, _network.fetchData)({
|
|
764
|
+
url: 'https://edgeupdates.microsoft.com/api/products'
|
|
765
|
+
})));
|
|
766
|
+
const productName = {
|
|
767
|
+
'msedge': 'Stable',
|
|
768
|
+
'msedge-beta': 'Beta',
|
|
769
|
+
'msedge-dev': 'Dev'
|
|
770
|
+
}[channel];
|
|
771
|
+
const product = products.find(product => product.product === productName);
|
|
772
|
+
const searchConfig = {
|
|
773
|
+
darwin: {
|
|
774
|
+
platform: 'MacOS',
|
|
775
|
+
arch: 'universal',
|
|
776
|
+
artifact: 'pkg'
|
|
777
|
+
},
|
|
778
|
+
win32: {
|
|
779
|
+
platform: 'Windows',
|
|
780
|
+
arch: 'x64',
|
|
781
|
+
artifact: 'msi'
|
|
782
|
+
}
|
|
783
|
+
}[process.platform];
|
|
784
|
+
const release = searchConfig ? product.releases.find(release => release.platform === searchConfig.platform && release.architecture === searchConfig.arch && release.artifacts.length > 0) : null;
|
|
785
|
+
const artifact = release ? release.artifacts.find(artifact => artifact.artifactname === searchConfig.artifact) : null;
|
|
786
|
+
if (artifact) scriptArgs.push(artifact.location /* url */);else throw new Error(`Cannot install ${channel} on ${process.platform}`);
|
|
787
|
+
}
|
|
788
|
+
await this._installChromiumChannel(channel, scripts, scriptArgs);
|
|
789
|
+
}
|
|
790
|
+
async _installChromiumChannel(channel, scripts, scriptArgs = []) {
|
|
791
|
+
const scriptName = scripts[process.platform];
|
|
792
|
+
if (!scriptName) throw new Error(`Cannot install ${channel} on ${process.platform}`);
|
|
793
|
+
const cwd = BIN_PATH;
|
|
794
|
+
const isPowerShell = scriptName.endsWith('.ps1');
|
|
795
|
+
if (isPowerShell) {
|
|
796
|
+
const args = ['-ExecutionPolicy', 'Bypass', '-File', _path.default.join(BIN_PATH, scriptName), ...scriptArgs];
|
|
797
|
+
const {
|
|
798
|
+
code
|
|
799
|
+
} = await (0, _spawnAsync.spawnAsync)('powershell.exe', args, {
|
|
800
|
+
cwd,
|
|
801
|
+
stdio: 'inherit'
|
|
802
|
+
});
|
|
803
|
+
if (code !== 0) throw new Error(`Failed to install ${channel}`);
|
|
804
|
+
} else {
|
|
805
|
+
const {
|
|
806
|
+
command,
|
|
807
|
+
args,
|
|
808
|
+
elevatedPermissions
|
|
809
|
+
} = await (0, _dependencies.transformCommandsForRoot)([`bash "${_path.default.join(BIN_PATH, scriptName)}" ${scriptArgs.join('')}`]);
|
|
810
|
+
if (elevatedPermissions) console.log('Switching to root user to install dependencies...'); // eslint-disable-line no-console
|
|
811
|
+
const {
|
|
812
|
+
code
|
|
813
|
+
} = await (0, _spawnAsync.spawnAsync)(command, args, {
|
|
814
|
+
cwd,
|
|
815
|
+
stdio: 'inherit'
|
|
816
|
+
});
|
|
817
|
+
if (code !== 0) throw new Error(`Failed to install ${channel}`);
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
async _validateInstallationCache(linksDir) {
|
|
821
|
+
// 1. Collect used downloads and package descriptors.
|
|
822
|
+
const usedBrowserPaths = new Set();
|
|
823
|
+
for (const fileName of await fs.promises.readdir(linksDir)) {
|
|
824
|
+
const linkPath = _path.default.join(linksDir, fileName);
|
|
825
|
+
let linkTarget = '';
|
|
826
|
+
try {
|
|
827
|
+
linkTarget = (await fs.promises.readFile(linkPath)).toString();
|
|
828
|
+
const browsersJSON = require(_path.default.join(linkTarget, 'browsers.json'));
|
|
829
|
+
const descriptors = readDescriptors(browsersJSON);
|
|
830
|
+
for (const browserName of allDownloadable) {
|
|
831
|
+
// We retain browsers if they are found in the descriptor.
|
|
832
|
+
// Note, however, that there are older versions out in the wild that rely on
|
|
833
|
+
// the "download" field in the browser descriptor and use its value
|
|
834
|
+
// to retain and download browsers.
|
|
835
|
+
// As of v1.10, we decided to abandon "download" field.
|
|
836
|
+
const descriptor = descriptors.find(d => d.name === browserName);
|
|
837
|
+
if (!descriptor) continue;
|
|
838
|
+
const usedBrowserPath = descriptor.dir;
|
|
839
|
+
const browserRevision = parseInt(descriptor.revision, 10);
|
|
840
|
+
// Old browser installations don't have marker file.
|
|
841
|
+
// We switched chromium from 999999 to 1000, 300000 is the new Y2K.
|
|
842
|
+
const shouldHaveMarkerFile = browserName === 'chromium' && (browserRevision >= 786218 || browserRevision < 300000) || browserName === 'firefox' && browserRevision >= 1128 || browserName === 'webkit' && browserRevision >= 1307 ||
|
|
843
|
+
// All new applications have a marker file right away.
|
|
844
|
+
browserName !== 'firefox' && browserName !== 'chromium' && browserName !== 'webkit';
|
|
845
|
+
if (!shouldHaveMarkerFile || (await (0, _fileUtils.existsAsync)(browserDirectoryToMarkerFilePath(usedBrowserPath)))) usedBrowserPaths.add(usedBrowserPath);
|
|
846
|
+
}
|
|
847
|
+
} catch (e) {
|
|
848
|
+
await fs.promises.unlink(linkPath).catch(e => {});
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
// 2. Delete all unused browsers.
|
|
853
|
+
if (!(0, _utils.getAsBooleanFromENV)('PLAYWRIGHT_SKIP_BROWSER_GC')) {
|
|
854
|
+
let downloadedBrowsers = (await fs.promises.readdir(registryDirectory)).map(file => _path.default.join(registryDirectory, file));
|
|
855
|
+
downloadedBrowsers = downloadedBrowsers.filter(file => isBrowserDirectory(file));
|
|
856
|
+
const directories = new Set(downloadedBrowsers);
|
|
857
|
+
for (const browserDirectory of usedBrowserPaths) directories.delete(browserDirectory);
|
|
858
|
+
for (const directory of directories) (0, _browserFetcher.logPolitely)('Removing unused browser at ' + directory);
|
|
859
|
+
await (0, _fileUtils.removeFolders)([...directories]);
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
exports.Registry = Registry;
|
|
864
|
+
function browserDirectoryToMarkerFilePath(browserDirectory) {
|
|
865
|
+
return _path.default.join(browserDirectory, 'INSTALLATION_COMPLETE');
|
|
866
|
+
}
|
|
867
|
+
function buildPlaywrightCLICommand(sdkLanguage, parameters) {
|
|
868
|
+
switch (sdkLanguage) {
|
|
869
|
+
case 'python':
|
|
870
|
+
return `playwright ${parameters}`;
|
|
871
|
+
case 'java':
|
|
872
|
+
return `mvn exec:java -e -D exec.mainClass=com.microsoft.playwright.CLI -D exec.args="${parameters}"`;
|
|
873
|
+
case 'csharp':
|
|
874
|
+
return `pwsh bin/Debug/netX/playwright.ps1 ${parameters}`;
|
|
875
|
+
default:
|
|
876
|
+
{
|
|
877
|
+
const packageManagerCommand = (0, _utils.getPackageManagerExecCommand)();
|
|
878
|
+
return `${packageManagerCommand} playwright ${parameters}`;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
async function installDefaultBrowsersForNpmInstall() {
|
|
883
|
+
const defaultBrowserNames = registry.defaultExecutables().map(e => e.name);
|
|
884
|
+
return installBrowsersForNpmInstall(defaultBrowserNames);
|
|
885
|
+
}
|
|
886
|
+
async function installBrowsersForNpmInstall(browsers) {
|
|
887
|
+
// PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD should have a value of 0 or 1
|
|
888
|
+
if ((0, _utils.getAsBooleanFromENV)('PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD')) {
|
|
889
|
+
(0, _browserFetcher.logPolitely)('Skipping browsers download because `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable is set');
|
|
890
|
+
return false;
|
|
891
|
+
}
|
|
892
|
+
const executables = [];
|
|
893
|
+
for (const browserName of browsers) {
|
|
894
|
+
const executable = registry.findExecutable(browserName);
|
|
895
|
+
if (!executable || executable.installType === 'none') throw new Error(`Cannot install ${browserName}`);
|
|
896
|
+
executables.push(executable);
|
|
897
|
+
}
|
|
898
|
+
await registry.install(executables, false /* forceReinstall */);
|
|
899
|
+
}
|
|
900
|
+
function findChromiumChannel(sdkLanguage) {
|
|
901
|
+
// Fall back to the stable channels of popular vendors to work out of the box.
|
|
902
|
+
// Null means no installation and no channels found.
|
|
903
|
+
let channel = null;
|
|
904
|
+
for (const name of ['chromium', 'chrome', 'msedge']) {
|
|
905
|
+
try {
|
|
906
|
+
registry.findExecutable(name).executablePathOrDie(sdkLanguage);
|
|
907
|
+
channel = name === 'chromium' ? undefined : name;
|
|
908
|
+
break;
|
|
909
|
+
} catch (e) {}
|
|
910
|
+
}
|
|
911
|
+
if (channel === null) {
|
|
912
|
+
const installCommand = buildPlaywrightCLICommand(sdkLanguage, `install chromium`);
|
|
913
|
+
const prettyMessage = [`No chromium-based browser found on the system.`, `Please run the following command to download one:`, ``, ` ${installCommand}`, ``, `<3 Playwright Team`].join('\n');
|
|
914
|
+
throw new Error('\n' + (0, _utils.wrapInASCIIBox)(prettyMessage, 1));
|
|
915
|
+
}
|
|
916
|
+
return channel;
|
|
917
|
+
}
|
|
918
|
+
function lowercaseAllKeys(json) {
|
|
919
|
+
if (typeof json !== 'object' || !json) return json;
|
|
920
|
+
if (Array.isArray(json)) return json.map(lowercaseAllKeys);
|
|
921
|
+
const result = {};
|
|
922
|
+
for (const [key, value] of Object.entries(json)) result[key.toLowerCase()] = lowercaseAllKeys(value);
|
|
923
|
+
return result;
|
|
924
|
+
}
|
|
925
|
+
const registry = exports.registry = new Registry(require('../../../browsers.json'));
|