@checkly/playwright-core 1.41.2-beta.6 → 1.41.23
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/lib/browserServerImpl.js +1 -1
- package/lib/cli/driver.js +11 -3
- package/lib/cli/program.js +13 -5
- package/lib/client/android.js +1 -1
- package/lib/client/artifact.js +2 -2
- package/lib/client/browserContext.js +5 -5
- package/lib/client/browserType.js +1 -1
- package/lib/client/channelOwner.js +3 -3
- package/lib/client/clientHelper.js +5 -1
- package/lib/client/connection.js +2 -2
- package/lib/client/consoleMessage.js +3 -3
- package/lib/client/electron.js +3 -0
- package/lib/client/events.js +1 -0
- package/lib/client/fetch.js +3 -3
- package/lib/client/frame.js +4 -3
- package/lib/client/harRouter.js +7 -1
- package/lib/client/locator.js +2 -2
- package/lib/client/page.js +26 -7
- package/lib/common/socksProxy.js +12 -17
- package/lib/generated/consoleApiSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/recorderSource.js +1 -1
- package/lib/outofprocess.js +3 -3
- package/lib/protocol/validator.js +46 -29
- package/lib/remote/playwrightConnection.js +2 -2
- package/lib/remote/playwrightServer.js +72 -166
- package/lib/server/android/android.js +2 -2
- package/lib/server/android/backendAdb.js +2 -2
- package/lib/server/browser.js +2 -2
- package/lib/server/browserContext.js +8 -9
- package/lib/server/browserType.js +5 -5
- package/lib/server/chromium/chromium.js +5 -4
- package/lib/server/chromium/crBrowser.js +2 -3
- package/lib/server/chromium/crConnection.js +2 -2
- package/lib/server/chromium/crExecutionContext.js +2 -2
- package/lib/server/chromium/crInput.js +2 -2
- package/lib/server/chromium/crNetworkManager.js +10 -11
- package/lib/server/chromium/crPage.js +48 -7
- package/lib/server/chromium/crServiceWorker.js +2 -3
- package/lib/server/console.js +1 -3
- package/lib/server/debugController.js +0 -3
- package/lib/server/deviceDescriptorsSource.json +50 -50
- package/lib/server/dispatchers/browserContextDispatcher.js +7 -6
- package/lib/server/dispatchers/dispatcher.js +19 -20
- package/lib/server/dispatchers/electronDispatcher.js +13 -0
- package/lib/server/dispatchers/frameDispatcher.js +0 -6
- package/lib/server/dispatchers/localUtilsDispatcher.js +4 -4
- package/lib/server/dispatchers/pageDispatcher.js +14 -10
- package/lib/server/dispatchers/playwrightDispatcher.js +5 -5
- package/lib/server/dispatchers/writableStreamDispatcher.js +2 -2
- package/lib/server/dom.js +133 -170
- package/lib/server/electron/electron.js +40 -14
- package/lib/server/electron/loader.js +4 -2
- package/lib/server/fetch.js +4 -4
- package/lib/server/firefox/ffAccessibility.js +2 -1
- package/lib/server/firefox/ffBrowser.js +3 -3
- package/lib/server/firefox/ffConnection.js +1 -1
- package/lib/server/firefox/ffExecutionContext.js +2 -2
- package/lib/server/firefox/ffNetworkManager.js +7 -7
- package/lib/server/firefox/ffPage.js +3 -5
- package/lib/server/firefox/firefox.js +2 -2
- package/lib/server/frames.js +42 -23
- package/lib/server/har/harTracer.js +6 -6
- package/lib/server/helper.js +1 -1
- package/lib/server/input.js +2 -2
- package/lib/server/isomorphic/utilityScriptSerializers.js +0 -1
- package/lib/server/javascript.js +2 -2
- package/lib/server/page.js +51 -7
- package/lib/server/pipeTransport.js +1 -1
- package/lib/server/playwright.js +1 -1
- package/lib/server/progress.js +5 -14
- package/lib/server/recorder/csharp.js +1 -1
- package/lib/server/recorder/recorderUtils.js +2 -2
- package/lib/server/recorder.js +14 -14
- package/lib/server/registry/browserFetcher.js +1 -2
- package/lib/server/registry/dependencies.js +7 -6
- package/lib/server/registry/index.js +50 -33
- package/lib/server/registry/nativeDeps.js +0 -94
- package/lib/server/registry/oopDownloadBrowserMain.js +2 -2
- package/lib/server/screenshotter.js +0 -1
- package/lib/server/socksInterceptor.js +2 -2
- package/lib/server/trace/recorder/snapshotter.js +2 -2
- package/lib/server/trace/recorder/tracing.js +12 -11
- package/lib/server/trace/test/inMemorySnapshotter.js +1 -1
- package/lib/server/trace/viewer/traceViewer.js +2 -2
- package/lib/server/transport.js +15 -13
- package/lib/server/webkit/wkBrowser.js +3 -3
- package/lib/server/webkit/wkConnection.js +1 -1
- package/lib/server/webkit/wkExecutionContext.js +2 -2
- package/lib/server/webkit/wkInput.js +2 -2
- package/lib/server/webkit/wkInterceptableRequest.js +2 -2
- package/lib/server/webkit/wkPage.js +10 -12
- package/lib/utils/comparators.js +4 -4
- package/lib/utils/fileUtils.js +4 -0
- package/lib/utils/happy-eyeballs.js +5 -4
- package/lib/utils/hostPlatform.js +1 -1
- package/lib/utils/index.js +11 -0
- package/lib/utils/isomorphic/cssParser.js +2 -2
- package/lib/utils/isomorphic/locatorParser.js +6 -4
- package/lib/utils/isomorphic/selectorParser.js +0 -1
- package/lib/utils/network.js +33 -0
- package/lib/utils/processLauncher.js +9 -2
- package/lib/utils/profiler.js +2 -2
- package/lib/utils/zipFile.js +1 -1
- package/lib/vite/htmlReport/index.html +12 -13
- 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/{index-64ce22d5.css → index-ljsTwXtJ.css} +1 -1
- package/lib/vite/recorder/assets/index-yg8ypzl6.js +47 -0
- package/lib/vite/recorder/index.html +2 -3
- package/lib/vite/traceViewer/assets/codeMirrorModule-A2_PGeGB.js +24 -0
- package/lib/vite/{recorder/assets/codeMirrorModule-85487eb6.js → traceViewer/assets/codeMirrorModule-aUzO-LID.js} +1 -1
- package/lib/vite/traceViewer/assets/wsPort-L8WBvZfK.js +69 -0
- package/lib/vite/traceViewer/assets/wsPort-uVqol1LI.js +69 -0
- package/lib/vite/traceViewer/index.4xhUWj1f.js +2 -0
- package/lib/vite/traceViewer/index.html +4 -5
- package/lib/vite/traceViewer/index.o6j3Cv4u.js +2 -0
- package/lib/vite/traceViewer/sw.bundle.js +4 -4
- package/lib/vite/traceViewer/uiMode.PlLkrJDI.js +10 -0
- package/lib/vite/traceViewer/uiMode.html +4 -5
- package/lib/vite/traceViewer/uiMode.qpn6w4df.js +10 -0
- package/lib/vite/traceViewer/wsPort.zR1WIy9-.css +1 -0
- package/package.json +1 -1
- package/lib/vite/recorder/assets/codeMirrorModule-5d0f417c.css +0 -1
- package/lib/vite/recorder/assets/index-b14c63fe.js +0 -41
- /package/lib/vite/recorder/assets/{codicon-79f233d0.ttf → codicon-zGuYmc9o.ttf} +0 -0
package/lib/outofprocess.js
CHANGED
|
@@ -9,8 +9,8 @@ var _transport = require("./protocol/transport");
|
|
|
9
9
|
var childProcess = _interopRequireWildcard(require("child_process"));
|
|
10
10
|
var path = _interopRequireWildcard(require("path"));
|
|
11
11
|
var _manualPromise = require("./utils/manualPromise");
|
|
12
|
-
function _getRequireWildcardCache(
|
|
13
|
-
function _interopRequireWildcard(
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
14
|
/**
|
|
15
15
|
* Copyright (c) Microsoft Corporation.
|
|
16
16
|
*
|
|
@@ -41,7 +41,7 @@ class PlaywrightClient {
|
|
|
41
41
|
this._playwright = void 0;
|
|
42
42
|
this._driverProcess = void 0;
|
|
43
43
|
this._closePromise = new _manualPromise.ManualPromise();
|
|
44
|
-
this._driverProcess = childProcess.fork(path.join(__dirname, '
|
|
44
|
+
this._driverProcess = childProcess.fork(path.join(__dirname, '..', 'cli.js'), ['run-driver'], {
|
|
45
45
|
stdio: 'pipe',
|
|
46
46
|
detached: true,
|
|
47
47
|
env: {
|
|
@@ -429,13 +429,6 @@ _validatorPrimitives.scheme.DebugControllerSourceChangedEvent = (0, _validatorPr
|
|
|
429
429
|
_validatorPrimitives.scheme.DebugControllerPausedEvent = (0, _validatorPrimitives.tObject)({
|
|
430
430
|
paused: _validatorPrimitives.tBoolean
|
|
431
431
|
});
|
|
432
|
-
_validatorPrimitives.scheme.DebugControllerBrowsersChangedEvent = (0, _validatorPrimitives.tObject)({
|
|
433
|
-
browsers: (0, _validatorPrimitives.tArray)((0, _validatorPrimitives.tObject)({
|
|
434
|
-
contexts: (0, _validatorPrimitives.tArray)((0, _validatorPrimitives.tObject)({
|
|
435
|
-
pages: (0, _validatorPrimitives.tArray)(_validatorPrimitives.tString)
|
|
436
|
-
}))
|
|
437
|
-
}))
|
|
438
|
-
});
|
|
439
432
|
_validatorPrimitives.scheme.DebugControllerInitializeParams = (0, _validatorPrimitives.tObject)({
|
|
440
433
|
codegenId: _validatorPrimitives.tString,
|
|
441
434
|
sdkLanguage: (0, _validatorPrimitives.tEnum)(['javascript', 'python', 'java', 'csharp'])
|
|
@@ -819,7 +812,6 @@ _validatorPrimitives.scheme.BrowserContextBindingCallEvent = (0, _validatorPrimi
|
|
|
819
812
|
binding: (0, _validatorPrimitives.tChannel)(['BindingCall'])
|
|
820
813
|
});
|
|
821
814
|
_validatorPrimitives.scheme.BrowserContextConsoleEvent = (0, _validatorPrimitives.tObject)({
|
|
822
|
-
page: (0, _validatorPrimitives.tChannel)(['Page']),
|
|
823
815
|
type: _validatorPrimitives.tString,
|
|
824
816
|
text: _validatorPrimitives.tString,
|
|
825
817
|
args: (0, _validatorPrimitives.tArray)((0, _validatorPrimitives.tChannel)(['ElementHandle', 'JSHandle'])),
|
|
@@ -827,7 +819,8 @@ _validatorPrimitives.scheme.BrowserContextConsoleEvent = (0, _validatorPrimitive
|
|
|
827
819
|
url: _validatorPrimitives.tString,
|
|
828
820
|
lineNumber: _validatorPrimitives.tNumber,
|
|
829
821
|
columnNumber: _validatorPrimitives.tNumber
|
|
830
|
-
})
|
|
822
|
+
}),
|
|
823
|
+
page: (0, _validatorPrimitives.tChannel)(['Page'])
|
|
831
824
|
});
|
|
832
825
|
_validatorPrimitives.scheme.BrowserContextCloseEvent = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
|
|
833
826
|
_validatorPrimitives.scheme.BrowserContextDialogEvent = (0, _validatorPrimitives.tObject)({
|
|
@@ -1030,6 +1023,9 @@ _validatorPrimitives.scheme.PageFrameAttachedEvent = (0, _validatorPrimitives.tO
|
|
|
1030
1023
|
_validatorPrimitives.scheme.PageFrameDetachedEvent = (0, _validatorPrimitives.tObject)({
|
|
1031
1024
|
frame: (0, _validatorPrimitives.tChannel)(['Frame'])
|
|
1032
1025
|
});
|
|
1026
|
+
_validatorPrimitives.scheme.PageLocatorHandlerTriggeredEvent = (0, _validatorPrimitives.tObject)({
|
|
1027
|
+
uid: _validatorPrimitives.tNumber
|
|
1028
|
+
});
|
|
1033
1029
|
_validatorPrimitives.scheme.PageRouteEvent = (0, _validatorPrimitives.tObject)({
|
|
1034
1030
|
route: (0, _validatorPrimitives.tChannel)(['Route'])
|
|
1035
1031
|
});
|
|
@@ -1085,6 +1081,16 @@ _validatorPrimitives.scheme.PageGoForwardParams = (0, _validatorPrimitives.tObje
|
|
|
1085
1081
|
_validatorPrimitives.scheme.PageGoForwardResult = (0, _validatorPrimitives.tObject)({
|
|
1086
1082
|
response: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tChannel)(['Response']))
|
|
1087
1083
|
});
|
|
1084
|
+
_validatorPrimitives.scheme.PageRegisterLocatorHandlerParams = (0, _validatorPrimitives.tObject)({
|
|
1085
|
+
selector: _validatorPrimitives.tString
|
|
1086
|
+
});
|
|
1087
|
+
_validatorPrimitives.scheme.PageRegisterLocatorHandlerResult = (0, _validatorPrimitives.tObject)({
|
|
1088
|
+
uid: _validatorPrimitives.tNumber
|
|
1089
|
+
});
|
|
1090
|
+
_validatorPrimitives.scheme.PageResolveLocatorHandlerNoReplyParams = (0, _validatorPrimitives.tObject)({
|
|
1091
|
+
uid: _validatorPrimitives.tNumber
|
|
1092
|
+
});
|
|
1093
|
+
_validatorPrimitives.scheme.PageResolveLocatorHandlerNoReplyResult = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
|
|
1088
1094
|
_validatorPrimitives.scheme.PageReloadParams = (0, _validatorPrimitives.tObject)({
|
|
1089
1095
|
timeout: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tNumber),
|
|
1090
1096
|
waitUntil: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tType)('LifecycleEvent'))
|
|
@@ -1100,26 +1106,22 @@ _validatorPrimitives.scheme.PageExpectScreenshotParams = (0, _validatorPrimitive
|
|
|
1100
1106
|
frame: (0, _validatorPrimitives.tChannel)(['Frame']),
|
|
1101
1107
|
selector: _validatorPrimitives.tString
|
|
1102
1108
|
})),
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
}))),
|
|
1120
|
-
maskColor: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tString),
|
|
1121
|
-
style: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tString)
|
|
1122
|
-
}))
|
|
1109
|
+
comparator: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tString),
|
|
1110
|
+
maxDiffPixels: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tNumber),
|
|
1111
|
+
maxDiffPixelRatio: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tNumber),
|
|
1112
|
+
threshold: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tNumber),
|
|
1113
|
+
fullPage: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tBoolean),
|
|
1114
|
+
clip: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tType)('Rect')),
|
|
1115
|
+
omitBackground: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tBoolean),
|
|
1116
|
+
caret: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tEnum)(['hide', 'initial'])),
|
|
1117
|
+
animations: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tEnum)(['disabled', 'allow'])),
|
|
1118
|
+
scale: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tEnum)(['css', 'device'])),
|
|
1119
|
+
mask: (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tArray)((0, _validatorPrimitives.tObject)({
|
|
1120
|
+
frame: (0, _validatorPrimitives.tChannel)(['Frame']),
|
|
1121
|
+
selector: _validatorPrimitives.tString
|
|
1122
|
+
}))),
|
|
1123
|
+
maskColor: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tString),
|
|
1124
|
+
style: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tString)
|
|
1123
1125
|
});
|
|
1124
1126
|
_validatorPrimitives.scheme.PageExpectScreenshotResult = (0, _validatorPrimitives.tObject)({
|
|
1125
1127
|
diff: (0, _validatorPrimitives.tOptional)(_validatorPrimitives.tBinary),
|
|
@@ -2299,6 +2301,16 @@ _validatorPrimitives.scheme.ElectronApplicationInitializer = (0, _validatorPrimi
|
|
|
2299
2301
|
context: (0, _validatorPrimitives.tChannel)(['BrowserContext'])
|
|
2300
2302
|
});
|
|
2301
2303
|
_validatorPrimitives.scheme.ElectronApplicationCloseEvent = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
|
|
2304
|
+
_validatorPrimitives.scheme.ElectronApplicationConsoleEvent = (0, _validatorPrimitives.tObject)({
|
|
2305
|
+
type: _validatorPrimitives.tString,
|
|
2306
|
+
text: _validatorPrimitives.tString,
|
|
2307
|
+
args: (0, _validatorPrimitives.tArray)((0, _validatorPrimitives.tChannel)(['ElementHandle', 'JSHandle'])),
|
|
2308
|
+
location: (0, _validatorPrimitives.tObject)({
|
|
2309
|
+
url: _validatorPrimitives.tString,
|
|
2310
|
+
lineNumber: _validatorPrimitives.tNumber,
|
|
2311
|
+
columnNumber: _validatorPrimitives.tNumber
|
|
2312
|
+
})
|
|
2313
|
+
});
|
|
2302
2314
|
_validatorPrimitives.scheme.ElectronApplicationBrowserWindowParams = (0, _validatorPrimitives.tObject)({
|
|
2303
2315
|
page: (0, _validatorPrimitives.tChannel)(['Page'])
|
|
2304
2316
|
});
|
|
@@ -2321,6 +2333,11 @@ _validatorPrimitives.scheme.ElectronApplicationEvaluateExpressionHandleParams =
|
|
|
2321
2333
|
_validatorPrimitives.scheme.ElectronApplicationEvaluateExpressionHandleResult = (0, _validatorPrimitives.tObject)({
|
|
2322
2334
|
handle: (0, _validatorPrimitives.tChannel)(['ElementHandle', 'JSHandle'])
|
|
2323
2335
|
});
|
|
2336
|
+
_validatorPrimitives.scheme.ElectronApplicationUpdateSubscriptionParams = (0, _validatorPrimitives.tObject)({
|
|
2337
|
+
event: (0, _validatorPrimitives.tEnum)(['console']),
|
|
2338
|
+
enabled: _validatorPrimitives.tBoolean
|
|
2339
|
+
});
|
|
2340
|
+
_validatorPrimitives.scheme.ElectronApplicationUpdateSubscriptionResult = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
|
|
2324
2341
|
_validatorPrimitives.scheme.ElectronApplicationCloseParams = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
|
|
2325
2342
|
_validatorPrimitives.scheme.ElectronApplicationCloseResult = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
|
|
2326
2343
|
_validatorPrimitives.scheme.AndroidInitializer = (0, _validatorPrimitives.tOptional)((0, _validatorPrimitives.tObject)({}));
|
|
@@ -11,7 +11,7 @@ var _socksProxy = require("../common/socksProxy");
|
|
|
11
11
|
var _utils = require("../utils");
|
|
12
12
|
var _android = require("../server/android/android");
|
|
13
13
|
var _debugControllerDispatcher = require("../server/dispatchers/debugControllerDispatcher");
|
|
14
|
-
var _debugLogger = require("../
|
|
14
|
+
var _debugLogger = require("../utils/debugLogger");
|
|
15
15
|
/**
|
|
16
16
|
* Copyright (c) Microsoft Corporation.
|
|
17
17
|
*
|
|
@@ -109,7 +109,7 @@ class PlaywrightConnection {
|
|
|
109
109
|
const playwright = this._preLaunched.playwright;
|
|
110
110
|
|
|
111
111
|
// Note: connected client owns the socks proxy and configures the pattern.
|
|
112
|
-
(_this$_preLaunched$so = this._preLaunched.socksProxy) === null || _this$_preLaunched$so === void 0
|
|
112
|
+
(_this$_preLaunched$so = this._preLaunched.socksProxy) === null || _this$_preLaunched$so === void 0 || _this$_preLaunched$so.setPattern(this._options.socksProxyPattern);
|
|
113
113
|
const browser = this._preLaunched.browser;
|
|
114
114
|
browser.on(_browser.Browser.Events.Disconnected, () => {
|
|
115
115
|
// Underlying browser did close for some reason - force disconnect the client.
|
|
@@ -3,14 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var _utilsBundle = require("../utilsBundle");
|
|
6
|
+
exports.PlaywrightServer = void 0;
|
|
8
7
|
var _playwright = require("../server/playwright");
|
|
9
8
|
var _playwrightConnection = require("./playwrightConnection");
|
|
10
|
-
var
|
|
11
|
-
var _debugLogger = require("../
|
|
9
|
+
var _semaphore = require("../utils/semaphore");
|
|
10
|
+
var _debugLogger = require("../utils/debugLogger");
|
|
12
11
|
var _utils = require("../utils");
|
|
13
|
-
var
|
|
12
|
+
var _wsServer = require("../utils/wsServer");
|
|
14
13
|
/**
|
|
15
14
|
* Copyright (c) Microsoft Corporation.
|
|
16
15
|
*
|
|
@@ -27,178 +26,85 @@ var _transport = require("../server/transport");
|
|
|
27
26
|
* limitations under the License.
|
|
28
27
|
*/
|
|
29
28
|
|
|
30
|
-
let lastConnectionId = 0;
|
|
31
|
-
const kConnectionSymbol = Symbol('kConnection');
|
|
32
29
|
class PlaywrightServer {
|
|
33
30
|
constructor(options) {
|
|
34
31
|
this._preLaunchedPlaywright = void 0;
|
|
35
|
-
this._wsServer = void 0;
|
|
36
|
-
this._server = void 0;
|
|
37
32
|
this._options = void 0;
|
|
33
|
+
this._wsServer = void 0;
|
|
38
34
|
this._options = options;
|
|
39
35
|
if (options.preLaunchedBrowser) this._preLaunchedPlaywright = options.preLaunchedBrowser.attribution.playwright;
|
|
40
36
|
if (options.preLaunchedAndroidDevice) this._preLaunchedPlaywright = options.preLaunchedAndroidDevice._android.attribution.playwright;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
});
|
|
67
|
-
_debugLogger.debugLogger.log('server', 'Listening at ' + wsEndpoint);
|
|
68
|
-
this._wsServer = new _utilsBundle.wsServer({
|
|
69
|
-
noServer: true,
|
|
70
|
-
perMessageDeflate: _transport.perMessageDeflate
|
|
71
|
-
});
|
|
72
|
-
const browserSemaphore = new Semaphore(this._options.maxConnections);
|
|
73
|
-
const controllerSemaphore = new Semaphore(1);
|
|
74
|
-
const reuseBrowserSemaphore = new Semaphore(1);
|
|
75
|
-
if (process.env.PWTEST_SERVER_WS_HEADERS) {
|
|
76
|
-
this._wsServer.on('headers', (headers, request) => {
|
|
77
|
-
headers.push(process.env.PWTEST_SERVER_WS_HEADERS);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
server.on('upgrade', (request, socket, head) => {
|
|
81
|
-
var _this$_wsServer;
|
|
82
|
-
const pathname = new URL('http://localhost' + request.url).pathname;
|
|
83
|
-
if (pathname !== this._options.path) {
|
|
84
|
-
socket.write(`HTTP/${request.httpVersion} 400 Bad Request\r\n\r\n`);
|
|
85
|
-
socket.destroy();
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const uaError = (0, _utils.userAgentVersionMatchesErrorMessage)(request.headers['user-agent'] || '');
|
|
89
|
-
if (uaError) {
|
|
90
|
-
socket.write(`HTTP/${request.httpVersion} 428 Precondition Required\r\n\r\n${uaError}`);
|
|
91
|
-
socket.destroy();
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
(_this$_wsServer = this._wsServer) === null || _this$_wsServer === void 0 ? void 0 : _this$_wsServer.handleUpgrade(request, socket, head, ws => {
|
|
95
|
-
var _this$_wsServer2;
|
|
96
|
-
return (_this$_wsServer2 = this._wsServer) === null || _this$_wsServer2 === void 0 ? void 0 : _this$_wsServer2.emit('connection', ws, request);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
this._wsServer.on('connection', (ws, request) => {
|
|
100
|
-
_debugLogger.debugLogger.log('server', 'Connected client ws.extension=' + ws.extensions);
|
|
101
|
-
const url = new URL('http://localhost' + (request.url || ''));
|
|
102
|
-
const browserHeader = request.headers['x-playwright-browser'];
|
|
103
|
-
const browserName = url.searchParams.get('browser') || (Array.isArray(browserHeader) ? browserHeader[0] : browserHeader) || null;
|
|
104
|
-
const proxyHeader = request.headers['x-playwright-proxy'];
|
|
105
|
-
const proxyValue = url.searchParams.get('proxy') || (Array.isArray(proxyHeader) ? proxyHeader[0] : proxyHeader);
|
|
106
|
-
const launchOptionsHeader = request.headers['x-playwright-launch-options'] || '';
|
|
107
|
-
const launchOptionsHeaderValue = Array.isArray(launchOptionsHeader) ? launchOptionsHeader[0] : launchOptionsHeader;
|
|
108
|
-
const launchOptionsParam = url.searchParams.get('launch-options');
|
|
109
|
-
let launchOptions = {};
|
|
110
|
-
try {
|
|
111
|
-
launchOptions = JSON.parse(launchOptionsParam || launchOptionsHeaderValue);
|
|
112
|
-
} catch (e) {}
|
|
113
|
-
const id = String(++lastConnectionId);
|
|
114
|
-
_debugLogger.debugLogger.log('server', `[${id}] serving connection: ${request.url}`);
|
|
37
|
+
const browserSemaphore = new _semaphore.Semaphore(this._options.maxConnections);
|
|
38
|
+
const controllerSemaphore = new _semaphore.Semaphore(1);
|
|
39
|
+
const reuseBrowserSemaphore = new _semaphore.Semaphore(1);
|
|
40
|
+
this._wsServer = new _wsServer.WSServer({
|
|
41
|
+
onUpgrade: (request, socket) => {
|
|
42
|
+
const uaError = (0, _utils.userAgentVersionMatchesErrorMessage)(request.headers['user-agent'] || '');
|
|
43
|
+
if (uaError) return {
|
|
44
|
+
error: `HTTP/${request.httpVersion} 428 Precondition Required\r\n\r\n${uaError}`
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
onHeaders: headers => {
|
|
48
|
+
if (process.env.PWTEST_SERVER_WS_HEADERS) headers.push(process.env.PWTEST_SERVER_WS_HEADERS);
|
|
49
|
+
},
|
|
50
|
+
onConnection: (request, url, ws, id) => {
|
|
51
|
+
const browserHeader = request.headers['x-playwright-browser'];
|
|
52
|
+
const browserName = url.searchParams.get('browser') || (Array.isArray(browserHeader) ? browserHeader[0] : browserHeader) || null;
|
|
53
|
+
const proxyHeader = request.headers['x-playwright-proxy'];
|
|
54
|
+
const proxyValue = url.searchParams.get('proxy') || (Array.isArray(proxyHeader) ? proxyHeader[0] : proxyHeader);
|
|
55
|
+
const launchOptionsHeader = request.headers['x-playwright-launch-options'] || '';
|
|
56
|
+
const launchOptionsHeaderValue = Array.isArray(launchOptionsHeader) ? launchOptionsHeader[0] : launchOptionsHeader;
|
|
57
|
+
const launchOptionsParam = url.searchParams.get('launch-options');
|
|
58
|
+
let launchOptions = {};
|
|
59
|
+
try {
|
|
60
|
+
launchOptions = JSON.parse(launchOptionsParam || launchOptionsHeaderValue);
|
|
61
|
+
} catch (e) {}
|
|
115
62
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
63
|
+
// Instantiate playwright for the extension modes.
|
|
64
|
+
const isExtension = this._options.mode === 'extension';
|
|
65
|
+
if (isExtension) {
|
|
66
|
+
if (!this._preLaunchedPlaywright) this._preLaunchedPlaywright = (0, _playwright.createPlaywright)({
|
|
67
|
+
sdkLanguage: 'javascript',
|
|
68
|
+
isServer: true
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
let clientType = 'launch-browser';
|
|
72
|
+
let semaphore = browserSemaphore;
|
|
73
|
+
if (isExtension && url.searchParams.has('debug-controller')) {
|
|
74
|
+
clientType = 'controller';
|
|
75
|
+
semaphore = controllerSemaphore;
|
|
76
|
+
} else if (isExtension) {
|
|
77
|
+
clientType = 'reuse-browser';
|
|
78
|
+
semaphore = reuseBrowserSemaphore;
|
|
79
|
+
} else if (this._options.mode === 'launchServer') {
|
|
80
|
+
clientType = 'pre-launched-browser-or-android';
|
|
81
|
+
semaphore = browserSemaphore;
|
|
82
|
+
}
|
|
83
|
+
return new _playwrightConnection.PlaywrightConnection(semaphore.acquire(), clientType, ws, {
|
|
84
|
+
socksProxyPattern: proxyValue,
|
|
85
|
+
browserName,
|
|
86
|
+
launchOptions
|
|
87
|
+
}, {
|
|
88
|
+
playwright: this._preLaunchedPlaywright,
|
|
89
|
+
browser: this._options.preLaunchedBrowser,
|
|
90
|
+
androidDevice: this._options.preLaunchedAndroidDevice,
|
|
91
|
+
socksProxy: this._options.preLaunchedSocksProxy
|
|
92
|
+
}, id, () => semaphore.release());
|
|
93
|
+
},
|
|
94
|
+
onClose: async () => {
|
|
95
|
+
_debugLogger.debugLogger.log('server', 'closing browsers');
|
|
96
|
+
if (this._preLaunchedPlaywright) await Promise.all(this._preLaunchedPlaywright.allBrowsers().map(browser => browser.close({
|
|
97
|
+
reason: 'Playwright Server stopped'
|
|
98
|
+
})));
|
|
99
|
+
_debugLogger.debugLogger.log('server', 'closed browsers');
|
|
135
100
|
}
|
|
136
|
-
const connection = new _playwrightConnection.PlaywrightConnection(semaphore.acquire(), clientType, ws, {
|
|
137
|
-
socksProxyPattern: proxyValue,
|
|
138
|
-
browserName,
|
|
139
|
-
launchOptions
|
|
140
|
-
}, {
|
|
141
|
-
playwright: this._preLaunchedPlaywright,
|
|
142
|
-
browser: this._options.preLaunchedBrowser,
|
|
143
|
-
androidDevice: this._options.preLaunchedAndroidDevice,
|
|
144
|
-
socksProxy: this._options.preLaunchedSocksProxy
|
|
145
|
-
}, id, () => semaphore.release());
|
|
146
|
-
ws[kConnectionSymbol] = connection;
|
|
147
101
|
});
|
|
148
|
-
return wsEndpoint;
|
|
149
102
|
}
|
|
150
|
-
async
|
|
151
|
-
|
|
152
|
-
if (!server) return;
|
|
153
|
-
_debugLogger.debugLogger.log('server', 'closing websocket server');
|
|
154
|
-
const waitForClose = new Promise(f => server.close(f));
|
|
155
|
-
// First disconnect all remaining clients.
|
|
156
|
-
await Promise.all(Array.from(server.clients).map(async ws => {
|
|
157
|
-
const connection = ws[kConnectionSymbol];
|
|
158
|
-
if (connection) await connection.close();
|
|
159
|
-
try {
|
|
160
|
-
ws.terminate();
|
|
161
|
-
} catch (e) {}
|
|
162
|
-
}));
|
|
163
|
-
await waitForClose;
|
|
164
|
-
_debugLogger.debugLogger.log('server', 'closing http server');
|
|
165
|
-
if (this._server) await new Promise(f => this._server.close(f));
|
|
166
|
-
this._wsServer = undefined;
|
|
167
|
-
this._server = undefined;
|
|
168
|
-
_debugLogger.debugLogger.log('server', 'closed server');
|
|
169
|
-
_debugLogger.debugLogger.log('server', 'closing browsers');
|
|
170
|
-
if (this._preLaunchedPlaywright) await Promise.all(this._preLaunchedPlaywright.allBrowsers().map(browser => browser.close({
|
|
171
|
-
reason: 'Playwright Server stopped'
|
|
172
|
-
})));
|
|
173
|
-
_debugLogger.debugLogger.log('server', 'closed browsers');
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
exports.PlaywrightServer = PlaywrightServer;
|
|
177
|
-
class Semaphore {
|
|
178
|
-
constructor(max) {
|
|
179
|
-
this._max = void 0;
|
|
180
|
-
this._acquired = 0;
|
|
181
|
-
this._queue = [];
|
|
182
|
-
this._max = max;
|
|
183
|
-
}
|
|
184
|
-
setMax(max) {
|
|
185
|
-
this._max = max;
|
|
186
|
-
}
|
|
187
|
-
acquire() {
|
|
188
|
-
const lock = new _manualPromise.ManualPromise();
|
|
189
|
-
this._queue.push(lock);
|
|
190
|
-
this._flush();
|
|
191
|
-
return lock;
|
|
192
|
-
}
|
|
193
|
-
release() {
|
|
194
|
-
--this._acquired;
|
|
195
|
-
this._flush();
|
|
103
|
+
async listen(port = 0, hostname) {
|
|
104
|
+
return this._wsServer.listen(port, hostname, this._options.path);
|
|
196
105
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
++this._acquired;
|
|
200
|
-
this._queue.shift().resolve();
|
|
201
|
-
}
|
|
106
|
+
async close() {
|
|
107
|
+
await this._wsServer.close();
|
|
202
108
|
}
|
|
203
109
|
}
|
|
204
|
-
exports.
|
|
110
|
+
exports.PlaywrightServer = PlaywrightServer;
|
|
@@ -16,7 +16,7 @@ var _progress = require("../progress");
|
|
|
16
16
|
var _crBrowser = require("../chromium/crBrowser");
|
|
17
17
|
var _helper = require("../helper");
|
|
18
18
|
var _transport = require("../../protocol/transport");
|
|
19
|
-
var _debugLogger = require("../../
|
|
19
|
+
var _debugLogger = require("../../utils/debugLogger");
|
|
20
20
|
var _processLauncher = require("../../utils/processLauncher");
|
|
21
21
|
var _timeoutSettings = require("../../common/timeoutSettings");
|
|
22
22
|
var _instrumentation = require("../instrumentation");
|
|
@@ -204,7 +204,7 @@ class AndroidDevice extends _instrumentation.SdkObject {
|
|
|
204
204
|
for (const connection of this._browserConnections) await connection.close();
|
|
205
205
|
if (this._driverPromise) {
|
|
206
206
|
const driver = await this._driver();
|
|
207
|
-
driver === null || driver === void 0
|
|
207
|
+
driver === null || driver === void 0 || driver.close();
|
|
208
208
|
}
|
|
209
209
|
await this._backend.close();
|
|
210
210
|
this._android._deviceClosed(this);
|
|
@@ -8,8 +8,8 @@ var _utilsBundle = require("../../utilsBundle");
|
|
|
8
8
|
var net = _interopRequireWildcard(require("net"));
|
|
9
9
|
var _events = require("events");
|
|
10
10
|
var _utils = require("../../utils");
|
|
11
|
-
function _getRequireWildcardCache(
|
|
12
|
-
function _interopRequireWildcard(
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
13
|
/**
|
|
14
14
|
* Copyright Microsoft Corporation. All rights reserved.
|
|
15
15
|
*
|
package/lib/server/browser.js
CHANGED
|
@@ -68,8 +68,8 @@ class Browser extends _instrumentation.SdkObject {
|
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
70
|
async stopPendingOperations(reason) {
|
|
71
|
-
var _this$_contextForReus
|
|
72
|
-
await ((_this$_contextForReus = this._contextForReuse) === null || _this$_contextForReus === void 0
|
|
71
|
+
var _this$_contextForReus;
|
|
72
|
+
await ((_this$_contextForReus = this._contextForReuse) === null || _this$_contextForReus === void 0 || (_this$_contextForReus = _this$_contextForReus.context) === null || _this$_contextForReus === void 0 ? void 0 : _this$_contextForReus.stopPendingOperations(reason));
|
|
73
73
|
}
|
|
74
74
|
_downloadCreated(page, uuid, url, suggestedFilename) {
|
|
75
75
|
const download = new _download.Download(page, this.options.downloadsPath || '', uuid, url, suggestedFilename);
|
|
@@ -25,8 +25,8 @@ var _recorder = require("./recorder");
|
|
|
25
25
|
var consoleApiSource = _interopRequireWildcard(require("../generated/consoleApiSource"));
|
|
26
26
|
var _fetch = require("./fetch");
|
|
27
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
28
|
-
function _getRequireWildcardCache(
|
|
29
|
-
function _interopRequireWildcard(
|
|
28
|
+
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); }
|
|
29
|
+
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; }
|
|
30
30
|
/**
|
|
31
31
|
* Copyright 2017 Google Inc. All rights reserved.
|
|
32
32
|
* Modifications copyright (c) Microsoft Corporation.
|
|
@@ -158,13 +158,13 @@ class BrowserContext extends _instrumentation.SdkObject {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
// Unless dialogs are dismissed, setting extra http headers below does not respond.
|
|
161
|
-
(_page = page) === null || _page === void 0
|
|
161
|
+
(_page = page) === null || _page === void 0 || _page._frameManager.setCloseAllOpeningDialogs(true);
|
|
162
162
|
await ((_page2 = page) === null || _page2 === void 0 ? void 0 : _page2._frameManager.closeOpenDialogs());
|
|
163
163
|
// Navigate to about:blank first to ensure no page scripts are running after this point.
|
|
164
164
|
await ((_page3 = page) === null || _page3 === void 0 ? void 0 : _page3.mainFrame().goto(metadata, 'about:blank', {
|
|
165
165
|
timeout: 0
|
|
166
166
|
}));
|
|
167
|
-
(_page4 = page) === null || _page4 === void 0
|
|
167
|
+
(_page4 = page) === null || _page4 === void 0 || _page4._frameManager.setCloseAllOpeningDialogs(false);
|
|
168
168
|
await this._resetStorage();
|
|
169
169
|
await this._removeExposedBindings();
|
|
170
170
|
await this._removeInitScripts();
|
|
@@ -401,9 +401,9 @@ class BrowserContext extends _instrumentation.SdkObject {
|
|
|
401
401
|
return result;
|
|
402
402
|
}
|
|
403
403
|
async _resetStorage() {
|
|
404
|
-
var _this$_options$storag
|
|
404
|
+
var _this$_options$storag;
|
|
405
405
|
const oldOrigins = this._origins;
|
|
406
|
-
const newOrigins = new Map(((_this$_options$storag = this._options.storageState) === null || _this$_options$storag === void 0
|
|
406
|
+
const newOrigins = new Map(((_this$_options$storag = this._options.storageState) === null || _this$_options$storag === void 0 || (_this$_options$storag = _this$_options$storag.origins) === null || _this$_options$storag === void 0 ? void 0 : _this$_options$storag.map(p => [p.origin, p])) || []);
|
|
407
407
|
if (!oldOrigins.size && !newOrigins.size) return;
|
|
408
408
|
let page = this.pages()[0];
|
|
409
409
|
const internalMetadata = (0, _instrumentation.serverSideCallMetadata)();
|
|
@@ -429,11 +429,10 @@ class BrowserContext extends _instrumentation.SdkObject {
|
|
|
429
429
|
this._origins = new Set([...newOrigins.keys()]);
|
|
430
430
|
// It is safe to not restore the URL to about:blank since we are doing it in Page::resetForReuse.
|
|
431
431
|
}
|
|
432
|
-
|
|
433
432
|
async _resetCookies() {
|
|
434
|
-
var _this$_options$
|
|
433
|
+
var _this$_options$storag2, _this$_options$storag3;
|
|
435
434
|
await this.clearCookies();
|
|
436
|
-
if ((_this$_options$
|
|
435
|
+
if ((_this$_options$storag2 = this._options.storageState) !== null && _this$_options$storag2 !== void 0 && _this$_options$storag2.cookies) await this.addCookies((_this$_options$storag3 = this._options.storageState) === null || _this$_options$storag3 === void 0 ? void 0 : _this$_options$storag3.cookies);
|
|
437
436
|
}
|
|
438
437
|
isSettingStorageState() {
|
|
439
438
|
return this._settingStorageState;
|
|
@@ -17,12 +17,12 @@ var _timeoutSettings = require("../common/timeoutSettings");
|
|
|
17
17
|
var _utils = require("../utils");
|
|
18
18
|
var _fileUtils = require("../utils/fileUtils");
|
|
19
19
|
var _helper = require("./helper");
|
|
20
|
-
var _debugLogger = require("../
|
|
20
|
+
var _debugLogger = require("../utils/debugLogger");
|
|
21
21
|
var _instrumentation = require("./instrumentation");
|
|
22
22
|
var _manualPromise = require("../utils/manualPromise");
|
|
23
23
|
var _protocolError = require("./protocolError");
|
|
24
|
-
function _getRequireWildcardCache(
|
|
25
|
-
function _interopRequireWildcard(
|
|
24
|
+
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); }
|
|
25
|
+
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; }
|
|
26
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
27
|
/**
|
|
28
28
|
* Copyright (c) Microsoft Corporation.
|
|
@@ -164,7 +164,7 @@ class BrowserType extends _instrumentation.SdkObject {
|
|
|
164
164
|
const registryExecutable = _registry.registry.findExecutable(options.channel || this._name);
|
|
165
165
|
if (!registryExecutable || registryExecutable.browserName !== this._name) throw new Error(`Unsupported ${this._name} channel "${options.channel}"`);
|
|
166
166
|
executable = registryExecutable.executablePathOrDie(this.attribution.playwright.options.sdkLanguage);
|
|
167
|
-
await
|
|
167
|
+
await _registry.registry.validateHostRequirementsForExecutablesIfNeeded([registryExecutable], this.attribution.playwright.options.sdkLanguage);
|
|
168
168
|
}
|
|
169
169
|
const waitForWSEndpoint = options.useWebSocket || (_options$args = options.args) !== null && _options$args !== void 0 && _options$args.some(a => a.startsWith('--remote-debugging-port')) ? new _manualPromise.ManualPromise() : undefined;
|
|
170
170
|
const waitForJuggler = this._name === 'firefox' ? new _manualPromise.ManualPromise() : undefined;
|
|
@@ -203,7 +203,7 @@ class BrowserType extends _instrumentation.SdkObject {
|
|
|
203
203
|
},
|
|
204
204
|
onExit: (exitCode, signal) => {
|
|
205
205
|
// Unblock launch when browser prematurely exits.
|
|
206
|
-
waitForJuggler === null || waitForJuggler === void 0
|
|
206
|
+
waitForJuggler === null || waitForJuggler === void 0 || waitForJuggler.resolve();
|
|
207
207
|
if (browserProcess && browserProcess.onclose) browserProcess.onclose(exitCode, signal);
|
|
208
208
|
}
|
|
209
209
|
});
|
|
@@ -19,7 +19,7 @@ var _userAgent = require("../../utils/userAgent");
|
|
|
19
19
|
var _ascii = require("../../utils/ascii");
|
|
20
20
|
var _utils = require("../../utils");
|
|
21
21
|
var _fileUtils = require("../../utils/fileUtils");
|
|
22
|
-
var _debugLogger = require("../../
|
|
22
|
+
var _debugLogger = require("../../utils/debugLogger");
|
|
23
23
|
var _progress = require("../progress");
|
|
24
24
|
var _timeoutSettings = require("../../common/timeoutSettings");
|
|
25
25
|
var _helper = require("../helper");
|
|
@@ -68,7 +68,7 @@ class Chromium extends _browserType.BrowserType {
|
|
|
68
68
|
'User-Agent': (0, _userAgent.getUserAgent)()
|
|
69
69
|
};else if (headersMap && !Object.keys(headersMap).some(key => key.toLowerCase() === 'user-agent')) headersMap['User-Agent'] = (0, _userAgent.getUserAgent)();
|
|
70
70
|
const artifactsDir = await _fs.default.promises.mkdtemp(ARTIFACTS_FOLDER);
|
|
71
|
-
const wsEndpoint = await urlToWSEndpoint(progress, endpointURL);
|
|
71
|
+
const wsEndpoint = await urlToWSEndpoint(progress, endpointURL, headersMap);
|
|
72
72
|
progress.throwIfAborted();
|
|
73
73
|
const chromeTransport = await _transport.WebSocketTransport.connect(progress, wsEndpoint, headersMap);
|
|
74
74
|
const cleanedUp = new _manualPromise.ManualPromise();
|
|
@@ -305,12 +305,13 @@ class Chromium extends _browserType.BrowserType {
|
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
exports.Chromium = Chromium;
|
|
308
|
-
async function urlToWSEndpoint(progress, endpointURL) {
|
|
308
|
+
async function urlToWSEndpoint(progress, endpointURL, headers) {
|
|
309
309
|
if (endpointURL.startsWith('ws')) return endpointURL;
|
|
310
310
|
progress.log(`<ws preparing> retrieving websocket url from ${endpointURL}`);
|
|
311
311
|
const httpURL = endpointURL.endsWith('/') ? `${endpointURL}json/version/` : `${endpointURL}/json/version/`;
|
|
312
312
|
const json = await (0, _network.fetchData)({
|
|
313
|
-
url: httpURL
|
|
313
|
+
url: httpURL,
|
|
314
|
+
headers
|
|
314
315
|
}, async (_, resp) => new Error(`Unexpected status ${resp.statusCode} when connecting to ${httpURL}.\n` + `This does not look like a DevTools server, try connecting via ws://.`));
|
|
315
316
|
return JSON.parse(json).webSocketDebuggerUrl;
|
|
316
317
|
}
|