patchright-core 1.52.5 → 1.55.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/ThirdPartyNotices.txt +65 -123
- package/bin/reinstall_chrome_beta_mac.sh +1 -1
- package/bin/reinstall_chrome_stable_mac.sh +1 -1
- package/bin/reinstall_msedge_beta_mac.sh +1 -1
- package/bin/reinstall_msedge_dev_mac.sh +1 -1
- package/bin/reinstall_msedge_stable_mac.sh +1 -1
- package/browsers.json +14 -14
- package/index.js +1 -1
- package/lib/androidServerImpl.js +4 -2
- package/lib/browserServerImpl.js +47 -12
- package/lib/cli/program.js +116 -50
- package/lib/cli/programWithTestStub.js +1 -1
- package/lib/client/android.js +30 -34
- package/lib/client/browser.js +54 -17
- package/lib/client/browserContext.js +67 -71
- package/lib/client/browserType.js +25 -34
- package/lib/client/channelOwner.js +20 -24
- package/lib/client/connection.js +6 -10
- package/lib/client/electron.js +8 -3
- package/lib/client/elementHandle.js +18 -21
- package/lib/client/fetch.js +5 -3
- package/lib/client/frame.js +54 -32
- package/lib/client/input.js +3 -1
- package/lib/client/jsHandle.js +4 -0
- package/lib/client/localUtils.js +0 -1
- package/lib/client/locator.js +30 -26
- package/lib/client/network.js +5 -12
- package/lib/client/page.js +32 -32
- package/lib/client/playwright.js +6 -16
- package/lib/client/selectors.js +18 -38
- package/lib/client/timeoutSettings.js +12 -8
- package/lib/client/tracing.js +24 -20
- package/lib/client/waiter.js +2 -2
- package/lib/client/webSocket.js +4 -22
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +1 -1
- package/lib/generated/webSocketMockSource.js +12 -50
- package/lib/inProcessFactory.js +9 -6
- package/lib/outofprocess.js +0 -2
- package/lib/protocol/validator.js +421 -345
- package/lib/protocol/validatorPrimitives.js +18 -4
- package/lib/remote/playwrightConnection.js +29 -166
- package/lib/remote/playwrightServer.js +233 -35
- package/lib/server/android/android.js +97 -83
- package/lib/server/android/backendAdb.js +0 -2
- package/lib/server/bidi/bidiBrowser.js +139 -73
- package/lib/server/bidi/bidiChromium.js +23 -22
- package/lib/server/bidi/bidiExecutionContext.js +2 -1
- package/lib/server/bidi/bidiFirefox.js +17 -14
- package/lib/server/bidi/bidiInput.js +22 -22
- package/lib/server/bidi/bidiNetworkManager.js +8 -11
- package/lib/server/bidi/bidiPage.js +42 -86
- package/lib/server/bidi/third_party/bidiProtocol.js +5 -133
- package/lib/server/bidi/third_party/bidiProtocolCore.js +179 -0
- package/lib/server/{dispatchers/selectorsDispatcher.js → bidi/third_party/bidiProtocolPermissions.js} +20 -18
- package/lib/server/browser.js +30 -21
- package/lib/server/browserContext.js +203 -165
- package/lib/server/browserType.js +109 -107
- package/lib/server/chromium/chromium.js +84 -69
- package/lib/server/chromium/chromiumSwitches.js +13 -20
- package/lib/server/chromium/crBrowser.js +74 -40
- package/lib/server/chromium/crConnection.js +8 -9
- package/lib/server/chromium/crCoverage.js +11 -8
- package/lib/server/chromium/crDragDrop.js +25 -20
- package/lib/server/chromium/crExecutionContext.js +2 -1
- package/lib/server/chromium/crInput.js +32 -29
- package/lib/server/chromium/crNetworkManager.js +43 -31
- package/lib/server/chromium/crPage.js +98 -72
- package/lib/server/chromium/crServiceWorker.js +13 -18
- package/lib/server/chromium/videoRecorder.js +10 -18
- package/lib/server/clock.js +51 -39
- package/lib/server/codegen/csharp.js +10 -5
- package/lib/server/codegen/java.js +1 -1
- package/lib/server/codegen/javascript.js +1 -1
- package/lib/server/codegen/jsonl.js +2 -1
- package/lib/server/codegen/language.js +22 -1
- package/lib/server/codegen/languages.js +4 -4
- package/lib/server/codegen/python.js +1 -1
- package/lib/server/cookieStore.js +3 -1
- package/lib/server/debugController.js +105 -71
- package/lib/server/debugger.js +6 -23
- package/lib/server/deviceDescriptorsSource.json +237 -127
- package/lib/server/dialog.js +50 -6
- package/lib/server/dispatchers/androidDispatcher.js +77 -62
- package/lib/server/dispatchers/artifactDispatcher.js +18 -18
- package/lib/server/dispatchers/browserContextDispatcher.js +141 -91
- package/lib/server/dispatchers/browserDispatcher.js +55 -88
- package/lib/server/dispatchers/browserTypeDispatcher.js +18 -9
- package/lib/server/dispatchers/cdpSessionDispatcher.js +4 -4
- package/lib/server/dispatchers/debugControllerDispatcher.js +12 -21
- package/lib/server/dispatchers/dialogDispatcher.js +4 -4
- package/lib/server/dispatchers/dispatcher.js +78 -53
- package/lib/server/dispatchers/electronDispatcher.js +19 -20
- package/lib/server/dispatchers/elementHandlerDispatcher.js +83 -93
- package/lib/server/dispatchers/frameDispatcher.js +98 -101
- package/lib/server/dispatchers/jsHandleDispatcher.js +21 -16
- package/lib/server/dispatchers/jsonPipeDispatcher.js +4 -4
- package/lib/server/dispatchers/localUtilsDispatcher.js +53 -59
- package/lib/server/dispatchers/networkDispatchers.js +41 -35
- package/lib/server/dispatchers/pageDispatcher.js +156 -107
- package/lib/server/dispatchers/playwrightDispatcher.js +37 -25
- package/lib/server/dispatchers/streamDispatcher.js +15 -8
- package/lib/server/dispatchers/tracingDispatcher.js +22 -13
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +46 -35
- package/lib/server/dispatchers/writableStreamDispatcher.js +16 -10
- package/lib/server/dom.js +198 -266
- package/lib/server/download.js +3 -3
- package/lib/server/electron/electron.js +96 -103
- package/lib/server/electron/loader.js +1 -1
- package/lib/server/fetch.js +22 -41
- package/lib/server/fileUploadUtils.js +1 -1
- package/lib/server/firefox/ffBrowser.js +79 -55
- package/lib/server/firefox/ffExecutionContext.js +2 -1
- package/lib/server/firefox/ffInput.js +23 -23
- package/lib/server/firefox/ffNetworkManager.js +8 -6
- package/lib/server/firefox/ffPage.js +39 -36
- package/lib/server/firefox/firefox.js +9 -10
- package/lib/server/frameSelectors.js +63 -20
- package/lib/server/frames.js +495 -555
- package/lib/server/har/harRecorder.js +1 -1
- package/lib/server/har/harTracer.js +4 -2
- package/lib/server/helper.js +3 -7
- package/lib/server/index.js +0 -3
- package/lib/server/input.js +47 -54
- package/lib/server/instrumentation.js +8 -14
- package/lib/server/javascript.js +8 -16
- package/lib/server/launchApp.js +48 -30
- package/lib/server/localUtils.js +45 -38
- package/lib/server/network.js +44 -10
- package/lib/server/page.js +232 -177
- package/lib/server/pageBinding.js +6 -7
- package/lib/server/playwright.js +4 -14
- package/lib/server/progress.js +57 -49
- package/lib/server/recorder/recorderApp.js +298 -95
- package/lib/server/recorder/recorderRunner.js +23 -24
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +67 -10
- package/lib/server/recorder.js +284 -146
- package/lib/server/registry/index.js +83 -48
- package/lib/server/registry/nativeDeps.js +175 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +1 -1
- package/lib/server/screenshotter.js +84 -83
- package/lib/server/selectors.js +12 -12
- package/lib/server/socksClientCertificatesInterceptor.js +198 -136
- package/lib/server/trace/recorder/snapshotter.js +12 -19
- package/lib/server/trace/recorder/tracing.js +36 -27
- package/lib/server/trace/viewer/traceViewer.js +11 -20
- package/lib/server/transport.js +20 -22
- package/lib/server/utils/comparators.js +2 -2
- package/lib/server/utils/debug.js +3 -8
- package/lib/server/utils/debugLogger.js +8 -0
- package/lib/server/utils/hostPlatform.js +3 -1
- package/lib/server/utils/network.js +35 -25
- package/lib/server/utils/nodePlatform.js +1 -1
- package/lib/server/utils/processLauncher.js +4 -1
- package/lib/server/utils/wsServer.js +11 -17
- package/lib/server/webkit/webkit.js +5 -2
- package/lib/server/webkit/wkBrowser.js +51 -28
- package/lib/server/webkit/wkExecutionContext.js +2 -1
- package/lib/server/webkit/wkInput.js +25 -25
- package/lib/server/webkit/wkInterceptableRequest.js +1 -1
- package/lib/server/webkit/wkPage.js +80 -59
- package/lib/server/webkit/wkProvisionalPage.js +1 -1
- package/lib/server/webkit/wkWorkers.js +7 -7
- package/lib/utils/isomorphic/ariaSnapshot.js +13 -7
- package/lib/utils/isomorphic/cssParser.js +1 -2
- package/lib/utils/isomorphic/locatorGenerators.js +18 -0
- package/lib/utils/isomorphic/manualPromise.js +1 -2
- package/lib/utils/isomorphic/mimeType.js +1 -2
- package/lib/utils/isomorphic/multimap.js +1 -2
- package/lib/utils/isomorphic/oldUtilityScriptSerializers.js +248 -0
- package/lib/utils/isomorphic/protocolFormatter.js +78 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +318 -0
- package/lib/utils/isomorphic/selectorParser.js +3 -4
- package/lib/utils/isomorphic/stringUtils.js +3 -24
- package/lib/utils/isomorphic/time.js +9 -4
- package/lib/utils/isomorphic/timeoutRunner.js +3 -4
- package/lib/utils/isomorphic/traceUtils.js +2 -3
- package/lib/utils/isomorphic/urlMatch.js +21 -7
- package/lib/utils/isomorphic/utilityScriptSerializers.js +208 -205
- package/lib/utils.js +8 -2
- package/lib/utilsBundleImpl/index.js +160 -150
- package/lib/vite/htmlReport/index.html +17 -17
- package/lib/vite/recorder/assets/{codeMirrorModule-CXVeovup.js → codeMirrorModule-DzQ0k89p.js} +1 -1
- package/lib/vite/recorder/assets/{index-eHBmevrY.css → index-CI4HQ-Zb.css} +1 -1
- package/lib/vite/recorder/assets/index-D7C7daHH.js +184 -0
- package/lib/vite/recorder/index.html +3 -3
- package/lib/vite/traceViewer/assets/{codeMirrorModule-_GLjJL-7.js → codeMirrorModule-Di48jgWx.js} +1 -1
- package/lib/vite/traceViewer/assets/defaultSettingsView-szBn8781.js +256 -0
- package/lib/vite/traceViewer/defaultSettingsView.DVJHpiGt.css +1 -0
- package/lib/vite/traceViewer/index.BFsek2M6.css +1 -0
- package/lib/vite/traceViewer/index.DQvXoPLL.js +2 -0
- package/lib/vite/traceViewer/index.html +6 -6
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/uiMode.dBV3oN9h.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +4 -4
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +1 -1
- package/types/protocol.d.ts +712 -107
- package/types/types.d.ts +128 -17
- package/lib/generated/consoleApiSource.js +0 -28
- package/lib/protocol/debug.js +0 -211
- package/lib/server/recorder/contextRecorder.js +0 -286
- package/lib/server/recorder/recorderCollection.js +0 -116
- package/lib/server/recorder/recorderFrontend.js +0 -16
- package/lib/server/storageScript.js +0 -154
- package/lib/server/timeoutSettings.js +0 -89
- package/lib/utils/isomorphic/builtins.js +0 -86
- package/lib/vite/recorder/assets/index-BsWQsSGl.js +0 -184
- package/lib/vite/traceViewer/assets/defaultSettingsView-DtCQiGHe.js +0 -265
- package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +0 -1
- package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
- package/lib/vite/traceViewer/index.cFZzK9RN.js +0 -2
- package/lib/vite/traceViewer/uiMode.XVPIqBeS.js +0 -5
|
@@ -46,7 +46,7 @@ class HarRecorder {
|
|
|
46
46
|
this._writtenZipEntries = /* @__PURE__ */ new Set();
|
|
47
47
|
this._artifact = new import_artifact.Artifact(context, import_path.default.join(context._browser.options.artifactsDir, `${(0, import_crypto.createGuid)()}.har`));
|
|
48
48
|
const urlFilterRe = options.urlRegexSource !== void 0 && options.urlRegexFlags !== void 0 ? new RegExp(options.urlRegexSource, options.urlRegexFlags) : void 0;
|
|
49
|
-
const expectsZip = options.
|
|
49
|
+
const expectsZip = !!options.zip;
|
|
50
50
|
const content = options.content || (expectsZip ? "attach" : "embed");
|
|
51
51
|
this._tracer = new import_harTracer.HarTracer(context, page, this, {
|
|
52
52
|
content,
|
|
@@ -85,6 +85,8 @@ class HarTracer {
|
|
|
85
85
|
import_eventsHelper.eventsHelper.addEventListener(this._context, import_browserContext.BrowserContext.Events.RequestFulfilled, (request) => this._onRequestFulfilled(request)),
|
|
86
86
|
import_eventsHelper.eventsHelper.addEventListener(this._context, import_browserContext.BrowserContext.Events.RequestContinued, (request) => this._onRequestContinued(request))
|
|
87
87
|
);
|
|
88
|
+
for (const page of this._context.pages())
|
|
89
|
+
this._createPageEntryIfNeeded(page);
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
_shouldIncludeEntryWithUrl(urlString) {
|
|
@@ -250,7 +252,7 @@ class HarTracer {
|
|
|
250
252
|
harEntry.request.headers = headers;
|
|
251
253
|
}
|
|
252
254
|
_recordRequestOverrides(harEntry, request) {
|
|
253
|
-
if (!request.
|
|
255
|
+
if (!request.overrides() || !this._options.recordRequestOverrides)
|
|
254
256
|
return;
|
|
255
257
|
harEntry.request.method = request.method();
|
|
256
258
|
harEntry.request.url = request.url();
|
|
@@ -390,7 +392,7 @@ class HarTracer {
|
|
|
390
392
|
status: response.status(),
|
|
391
393
|
statusText: response.statusText(),
|
|
392
394
|
httpVersion: response.httpVersion(),
|
|
393
|
-
// These are bad values that will be overwritten
|
|
395
|
+
// These are bad values that will be overwritten below.
|
|
394
396
|
cookies: [],
|
|
395
397
|
headers: [],
|
|
396
398
|
content: {
|
package/lib/server/helper.js
CHANGED
|
@@ -51,22 +51,18 @@ class Helper {
|
|
|
51
51
|
}
|
|
52
52
|
static waitForEvent(progress, emitter, event, predicate) {
|
|
53
53
|
const listeners = [];
|
|
54
|
-
const
|
|
54
|
+
const dispose = () => import_eventsHelper.eventsHelper.removeEventListeners(listeners);
|
|
55
|
+
const promise = progress.race(new Promise((resolve, reject) => {
|
|
55
56
|
listeners.push(import_eventsHelper.eventsHelper.addEventListener(emitter, event, (eventArg) => {
|
|
56
57
|
try {
|
|
57
58
|
if (predicate && !predicate(eventArg))
|
|
58
59
|
return;
|
|
59
|
-
import_eventsHelper.eventsHelper.removeEventListeners(listeners);
|
|
60
60
|
resolve(eventArg);
|
|
61
61
|
} catch (e) {
|
|
62
|
-
import_eventsHelper.eventsHelper.removeEventListeners(listeners);
|
|
63
62
|
reject(e);
|
|
64
63
|
}
|
|
65
64
|
}));
|
|
66
|
-
});
|
|
67
|
-
const dispose = () => import_eventsHelper.eventsHelper.removeEventListeners(listeners);
|
|
68
|
-
if (progress)
|
|
69
|
-
progress.cleanupWhenAborted(dispose);
|
|
65
|
+
})).finally(() => dispose());
|
|
70
66
|
return { promise, dispose };
|
|
71
67
|
}
|
|
72
68
|
static secondsToRoundishMillis(value) {
|
package/lib/server/index.js
CHANGED
|
@@ -30,7 +30,6 @@ __export(server_exports, {
|
|
|
30
30
|
registry: () => import_registry.registry,
|
|
31
31
|
registryDirectory: () => import_registry.registryDirectory,
|
|
32
32
|
runTraceViewerApp: () => import_traceViewer.runTraceViewerApp,
|
|
33
|
-
serverSideCallMetadata: () => import_instrumentation.serverSideCallMetadata,
|
|
34
33
|
startTraceViewerServer: () => import_traceViewer.startTraceViewerServer,
|
|
35
34
|
writeDockerVersion: () => import_registry.writeDockerVersion
|
|
36
35
|
});
|
|
@@ -40,7 +39,6 @@ var import_dispatcher = require("./dispatchers/dispatcher");
|
|
|
40
39
|
var import_playwrightDispatcher = require("./dispatchers/playwrightDispatcher");
|
|
41
40
|
var import_playwright = require("./playwright");
|
|
42
41
|
var import_traceViewer = require("./trace/viewer/traceViewer");
|
|
43
|
-
var import_instrumentation = require("./instrumentation");
|
|
44
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
45
43
|
0 && (module.exports = {
|
|
46
44
|
DispatcherConnection,
|
|
@@ -55,7 +53,6 @@ var import_instrumentation = require("./instrumentation");
|
|
|
55
53
|
registry,
|
|
56
54
|
registryDirectory,
|
|
57
55
|
runTraceViewerApp,
|
|
58
|
-
serverSideCallMetadata,
|
|
59
56
|
startTraceViewerServer,
|
|
60
57
|
writeDockerVersion
|
|
61
58
|
});
|
package/lib/server/input.js
CHANGED
|
@@ -38,55 +38,58 @@ __export(input_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(input_exports);
|
|
39
39
|
var import_utils = require("../utils");
|
|
40
40
|
var keyboardLayout = __toESM(require("./usKeyboardLayout"));
|
|
41
|
+
var import_dom = require("./dom");
|
|
41
42
|
const keypadLocation = keyboardLayout.keypadLocation;
|
|
42
43
|
const kModifiers = ["Alt", "Control", "Meta", "Shift"];
|
|
43
44
|
class Keyboard {
|
|
44
|
-
constructor(raw) {
|
|
45
|
+
constructor(raw, page) {
|
|
45
46
|
this._pressedModifiers = /* @__PURE__ */ new Set();
|
|
46
47
|
this._pressedKeys = /* @__PURE__ */ new Set();
|
|
47
48
|
this._raw = raw;
|
|
49
|
+
this._page = page;
|
|
48
50
|
}
|
|
49
|
-
async down(key) {
|
|
51
|
+
async down(progress, key) {
|
|
50
52
|
const description = this._keyDescriptionForString(key);
|
|
51
53
|
const autoRepeat = this._pressedKeys.has(description.code);
|
|
52
54
|
this._pressedKeys.add(description.code);
|
|
53
55
|
if (kModifiers.includes(description.key))
|
|
54
56
|
this._pressedModifiers.add(description.key);
|
|
55
|
-
await this._raw.keydown(this._pressedModifiers, key, description, autoRepeat);
|
|
57
|
+
await this._raw.keydown(progress, this._pressedModifiers, key, description, autoRepeat);
|
|
56
58
|
}
|
|
57
59
|
_keyDescriptionForString(str) {
|
|
58
60
|
const keyString = resolveSmartModifierString(str);
|
|
59
61
|
let description = usKeyboardLayout.get(keyString);
|
|
60
|
-
|
|
62
|
+
if (!description)
|
|
63
|
+
throw new import_dom.NonRecoverableDOMError(`Unknown key: "${keyString}"`);
|
|
61
64
|
const shift = this._pressedModifiers.has("Shift");
|
|
62
65
|
description = shift && description.shifted ? description.shifted : description;
|
|
63
66
|
if (this._pressedModifiers.size > 1 || !this._pressedModifiers.has("Shift") && this._pressedModifiers.size === 1)
|
|
64
67
|
return { ...description, text: "" };
|
|
65
68
|
return description;
|
|
66
69
|
}
|
|
67
|
-
async up(key) {
|
|
70
|
+
async up(progress, key) {
|
|
68
71
|
const description = this._keyDescriptionForString(key);
|
|
69
72
|
if (kModifiers.includes(description.key))
|
|
70
73
|
this._pressedModifiers.delete(description.key);
|
|
71
74
|
this._pressedKeys.delete(description.code);
|
|
72
|
-
await this._raw.keyup(this._pressedModifiers, key, description);
|
|
75
|
+
await this._raw.keyup(progress, this._pressedModifiers, key, description);
|
|
73
76
|
}
|
|
74
|
-
async insertText(text) {
|
|
75
|
-
await this._raw.sendText(text);
|
|
77
|
+
async insertText(progress, text) {
|
|
78
|
+
await this._raw.sendText(progress, text);
|
|
76
79
|
}
|
|
77
|
-
async type(text, options) {
|
|
80
|
+
async type(progress, text, options) {
|
|
78
81
|
const delay = options && options.delay || void 0;
|
|
79
82
|
for (const char of text) {
|
|
80
83
|
if (usKeyboardLayout.has(char)) {
|
|
81
|
-
await this.press(char, { delay });
|
|
84
|
+
await this.press(progress, char, { delay });
|
|
82
85
|
} else {
|
|
83
86
|
if (delay)
|
|
84
|
-
await
|
|
85
|
-
await this.insertText(char);
|
|
87
|
+
await progress.wait(delay);
|
|
88
|
+
await this.insertText(progress, char);
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
}
|
|
89
|
-
async press(key, options = {}) {
|
|
92
|
+
async press(progress, key, options = {}) {
|
|
90
93
|
function split(keyString) {
|
|
91
94
|
const keys = [];
|
|
92
95
|
let building = "";
|
|
@@ -104,15 +107,15 @@ class Keyboard {
|
|
|
104
107
|
const tokens = split(key);
|
|
105
108
|
key = tokens[tokens.length - 1];
|
|
106
109
|
for (let i = 0; i < tokens.length - 1; ++i)
|
|
107
|
-
await this.down(tokens[i]);
|
|
108
|
-
await this.down(key);
|
|
110
|
+
await this.down(progress, tokens[i]);
|
|
111
|
+
await this.down(progress, key);
|
|
109
112
|
if (options.delay)
|
|
110
|
-
await
|
|
111
|
-
await this.up(key);
|
|
113
|
+
await progress.wait(options.delay);
|
|
114
|
+
await this.up(progress, key);
|
|
112
115
|
for (let i = tokens.length - 2; i >= 0; --i)
|
|
113
|
-
await this.up(tokens[i]);
|
|
116
|
+
await this.up(progress, tokens[i]);
|
|
114
117
|
}
|
|
115
|
-
async ensureModifiers(mm) {
|
|
118
|
+
async ensureModifiers(progress, mm) {
|
|
116
119
|
const modifiers = mm.map(resolveSmartModifier);
|
|
117
120
|
for (const modifier of modifiers) {
|
|
118
121
|
if (!kModifiers.includes(modifier))
|
|
@@ -123,9 +126,9 @@ class Keyboard {
|
|
|
123
126
|
const needDown = modifiers.includes(key);
|
|
124
127
|
const isDown = this._pressedModifiers.has(key);
|
|
125
128
|
if (needDown && !isDown)
|
|
126
|
-
await this.down(key);
|
|
129
|
+
await this.down(progress, key);
|
|
127
130
|
else if (!needDown && isDown)
|
|
128
|
-
await this.up(key);
|
|
131
|
+
await this.up(progress, key);
|
|
129
132
|
}
|
|
130
133
|
return restore;
|
|
131
134
|
}
|
|
@@ -151,9 +154,10 @@ class Mouse {
|
|
|
151
154
|
this._page = page;
|
|
152
155
|
this._keyboard = this._page.keyboard;
|
|
153
156
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
+
currentPoint() {
|
|
158
|
+
return { x: this._x, y: this._y };
|
|
159
|
+
}
|
|
160
|
+
async move(progress, x, y, options = {}) {
|
|
157
161
|
const { steps = 1 } = options;
|
|
158
162
|
const fromX = this._x;
|
|
159
163
|
const fromY = this._y;
|
|
@@ -162,53 +166,44 @@ class Mouse {
|
|
|
162
166
|
for (let i = 1; i <= steps; i++) {
|
|
163
167
|
const middleX = fromX + (x - fromX) * (i / steps);
|
|
164
168
|
const middleY = fromY + (y - fromY) * (i / steps);
|
|
165
|
-
await this._raw.move(middleX, middleY, this._lastButton, this._buttons, this._keyboard._modifiers(), !!options.forClick);
|
|
169
|
+
await this._raw.move(progress, middleX, middleY, this._lastButton, this._buttons, this._keyboard._modifiers(), !!options.forClick);
|
|
166
170
|
}
|
|
167
171
|
}
|
|
168
|
-
async down(options = {}
|
|
169
|
-
if (metadata)
|
|
170
|
-
metadata.point = { x: this._x, y: this._y };
|
|
172
|
+
async down(progress, options = {}) {
|
|
171
173
|
const { button = "left", clickCount = 1 } = options;
|
|
172
174
|
this._lastButton = button;
|
|
173
175
|
this._buttons.add(button);
|
|
174
|
-
await this._raw.down(this._x, this._y, this._lastButton, this._buttons, this._keyboard._modifiers(), clickCount);
|
|
176
|
+
await this._raw.down(progress, this._x, this._y, this._lastButton, this._buttons, this._keyboard._modifiers(), clickCount);
|
|
175
177
|
}
|
|
176
|
-
async up(options = {}
|
|
177
|
-
if (metadata)
|
|
178
|
-
metadata.point = { x: this._x, y: this._y };
|
|
178
|
+
async up(progress, options = {}) {
|
|
179
179
|
const { button = "left", clickCount = 1 } = options;
|
|
180
180
|
this._lastButton = "none";
|
|
181
181
|
this._buttons.delete(button);
|
|
182
|
-
await this._raw.up(this._x, this._y, button, this._buttons, this._keyboard._modifiers(), clickCount);
|
|
182
|
+
await this._raw.up(progress, this._x, this._y, button, this._buttons, this._keyboard._modifiers(), clickCount);
|
|
183
183
|
}
|
|
184
|
-
async click(x, y, options = {}
|
|
185
|
-
if (metadata)
|
|
186
|
-
metadata.point = { x, y };
|
|
184
|
+
async click(progress, x, y, options = {}) {
|
|
187
185
|
const { delay = null, clickCount = 1 } = options;
|
|
188
186
|
if (delay) {
|
|
189
|
-
this.move(x, y, { forClick: true });
|
|
187
|
+
this.move(progress, x, y, { forClick: true });
|
|
190
188
|
for (let cc = 1; cc <= clickCount; ++cc) {
|
|
191
|
-
await this.down({ ...options, clickCount: cc });
|
|
192
|
-
await
|
|
193
|
-
await this.up({ ...options, clickCount: cc });
|
|
189
|
+
await this.down(progress, { ...options, clickCount: cc });
|
|
190
|
+
await progress.wait(delay);
|
|
191
|
+
await this.up(progress, { ...options, clickCount: cc });
|
|
194
192
|
if (cc < clickCount)
|
|
195
|
-
await
|
|
193
|
+
await progress.wait(delay);
|
|
196
194
|
}
|
|
197
195
|
} else {
|
|
198
196
|
const promises = [];
|
|
199
|
-
promises.push(this.move(x, y, { forClick: true }));
|
|
197
|
+
promises.push(this.move(progress, x, y, { forClick: true }));
|
|
200
198
|
for (let cc = 1; cc <= clickCount; ++cc) {
|
|
201
|
-
promises.push(this.down({ ...options, clickCount: cc }));
|
|
202
|
-
promises.push(this.up({ ...options, clickCount: cc }));
|
|
199
|
+
promises.push(this.down(progress, { ...options, clickCount: cc }));
|
|
200
|
+
promises.push(this.up(progress, { ...options, clickCount: cc }));
|
|
203
201
|
}
|
|
204
202
|
await Promise.all(promises);
|
|
205
203
|
}
|
|
206
204
|
}
|
|
207
|
-
async
|
|
208
|
-
await this.
|
|
209
|
-
}
|
|
210
|
-
async wheel(deltaX, deltaY) {
|
|
211
|
-
await this._raw.wheel(this._x, this._y, this._buttons, this._keyboard._modifiers(), deltaX, deltaY);
|
|
205
|
+
async wheel(progress, deltaX, deltaY) {
|
|
206
|
+
await this._raw.wheel(progress, this._x, this._y, this._buttons, this._keyboard._modifiers(), deltaX, deltaY);
|
|
212
207
|
}
|
|
213
208
|
}
|
|
214
209
|
const aliases = /* @__PURE__ */ new Map([
|
|
@@ -261,12 +256,10 @@ class Touchscreen {
|
|
|
261
256
|
this._raw = raw;
|
|
262
257
|
this._page = page;
|
|
263
258
|
}
|
|
264
|
-
async tap(x, y
|
|
265
|
-
if (
|
|
266
|
-
metadata.point = { x, y };
|
|
267
|
-
if (!this._page._browserContext._options.hasTouch)
|
|
259
|
+
async tap(progress, x, y) {
|
|
260
|
+
if (!this._page.browserContext._options.hasTouch)
|
|
268
261
|
throw new Error("hasTouch must be enabled on the browser context before using the touchscreen.");
|
|
269
|
-
await this._raw.tap(x, y, this._page.keyboard._modifiers());
|
|
262
|
+
await this._raw.tap(progress, x, y, this._page.keyboard._modifiers());
|
|
270
263
|
}
|
|
271
264
|
}
|
|
272
265
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -20,7 +20,7 @@ var instrumentation_exports = {};
|
|
|
20
20
|
__export(instrumentation_exports, {
|
|
21
21
|
SdkObject: () => SdkObject,
|
|
22
22
|
createInstrumentation: () => createInstrumentation,
|
|
23
|
-
|
|
23
|
+
createRootSdkObject: () => createRootSdkObject
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(instrumentation_exports);
|
|
26
26
|
var import_events = require("events");
|
|
@@ -34,6 +34,12 @@ class SdkObject extends import_events.EventEmitter {
|
|
|
34
34
|
this.instrumentation = parent.instrumentation;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
function createRootSdkObject() {
|
|
38
|
+
const fakeParent = { attribution: {}, instrumentation: createInstrumentation() };
|
|
39
|
+
const root = new SdkObject(fakeParent);
|
|
40
|
+
root.guid = "";
|
|
41
|
+
return root;
|
|
42
|
+
}
|
|
37
43
|
function createInstrumentation() {
|
|
38
44
|
const listeners = /* @__PURE__ */ new Map();
|
|
39
45
|
return new Proxy({}, {
|
|
@@ -55,21 +61,9 @@ function createInstrumentation() {
|
|
|
55
61
|
}
|
|
56
62
|
});
|
|
57
63
|
}
|
|
58
|
-
function serverSideCallMetadata() {
|
|
59
|
-
return {
|
|
60
|
-
id: "",
|
|
61
|
-
startTime: 0,
|
|
62
|
-
endTime: 0,
|
|
63
|
-
type: "Internal",
|
|
64
|
-
method: "",
|
|
65
|
-
params: {},
|
|
66
|
-
log: [],
|
|
67
|
-
isServerSide: true
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
64
|
// Annotate the CommonJS export names for ESM import in node:
|
|
71
65
|
0 && (module.exports = {
|
|
72
66
|
SdkObject,
|
|
73
67
|
createInstrumentation,
|
|
74
|
-
|
|
68
|
+
createRootSdkObject
|
|
75
69
|
});
|
package/lib/server/javascript.js
CHANGED
|
@@ -35,21 +35,15 @@ __export(javascript_exports, {
|
|
|
35
35
|
evaluateExpression: () => evaluateExpression,
|
|
36
36
|
isJavaScriptErrorInEvaluate: () => isJavaScriptErrorInEvaluate,
|
|
37
37
|
normalizeEvaluationExpression: () => normalizeEvaluationExpression,
|
|
38
|
-
parseEvaluationResultValue: () => parseEvaluationResultValue,
|
|
39
38
|
parseUnserializableValue: () => parseUnserializableValue,
|
|
40
|
-
serializeAsCallArgument: () => serializeAsCallArgument,
|
|
41
39
|
sparseArrayToString: () => sparseArrayToString
|
|
42
40
|
});
|
|
43
41
|
module.exports = __toCommonJS(javascript_exports);
|
|
44
42
|
var import_instrumentation = require("./instrumentation");
|
|
45
|
-
var
|
|
43
|
+
var rawUtilityScriptSource = __toESM(require("../generated/utilityScriptSource"));
|
|
46
44
|
var import_utils = require("../utils");
|
|
47
|
-
var import_builtins = require("../utils/isomorphic/builtins");
|
|
48
45
|
var import_utilityScriptSerializers = require("../utils/isomorphic/utilityScriptSerializers");
|
|
49
46
|
var import_manualPromise = require("../utils/isomorphic/manualPromise");
|
|
50
|
-
const utilityScriptSerializers = (0, import_utilityScriptSerializers.source)((0, import_builtins.builtins)());
|
|
51
|
-
const parseEvaluationResultValue = utilityScriptSerializers.parseEvaluationResultValue;
|
|
52
|
-
const serializeAsCallArgument = utilityScriptSerializers.serializeAsCallArgument;
|
|
53
47
|
class ExecutionContext extends import_instrumentation.SdkObject {
|
|
54
48
|
constructor(parent, delegate, worldNameForTest) {
|
|
55
49
|
super(parent, "execution-context");
|
|
@@ -70,7 +64,7 @@ class ExecutionContext extends import_instrumentation.SdkObject {
|
|
|
70
64
|
return this._raceAgainstContextDestroyed(this.delegate.rawEvaluateHandle(this, expression));
|
|
71
65
|
}
|
|
72
66
|
async evaluateWithArguments(expression, returnByValue, values, handles) {
|
|
73
|
-
const utilityScript = await this.
|
|
67
|
+
const utilityScript = await this.utilityScript();
|
|
74
68
|
return this._raceAgainstContextDestroyed(this.delegate.evaluateWithArguments(expression, returnByValue, utilityScript, values, handles));
|
|
75
69
|
}
|
|
76
70
|
getProperties(object) {
|
|
@@ -82,15 +76,15 @@ class ExecutionContext extends import_instrumentation.SdkObject {
|
|
|
82
76
|
adoptIfNeeded(handle) {
|
|
83
77
|
return null;
|
|
84
78
|
}
|
|
85
|
-
|
|
79
|
+
utilityScript() {
|
|
86
80
|
if (!this._utilityScriptPromise) {
|
|
87
|
-
const
|
|
81
|
+
const source = `
|
|
88
82
|
(() => {
|
|
89
83
|
const module = {};
|
|
90
|
-
${
|
|
91
|
-
return new (module.exports.UtilityScript())(${(0, import_utils.isUnderTest)()});
|
|
84
|
+
${rawUtilityScriptSource.source}
|
|
85
|
+
return new (module.exports.UtilityScript())(globalThis, ${(0, import_utils.isUnderTest)()});
|
|
92
86
|
})();`;
|
|
93
|
-
this._utilityScriptPromise = this._raceAgainstContextDestroyed(this.delegate.rawEvaluateHandle(this,
|
|
87
|
+
this._utilityScriptPromise = this._raceAgainstContextDestroyed(this.delegate.rawEvaluateHandle(this, source)).then((handle) => {
|
|
94
88
|
handle._setPreview("UtilityScript");
|
|
95
89
|
return handle;
|
|
96
90
|
});
|
|
@@ -213,7 +207,7 @@ async function evaluateExpression(context, expression, options, ...args) {
|
|
|
213
207
|
handles.push(handle);
|
|
214
208
|
return handles.length - 1;
|
|
215
209
|
};
|
|
216
|
-
args = args.map((arg) => serializeAsCallArgument(arg, (handle) => {
|
|
210
|
+
args = args.map((arg) => (0, import_utilityScriptSerializers.serializeAsCallArgument)(arg, (handle) => {
|
|
217
211
|
if (handle instanceof JSHandle) {
|
|
218
212
|
if (!handle._objectId)
|
|
219
213
|
return { fallThrough: handle._value };
|
|
@@ -308,8 +302,6 @@ function sparseArrayToString(entries) {
|
|
|
308
302
|
evaluateExpression,
|
|
309
303
|
isJavaScriptErrorInEvaluate,
|
|
310
304
|
normalizeEvaluationExpression,
|
|
311
|
-
parseEvaluationResultValue,
|
|
312
305
|
parseUnserializableValue,
|
|
313
|
-
serializeAsCallArgument,
|
|
314
306
|
sparseArrayToString
|
|
315
307
|
});
|
package/lib/server/launchApp.js
CHANGED
|
@@ -35,9 +35,9 @@ module.exports = __toCommonJS(launchApp_exports);
|
|
|
35
35
|
var import_fs = __toESM(require("fs"));
|
|
36
36
|
var import_path = __toESM(require("path"));
|
|
37
37
|
var import_utils = require("../utils");
|
|
38
|
-
var import_instrumentation = require("./instrumentation");
|
|
39
38
|
var import_registry = require("./registry");
|
|
40
39
|
var import_registry2 = require("./registry");
|
|
40
|
+
var import_progress = require("./progress");
|
|
41
41
|
async function launchApp(browserType, options) {
|
|
42
42
|
const args = [...options.persistentContextOptions?.args ?? []];
|
|
43
43
|
let channel = options.persistentContextOptions?.channel;
|
|
@@ -49,23 +49,37 @@ async function launchApp(browserType, options) {
|
|
|
49
49
|
"--test-type="
|
|
50
50
|
);
|
|
51
51
|
if (!channel && !options.persistentContextOptions?.executablePath)
|
|
52
|
-
channel = (0, import_registry.
|
|
52
|
+
channel = (0, import_registry.findChromiumChannelBestEffort)(options.sdkLanguage);
|
|
53
|
+
}
|
|
54
|
+
const controller = new import_progress.ProgressController();
|
|
55
|
+
let context;
|
|
56
|
+
try {
|
|
57
|
+
context = await controller.run((progress) => browserType.launchPersistentContext(progress, "", {
|
|
58
|
+
ignoreDefaultArgs: ["--enable-automation"],
|
|
59
|
+
...options?.persistentContextOptions,
|
|
60
|
+
channel,
|
|
61
|
+
noDefaultViewport: options.persistentContextOptions?.noDefaultViewport ?? true,
|
|
62
|
+
acceptDownloads: options?.persistentContextOptions?.acceptDownloads ?? ((0, import_utils.isUnderTest)() ? "accept" : "internal-browser-default"),
|
|
63
|
+
colorScheme: options?.persistentContextOptions?.colorScheme ?? "no-override",
|
|
64
|
+
args
|
|
65
|
+
}), 0);
|
|
66
|
+
} catch (error) {
|
|
67
|
+
if (channel) {
|
|
68
|
+
error = (0, import_utils.rewriteErrorMessage)(error, [
|
|
69
|
+
`Failed to launch "${channel}" channel.`,
|
|
70
|
+
"Using custom channels could lead to unexpected behavior due to Enterprise policies (chrome://policy).",
|
|
71
|
+
"Install the default browser instead:",
|
|
72
|
+
(0, import_utils.wrapInASCIIBox)(`${(0, import_registry.buildPlaywrightCLICommand)(options.sdkLanguage, "install")}`, 2)
|
|
73
|
+
].join("\n"));
|
|
74
|
+
}
|
|
75
|
+
throw error;
|
|
53
76
|
}
|
|
54
|
-
const context = await browserType.launchPersistentContext((0, import_instrumentation.serverSideCallMetadata)(), "", {
|
|
55
|
-
ignoreDefaultArgs: ["--enable-automation"],
|
|
56
|
-
...options?.persistentContextOptions,
|
|
57
|
-
channel,
|
|
58
|
-
noDefaultViewport: options.persistentContextOptions?.noDefaultViewport ?? true,
|
|
59
|
-
acceptDownloads: options?.persistentContextOptions?.acceptDownloads ?? ((0, import_utils.isUnderTest)() ? "accept" : "internal-browser-default"),
|
|
60
|
-
colorScheme: options?.persistentContextOptions?.colorScheme ?? "no-override",
|
|
61
|
-
args
|
|
62
|
-
});
|
|
63
77
|
const [page] = context.pages();
|
|
64
78
|
if (browserType.name() === "chromium" && process.platform === "darwin") {
|
|
65
79
|
context.on("page", async (newPage) => {
|
|
66
80
|
if (newPage.mainFrame().url() === "chrome://new-tab-page/") {
|
|
67
81
|
await page.bringToFront();
|
|
68
|
-
await newPage.close(
|
|
82
|
+
await newPage.close();
|
|
69
83
|
}
|
|
70
84
|
});
|
|
71
85
|
}
|
|
@@ -75,7 +89,7 @@ async function launchApp(browserType, options) {
|
|
|
75
89
|
}
|
|
76
90
|
async function installAppIcon(page) {
|
|
77
91
|
const icon = await import_fs.default.promises.readFile(require.resolve("./chromium/appIcon.png"));
|
|
78
|
-
const crPage = page.
|
|
92
|
+
const crPage = page.delegate;
|
|
79
93
|
await crPage._mainFrameSession._client.send("Browser.setDockTile", {
|
|
80
94
|
image: icon.toString("base64")
|
|
81
95
|
});
|
|
@@ -84,24 +98,28 @@ async function syncLocalStorageWithSettings(page, appName) {
|
|
|
84
98
|
if ((0, import_utils.isUnderTest)())
|
|
85
99
|
return;
|
|
86
100
|
const settingsFile = import_path.default.join(import_registry2.registryDirectory, ".settings", `${appName}.json`);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
const controller = new import_progress.ProgressController();
|
|
102
|
+
await controller.run(async (progress) => {
|
|
103
|
+
await page.exposeBinding(progress, "_saveSerializedSettings", false, (_, settings2) => {
|
|
104
|
+
import_fs.default.mkdirSync(import_path.default.dirname(settingsFile), { recursive: true });
|
|
105
|
+
import_fs.default.writeFileSync(settingsFile, settings2);
|
|
106
|
+
});
|
|
107
|
+
const settings = await import_fs.default.promises.readFile(settingsFile, "utf-8").catch(() => "{}");
|
|
108
|
+
await page.addInitScript(
|
|
109
|
+
progress,
|
|
110
|
+
`(${String((settings2) => {
|
|
111
|
+
if (location && location.protocol === "data:")
|
|
112
|
+
return;
|
|
113
|
+
if (window.top !== window)
|
|
114
|
+
return;
|
|
115
|
+
Object.entries(settings2).map(([k, v]) => localStorage[k] = v);
|
|
116
|
+
window.saveSettings = () => {
|
|
117
|
+
window._saveSerializedSettings(JSON.stringify({ ...localStorage }));
|
|
118
|
+
};
|
|
119
|
+
})})(${settings});
|
|
120
|
+
`
|
|
121
|
+
);
|
|
90
122
|
});
|
|
91
|
-
const settings = await import_fs.default.promises.readFile(settingsFile, "utf-8").catch(() => "{}");
|
|
92
|
-
await page.addInitScript(
|
|
93
|
-
`(${String((settings2) => {
|
|
94
|
-
if (location && location.protocol === "data:")
|
|
95
|
-
return;
|
|
96
|
-
if (window.top !== window)
|
|
97
|
-
return;
|
|
98
|
-
Object.entries(settings2).map(([k, v]) => localStorage[k] = v);
|
|
99
|
-
window.saveSettings = () => {
|
|
100
|
-
window._saveSerializedSettings(JSON.stringify({ ...localStorage }));
|
|
101
|
-
};
|
|
102
|
-
})})(${settings});
|
|
103
|
-
`
|
|
104
|
-
);
|
|
105
123
|
}
|
|
106
124
|
// Annotate the CommonJS export names for ESM import in node:
|
|
107
125
|
0 && (module.exports = {
|