patchright-core 1.50.1 → 1.51.1
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 +1 -43
- package/browsers.json +22 -10
- package/index.js +0 -1
- package/lib/androidServerImpl.js +4 -4
- package/lib/browserServerImpl.js +18 -9
- package/lib/cli/driver.js +6 -6
- package/lib/cli/program.js +9 -9
- package/lib/cli/programWithTestStub.js +2 -1
- package/lib/client/android.js +37 -58
- package/lib/client/artifact.js +4 -7
- package/lib/client/browser.js +10 -15
- package/lib/client/browserContext.js +77 -73
- package/lib/client/browserType.js +30 -64
- package/lib/client/channelOwner.js +23 -20
- package/lib/client/clientHelper.js +5 -7
- package/lib/client/clientStackTrace.js +65 -0
- package/lib/client/connection.js +46 -39
- package/lib/client/consoleMessage.js +4 -7
- package/lib/client/electron.js +10 -10
- package/lib/client/elementHandle.js +32 -33
- package/lib/client/errors.js +2 -2
- package/lib/client/eventEmitter.js +5 -8
- package/lib/client/fetch.js +60 -61
- package/lib/client/fileUtils.js +31 -0
- package/lib/client/frame.js +30 -29
- package/lib/client/harRouter.js +7 -9
- package/lib/client/jsHandle.js +3 -4
- package/lib/client/localUtils.js +24 -0
- package/lib/client/locator.js +37 -18
- package/lib/client/network.js +40 -40
- package/lib/client/page.js +59 -55
- package/lib/client/platform.js +71 -0
- package/lib/client/playwright.js +21 -1
- package/lib/client/selectors.js +8 -2
- package/lib/client/stream.js +2 -21
- package/lib/client/timeoutSettings.js +65 -0
- package/lib/client/tracing.js +10 -7
- package/lib/client/video.js +2 -2
- package/lib/client/waiter.js +5 -6
- package/lib/client/webSocket.js +106 -0
- package/lib/client/worker.js +12 -10
- package/lib/client/writableStream.js +2 -21
- package/lib/generated/consoleApiSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/inProcessFactory.js +6 -3
- package/lib/outofprocess.js +12 -8
- package/lib/protocol/validator.js +64 -13
- package/lib/protocol/validatorPrimitives.js +1 -2
- package/lib/remote/playwrightConnection.js +18 -10
- package/lib/remote/playwrightServer.js +20 -7
- package/lib/server/android/android.js +17 -14
- package/lib/server/android/backendAdb.js +14 -14
- package/lib/server/artifact.js +3 -3
- package/lib/server/bidi/bidiBrowser.js +2 -2
- package/lib/server/bidi/bidiChromium.js +4 -3
- package/lib/server/bidi/bidiConnection.js +1 -1
- package/lib/server/bidi/bidiExecutionContext.js +70 -40
- package/lib/server/bidi/bidiFirefox.js +4 -3
- package/lib/server/bidi/bidiInput.js +5 -8
- package/lib/server/bidi/bidiNetworkManager.js +3 -3
- package/lib/server/bidi/bidiOverCdp.js +2 -2
- package/lib/server/bidi/bidiPage.js +30 -46
- package/lib/server/bidi/third_party/firefoxPrefs.js +19 -3
- package/lib/server/browser.js +2 -2
- package/lib/server/browserContext.js +37 -40
- package/lib/server/browserType.js +18 -17
- package/lib/{utils/sequence.js → server/callLog.js} +18 -3
- package/lib/server/chromium/chromium.js +14 -14
- package/lib/server/chromium/chromiumSwitches.js +32 -1
- package/lib/server/chromium/crBrowser.js +15 -14
- package/lib/server/chromium/crConnection.js +2 -2
- package/lib/server/chromium/crCoverage.js +1 -1
- package/lib/server/chromium/crDevTools.js +1 -1
- package/lib/server/chromium/crDragDrop.js +1 -1
- package/lib/server/chromium/crExecutionContext.js +25 -17
- package/lib/server/chromium/crInput.js +2 -2
- package/lib/server/chromium/crNetworkManager.js +73 -26
- package/lib/server/chromium/crPage.js +22 -23
- package/lib/server/chromium/crPdf.js +1 -1
- package/lib/server/chromium/crProtocolHelper.js +3 -3
- package/lib/server/chromium/crServiceWorker.js +2 -2
- package/lib/server/chromium/videoRecorder.js +2 -2
- package/lib/server/clock.js +1 -1
- package/lib/server/codegen/javascript.js +1 -1
- package/lib/server/codegen/languages.js +2 -2
- package/lib/server/debugController.js +3 -3
- package/lib/server/deviceDescriptors.js +1 -1
- package/lib/server/deviceDescriptorsSource.json +131 -131
- package/lib/server/dispatchers/androidDispatcher.js +1 -1
- package/lib/server/dispatchers/artifactDispatcher.js +3 -3
- package/lib/server/dispatchers/browserContextDispatcher.js +19 -19
- package/lib/server/dispatchers/browserTypeDispatcher.js +1 -1
- package/lib/server/dispatchers/cdpSessionDispatcher.js +1 -1
- package/lib/server/dispatchers/dispatcher.js +27 -25
- package/lib/server/dispatchers/electronDispatcher.js +3 -3
- package/lib/server/dispatchers/elementHandlerDispatcher.js +7 -2
- package/lib/server/dispatchers/frameDispatcher.js +4 -4
- package/lib/server/dispatchers/jsHandleDispatcher.js +2 -2
- package/lib/server/dispatchers/jsonPipeDispatcher.js +2 -2
- package/lib/server/dispatchers/localUtilsDispatcher.js +25 -298
- package/lib/server/dispatchers/networkDispatchers.js +3 -3
- package/lib/server/dispatchers/pageDispatcher.js +11 -9
- package/lib/server/dispatchers/playwrightDispatcher.js +5 -5
- package/lib/server/dispatchers/streamDispatcher.js +4 -3
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +8 -7
- package/lib/server/dispatchers/writableStreamDispatcher.js +5 -6
- package/lib/server/dom.js +18 -12
- package/lib/server/download.js +1 -1
- package/lib/server/electron/electron.js +17 -16
- package/lib/server/errors.js +1 -1
- package/lib/server/fetch.js +36 -25
- package/lib/server/fileUploadUtils.js +7 -4
- package/lib/server/firefox/ffBrowser.js +8 -2
- package/lib/server/firefox/ffConnection.js +1 -1
- package/lib/server/firefox/ffExecutionContext.js +25 -17
- package/lib/server/firefox/ffNetworkManager.js +2 -2
- package/lib/server/firefox/ffPage.js +15 -21
- package/lib/server/firefox/firefox.js +7 -9
- package/lib/server/frameSelectors.js +1 -1
- package/lib/server/frames.js +366 -209
- package/lib/server/har/harRecorder.js +4 -4
- package/lib/server/har/harTracer.js +7 -8
- package/lib/server/harBackend.js +157 -0
- package/lib/server/helper.js +2 -2
- package/lib/server/index.js +1 -8
- package/lib/server/input.js +1 -1
- package/lib/server/instrumentation.js +2 -2
- package/lib/server/isomorphic/utilityScriptSerializers.js +3 -0
- package/lib/server/javascript.js +46 -33
- package/lib/server/launchApp.js +2 -2
- package/lib/server/localUtils.js +203 -0
- package/lib/server/network.js +3 -3
- package/lib/server/page.js +41 -22
- package/lib/server/pipeTransport.js +1 -1
- package/lib/server/playwright.js +5 -5
- package/lib/server/progress.js +1 -1
- package/lib/server/protocolError.js +1 -1
- package/lib/server/recorder/contextRecorder.js +3 -3
- package/lib/server/recorder/recorderApp.js +18 -12
- package/lib/server/recorder/recorderCollection.js +3 -3
- package/lib/server/recorder/throttledFile.js +3 -4
- package/lib/server/recorder.js +7 -5
- package/lib/server/registry/browserFetcher.js +9 -7
- package/lib/server/registry/dependencies.js +15 -15
- package/lib/server/registry/index.js +38 -44
- package/lib/server/registry/oopDownloadBrowserMain.js +3 -3
- package/lib/server/screenshotter.js +1 -1
- package/lib/server/selectors.js +3 -3
- package/lib/server/socksClientCertificatesInterceptor.js +8 -8
- package/lib/server/socksInterceptor.js +8 -5
- package/lib/server/storageScript.js +160 -0
- package/lib/{common → server}/timeoutSettings.js +6 -5
- package/lib/server/trace/recorder/snapshotter.js +9 -8
- package/lib/server/trace/recorder/tracing.js +40 -31
- package/lib/server/trace/test/inMemorySnapshotter.js +4 -4
- package/lib/server/trace/viewer/traceViewer.js +13 -5
- package/lib/server/transport.js +2 -2
- package/lib/{utils → server/utils}/comparators.js +4 -4
- package/lib/{utils → server/utils}/crypto.js +4 -4
- package/lib/{utils → server/utils}/debug.js +4 -12
- package/lib/{utils → server/utils}/debugLogger.js +2 -2
- package/lib/{utils → server/utils}/env.js +4 -0
- package/lib/{utils → server/utils}/expectUtils.js +1 -1
- package/lib/{utils → server/utils}/fileUtils.js +4 -5
- package/lib/{utils/happy-eyeballs.js → server/utils/happyEyeballs.js} +22 -24
- package/lib/{utils → server/utils}/hostPlatform.js +1 -1
- package/lib/{utils → server/utils}/httpServer.js +8 -8
- package/lib/{utils → server/utils}/linuxUtils.js +3 -23
- package/lib/{utils → server/utils}/network.js +4 -4
- package/lib/server/utils/nodePlatform.js +140 -0
- package/lib/{protocol/transport.js → server/utils/pipeTransport.js} +2 -2
- package/lib/{utils → server/utils}/processLauncher.js +5 -5
- package/lib/{utils → server/utils}/profiler.js +5 -6
- package/lib/{common → server/utils}/socksProxy.js +10 -9
- package/lib/{utils → server/utils}/userAgent.js +2 -16
- package/lib/{utils → server/utils}/wsServer.js +3 -3
- package/lib/{utils → server/utils}/zipFile.js +1 -1
- package/lib/{utils → server/utils}/zones.js +9 -24
- package/lib/server/webkit/webkit.js +4 -4
- package/lib/server/webkit/wkBrowser.js +4 -4
- package/lib/server/webkit/wkConnection.js +1 -1
- package/lib/server/webkit/wkExecutionContext.js +25 -17
- package/lib/server/webkit/wkInput.js +2 -2
- package/lib/server/webkit/wkInterceptableRequest.js +2 -2
- package/lib/server/webkit/wkPage.js +41 -40
- package/lib/server/webkit/wkProvisionalPage.js +1 -1
- package/lib/server/webkit/wkWorkers.js +2 -2
- package/lib/utils/isomorphic/ariaSnapshot.js +2 -1
- package/lib/utils/isomorphic/assert.js +25 -0
- package/lib/utils/isomorphic/colors.js +65 -0
- package/lib/utils/isomorphic/cssParser.js +1 -1
- package/lib/utils/isomorphic/locatorGenerators.js +13 -1
- package/lib/utils/isomorphic/locatorParser.js +2 -2
- package/lib/utils/{manualPromise.js → isomorphic/manualPromise.js} +3 -5
- package/lib/utils/isomorphic/mimeType.js +11 -3
- package/lib/utils/{multimap.js → isomorphic/multimap.js} +1 -3
- package/lib/utils/{rtti.js → isomorphic/rtti.js} +2 -5
- package/lib/utils/isomorphic/stackTrace.js +169 -0
- package/lib/utils/isomorphic/stringUtils.js +1 -1
- package/lib/utils/{time.js → isomorphic/time.js} +1 -13
- package/lib/utils/{timeoutRunner.js → isomorphic/timeoutRunner.js} +4 -4
- package/lib/utils/isomorphic/traceUtils.js +23 -0
- package/lib/{utils/index.js → utils.js} +200 -121
- package/lib/utilsBundle.js +1 -25
- package/lib/utilsBundleImpl/index.js +114 -116
- package/lib/vite/htmlReport/index.html +20 -20
- package/lib/vite/recorder/assets/codeMirrorModule-B9YMkrwa.js +24 -0
- package/lib/vite/recorder/assets/index-ELPgmkwA.js +184 -0
- package/lib/vite/recorder/index.html +1 -1
- package/lib/vite/traceViewer/assets/codeMirrorModule-DpJ-EmBQ.js +24 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-DTenqiGw.js +259 -0
- package/lib/vite/traceViewer/assets/{xtermModule-c-SNdYZy.js → xtermModule-BoAIEibi.js} +7 -7
- package/lib/vite/traceViewer/defaultSettingsView.5fN5lw10.css +1 -0
- package/lib/vite/traceViewer/index.CUq7VgrV.js +2 -0
- package/lib/vite/traceViewer/index.html +3 -3
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/uiMode.CHJSAD7F.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +7 -7
- package/types/protocol.d.ts +123 -99
- package/types/types.d.ts +91 -37
- package/lib/utils/stackTrace.js +0 -134
- package/lib/utils/traceUtils.js +0 -44
- package/lib/vite/recorder/assets/codeMirrorModule-CNAqJrkA.js +0 -24
- package/lib/vite/recorder/assets/index-DGS0JLxS.js +0 -184
- package/lib/vite/traceViewer/assets/codeMirrorModule-D55P_UuL.js +0 -24
- package/lib/vite/traceViewer/assets/defaultSettingsView-B-uNoFsX.js +0 -243
- package/lib/vite/traceViewer/defaultSettingsView.2xeEXCXv.css +0 -1
- package/lib/vite/traceViewer/index.BfvuujqP.js +0 -2
- package/lib/vite/traceViewer/uiMode.CStJu6jo.js +0 -5
- /package/lib/{utils → server/utils}/ascii.js +0 -0
- /package/lib/{utils → server/utils}/eventsHelper.js +0 -0
- /package/lib/{image_tools → server/utils/image_tools}/colorUtils.js +0 -0
- /package/lib/{image_tools → server/utils/image_tools}/compare.js +0 -0
- /package/lib/{image_tools → server/utils/image_tools}/imageChannel.js +0 -0
- /package/lib/{image_tools → server/utils/image_tools}/stats.js +0 -0
- /package/lib/{utils → server/utils}/spawnAsync.js +0 -0
- /package/lib/{utils → server/utils}/task.js +0 -0
- /package/lib/utils/{headers.js → isomorphic/headers.js} +0 -0
- /package/lib/utils/{semaphore.js → isomorphic/semaphore.js} +0 -0
- /package/lib/{common → utils/isomorphic}/types.js +0 -0
package/lib/client/fetch.js
CHANGED
|
@@ -4,17 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.APIResponse = exports.APIRequestContext = exports.APIRequest = void 0;
|
|
7
|
-
var
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var util = _interopRequireWildcard(require("util"));
|
|
10
|
-
var _utils = require("../utils");
|
|
11
|
-
var _fileUtils = require("../utils/fileUtils");
|
|
7
|
+
var _browserContext = require("./browserContext");
|
|
12
8
|
var _channelOwner = require("./channelOwner");
|
|
9
|
+
var _errors = require("./errors");
|
|
13
10
|
var _network = require("./network");
|
|
14
11
|
var _tracing = require("./tracing");
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
|
|
12
|
+
var _assert = require("../utils/isomorphic/assert");
|
|
13
|
+
var _fileUtils = require("./fileUtils");
|
|
14
|
+
var _headers = require("../utils/isomorphic/headers");
|
|
15
|
+
var _rtti = require("../utils/isomorphic/rtti");
|
|
18
16
|
/**
|
|
19
17
|
* Copyright (c) Microsoft Corporation.
|
|
20
18
|
*
|
|
@@ -30,42 +28,37 @@ let _Symbol$asyncDispose, _Symbol$asyncDispose2, _util$inspect$custom;
|
|
|
30
28
|
* See the License for the specific language governing permissions and
|
|
31
29
|
* limitations under the License.
|
|
32
30
|
*/
|
|
33
|
-
|
|
34
|
-
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; }
|
|
35
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
+
|
|
36
32
|
class APIRequest {
|
|
37
33
|
constructor(playwright) {
|
|
38
34
|
this._playwright = void 0;
|
|
39
35
|
this._contexts = new Set();
|
|
40
|
-
// Instrumentation.
|
|
41
|
-
this._defaultContextOptions = void 0;
|
|
42
36
|
this._playwright = playwright;
|
|
43
37
|
}
|
|
44
38
|
async newContext(options = {}) {
|
|
45
|
-
var _this$
|
|
39
|
+
var _this$_playwright$_de, _this$_playwright$_de2;
|
|
46
40
|
options = {
|
|
47
|
-
...this._defaultContextOptions,
|
|
41
|
+
...this._playwright._defaultContextOptions,
|
|
42
|
+
timeout: this._playwright._defaultContextTimeout,
|
|
48
43
|
...options
|
|
49
44
|
};
|
|
50
|
-
const storageState = typeof options.storageState === 'string' ? JSON.parse(await
|
|
51
|
-
// We do not expose tracesDir in the API, so do not allow options to accidentally override it.
|
|
52
|
-
const tracesDir = (_this$_defaultContext = this._defaultContextOptions) === null || _this$_defaultContext === void 0 ? void 0 : _this$_defaultContext.tracesDir;
|
|
45
|
+
const storageState = typeof options.storageState === 'string' ? JSON.parse(await this._playwright._platform.fs().promises.readFile(options.storageState, 'utf8')) : options.storageState;
|
|
53
46
|
const context = APIRequestContext.from((await this._playwright._channel.newRequest({
|
|
54
47
|
...options,
|
|
55
|
-
extraHTTPHeaders: options.extraHTTPHeaders ? (0,
|
|
48
|
+
extraHTTPHeaders: options.extraHTTPHeaders ? (0, _headers.headersObjectToArray)(options.extraHTTPHeaders) : undefined,
|
|
56
49
|
storageState,
|
|
57
|
-
tracesDir,
|
|
58
|
-
|
|
50
|
+
tracesDir: (_this$_playwright$_de = this._playwright._defaultLaunchOptions) === null || _this$_playwright$_de === void 0 ? void 0 : _this$_playwright$_de.tracesDir,
|
|
51
|
+
// We do not expose tracesDir in the API, so do not allow options to accidentally override it.
|
|
52
|
+
clientCertificates: await (0, _browserContext.toClientCertificatesProtocol)(this._playwright._platform, options.clientCertificates)
|
|
59
53
|
})).request);
|
|
60
54
|
this._contexts.add(context);
|
|
61
55
|
context._request = this;
|
|
62
|
-
context._tracing._tracesDir = tracesDir;
|
|
56
|
+
context._tracing._tracesDir = (_this$_playwright$_de2 = this._playwright._defaultLaunchOptions) === null || _this$_playwright$_de2 === void 0 ? void 0 : _this$_playwright$_de2.tracesDir;
|
|
63
57
|
await context._instrumentation.runAfterCreateRequestContext(context);
|
|
64
58
|
return context;
|
|
65
59
|
}
|
|
66
60
|
}
|
|
67
61
|
exports.APIRequest = APIRequest;
|
|
68
|
-
_Symbol$asyncDispose = Symbol.asyncDispose;
|
|
69
62
|
class APIRequestContext extends _channelOwner.ChannelOwner {
|
|
70
63
|
static from(channel) {
|
|
71
64
|
return channel._object;
|
|
@@ -77,7 +70,7 @@ class APIRequestContext extends _channelOwner.ChannelOwner {
|
|
|
77
70
|
this._closeReason = void 0;
|
|
78
71
|
this._tracing = _tracing.Tracing.from(initializer.tracing);
|
|
79
72
|
}
|
|
80
|
-
async [
|
|
73
|
+
async [Symbol.asyncDispose]() {
|
|
81
74
|
await this.dispose();
|
|
82
75
|
}
|
|
83
76
|
async dispose(options = {}) {
|
|
@@ -130,8 +123,8 @@ class APIRequestContext extends _channelOwner.ChannelOwner {
|
|
|
130
123
|
});
|
|
131
124
|
}
|
|
132
125
|
async fetch(urlOrRequest, options = {}) {
|
|
133
|
-
const url = (0,
|
|
134
|
-
const request = (0,
|
|
126
|
+
const url = (0, _rtti.isString)(urlOrRequest) ? urlOrRequest : undefined;
|
|
127
|
+
const request = (0, _rtti.isString)(urlOrRequest) ? undefined : urlOrRequest;
|
|
135
128
|
return await this._innerFetch({
|
|
136
129
|
url,
|
|
137
130
|
request,
|
|
@@ -142,23 +135,23 @@ class APIRequestContext extends _channelOwner.ChannelOwner {
|
|
|
142
135
|
return await this._wrapApiCall(async () => {
|
|
143
136
|
var _options$request, _options$request2, _options$request3;
|
|
144
137
|
if (this._closeReason) throw new _errors.TargetClosedError(this._closeReason);
|
|
145
|
-
(0,
|
|
146
|
-
(0,
|
|
147
|
-
(0,
|
|
148
|
-
(0,
|
|
138
|
+
(0, _assert.assert)(options.request || typeof options.url === 'string', 'First argument must be either URL string or Request');
|
|
139
|
+
(0, _assert.assert)((options.data === undefined ? 0 : 1) + (options.form === undefined ? 0 : 1) + (options.multipart === undefined ? 0 : 1) <= 1, `Only one of 'data', 'form' or 'multipart' can be specified`);
|
|
140
|
+
(0, _assert.assert)(options.maxRedirects === undefined || options.maxRedirects >= 0, `'maxRedirects' must be greater than or equal to '0'`);
|
|
141
|
+
(0, _assert.assert)(options.maxRetries === undefined || options.maxRetries >= 0, `'maxRetries' must be greater than or equal to '0'`);
|
|
149
142
|
const url = options.url !== undefined ? options.url : options.request.url();
|
|
150
143
|
const method = options.method || ((_options$request = options.request) === null || _options$request === void 0 ? void 0 : _options$request.method());
|
|
151
144
|
let encodedParams = undefined;
|
|
152
145
|
if (typeof options.params === 'string') encodedParams = options.params;else if (options.params instanceof URLSearchParams) encodedParams = options.params.toString();
|
|
153
146
|
// Cannot call allHeaders() here as the request may be paused inside route handler.
|
|
154
147
|
const headersObj = options.headers || ((_options$request2 = options.request) === null || _options$request2 === void 0 ? void 0 : _options$request2.headers());
|
|
155
|
-
const headers = headersObj ? (0,
|
|
148
|
+
const headers = headersObj ? (0, _headers.headersObjectToArray)(headersObj) : undefined;
|
|
156
149
|
let jsonData;
|
|
157
150
|
let formData;
|
|
158
151
|
let multipartData;
|
|
159
152
|
let postDataBuffer;
|
|
160
153
|
if (options.data !== undefined) {
|
|
161
|
-
if ((0,
|
|
154
|
+
if ((0, _rtti.isString)(options.data)) {
|
|
162
155
|
if (isJsonContentType(headers)) jsonData = isJsonParsable(options.data) ? options.data : JSON.stringify(options.data);else postDataBuffer = Buffer.from(options.data, 'utf8');
|
|
163
156
|
} else if (Buffer.isBuffer(options.data)) {
|
|
164
157
|
postDataBuffer = options.data;
|
|
@@ -185,7 +178,7 @@ class APIRequestContext extends _channelOwner.ChannelOwner {
|
|
|
185
178
|
if (globalThis.FormData && options.multipart instanceof FormData) {
|
|
186
179
|
const form = options.multipart;
|
|
187
180
|
for (const [name, value] of form.entries()) {
|
|
188
|
-
if ((0,
|
|
181
|
+
if ((0, _rtti.isString)(value)) {
|
|
189
182
|
multipartData.push({
|
|
190
183
|
name,
|
|
191
184
|
value
|
|
@@ -204,7 +197,7 @@ class APIRequestContext extends _channelOwner.ChannelOwner {
|
|
|
204
197
|
}
|
|
205
198
|
} else {
|
|
206
199
|
// Convert file-like values to ServerFilePayload structs.
|
|
207
|
-
for (const [name, value] of Object.entries(options.multipart)) multipartData.push(await toFormField(name, value));
|
|
200
|
+
for (const [name, value] of Object.entries(options.multipart)) multipartData.push(await toFormField(this._platform, name, value));
|
|
208
201
|
}
|
|
209
202
|
}
|
|
210
203
|
if (postDataBuffer === undefined && jsonData === undefined && formData === undefined && multipartData === undefined) postDataBuffer = ((_options$request3 = options.request) === null || _options$request3 === void 0 ? void 0 : _options$request3.postDataBuffer()) || undefined;
|
|
@@ -232,16 +225,19 @@ class APIRequestContext extends _channelOwner.ChannelOwner {
|
|
|
232
225
|
});
|
|
233
226
|
}
|
|
234
227
|
async storageState(options = {}) {
|
|
235
|
-
const state = await this._channel.storageState(
|
|
228
|
+
const state = await this._channel.storageState({
|
|
229
|
+
indexedDB: options.indexedDB
|
|
230
|
+
});
|
|
236
231
|
if (options.path) {
|
|
237
|
-
await (0, _fileUtils.mkdirIfNeeded)(options.path);
|
|
238
|
-
await
|
|
232
|
+
await (0, _fileUtils.mkdirIfNeeded)(this._platform, options.path);
|
|
233
|
+
await this._platform.fs().promises.writeFile(options.path, JSON.stringify(state, undefined, 2), 'utf8');
|
|
239
234
|
}
|
|
240
235
|
return state;
|
|
241
236
|
}
|
|
242
237
|
}
|
|
243
238
|
exports.APIRequestContext = APIRequestContext;
|
|
244
|
-
async function toFormField(name, value) {
|
|
239
|
+
async function toFormField(platform, name, value) {
|
|
240
|
+
const typeOfValue = typeof value;
|
|
245
241
|
if (isFilePayload(value)) {
|
|
246
242
|
const payload = value;
|
|
247
243
|
if (!Buffer.isBuffer(payload.buffer)) throw new Error(`Unexpected buffer type of 'data.${name}'`);
|
|
@@ -249,15 +245,15 @@ async function toFormField(name, value) {
|
|
|
249
245
|
name,
|
|
250
246
|
file: filePayloadToJson(payload)
|
|
251
247
|
};
|
|
252
|
-
} else if (
|
|
248
|
+
} else if (typeOfValue === 'string' || typeOfValue === 'number' || typeOfValue === 'boolean') {
|
|
253
249
|
return {
|
|
254
250
|
name,
|
|
255
|
-
|
|
251
|
+
value: String(value)
|
|
256
252
|
};
|
|
257
253
|
} else {
|
|
258
254
|
return {
|
|
259
255
|
name,
|
|
260
|
-
|
|
256
|
+
file: await readStreamToJson(platform, value)
|
|
261
257
|
};
|
|
262
258
|
}
|
|
263
259
|
}
|
|
@@ -270,8 +266,6 @@ function isJsonParsable(value) {
|
|
|
270
266
|
if (e instanceof SyntaxError) return false;else throw e;
|
|
271
267
|
}
|
|
272
268
|
}
|
|
273
|
-
_Symbol$asyncDispose2 = Symbol.asyncDispose;
|
|
274
|
-
_util$inspect$custom = util.inspect.custom;
|
|
275
269
|
class APIResponse {
|
|
276
270
|
constructor(context, initializer) {
|
|
277
271
|
this._initializer = void 0;
|
|
@@ -280,6 +274,7 @@ class APIResponse {
|
|
|
280
274
|
this._request = context;
|
|
281
275
|
this._initializer = initializer;
|
|
282
276
|
this._headers = new _network.RawHeaders(this._initializer.headers);
|
|
277
|
+
if (context._platform.inspectCustom) this[context._platform.inspectCustom] = () => this._inspect();
|
|
283
278
|
}
|
|
284
279
|
ok() {
|
|
285
280
|
return this._initializer.status >= 200 && this._initializer.status <= 299;
|
|
@@ -300,16 +295,18 @@ class APIResponse {
|
|
|
300
295
|
return this._headers.headersArray();
|
|
301
296
|
}
|
|
302
297
|
async body() {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
298
|
+
return await this._request._wrapApiCall(async () => {
|
|
299
|
+
try {
|
|
300
|
+
const result = await this._request._channel.fetchResponseBody({
|
|
301
|
+
fetchUid: this._fetchUid()
|
|
302
|
+
});
|
|
303
|
+
if (result.binary === undefined) throw new Error('Response has been disposed');
|
|
304
|
+
return result.binary;
|
|
305
|
+
} catch (e) {
|
|
306
|
+
if ((0, _errors.isTargetClosedError)(e)) throw new Error('Response has been disposed');
|
|
307
|
+
throw e;
|
|
308
|
+
}
|
|
309
|
+
}, true);
|
|
313
310
|
}
|
|
314
311
|
async text() {
|
|
315
312
|
const content = await this.body();
|
|
@@ -319,7 +316,7 @@ class APIResponse {
|
|
|
319
316
|
const content = await this.text();
|
|
320
317
|
return JSON.parse(content);
|
|
321
318
|
}
|
|
322
|
-
async [
|
|
319
|
+
async [Symbol.asyncDispose]() {
|
|
323
320
|
await this.dispose();
|
|
324
321
|
}
|
|
325
322
|
async dispose() {
|
|
@@ -327,7 +324,7 @@ class APIResponse {
|
|
|
327
324
|
fetchUid: this._fetchUid()
|
|
328
325
|
});
|
|
329
326
|
}
|
|
330
|
-
|
|
327
|
+
_inspect() {
|
|
331
328
|
const headers = this.headersArray().map(({
|
|
332
329
|
name,
|
|
333
330
|
value
|
|
@@ -354,7 +351,7 @@ function filePayloadToJson(payload) {
|
|
|
354
351
|
buffer: payload.buffer
|
|
355
352
|
};
|
|
356
353
|
}
|
|
357
|
-
async function readStreamToJson(stream) {
|
|
354
|
+
async function readStreamToJson(platform, stream) {
|
|
358
355
|
const buffer = await new Promise((resolve, reject) => {
|
|
359
356
|
const chunks = [];
|
|
360
357
|
stream.on('data', chunk => chunks.push(chunk));
|
|
@@ -363,7 +360,7 @@ async function readStreamToJson(stream) {
|
|
|
363
360
|
});
|
|
364
361
|
const streamPath = Buffer.isBuffer(stream.path) ? stream.path.toString('utf8') : stream.path;
|
|
365
362
|
return {
|
|
366
|
-
name:
|
|
363
|
+
name: platform.path().basename(streamPath),
|
|
367
364
|
buffer
|
|
368
365
|
};
|
|
369
366
|
}
|
|
@@ -380,10 +377,12 @@ function isJsonContentType(headers) {
|
|
|
380
377
|
function objectToArray(map) {
|
|
381
378
|
if (!map) return undefined;
|
|
382
379
|
const result = [];
|
|
383
|
-
for (const [name, value] of Object.entries(map))
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
380
|
+
for (const [name, value] of Object.entries(map)) {
|
|
381
|
+
if (value !== undefined) result.push({
|
|
382
|
+
name,
|
|
383
|
+
value: String(value)
|
|
384
|
+
});
|
|
385
|
+
}
|
|
387
386
|
return result;
|
|
388
387
|
}
|
|
389
388
|
function isFilePayload(value) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fileUploadSizeLimit = void 0;
|
|
7
|
+
exports.mkdirIfNeeded = mkdirIfNeeded;
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) Microsoft Corporation.
|
|
10
|
+
*
|
|
11
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License.
|
|
13
|
+
* You may obtain a copy of the License at
|
|
14
|
+
*
|
|
15
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
19
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
20
|
+
* See the License for the specific language governing permissions and
|
|
21
|
+
* limitations under the License.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// Keep in sync with the server.
|
|
25
|
+
const fileUploadSizeLimit = exports.fileUploadSizeLimit = 50 * 1024 * 1024;
|
|
26
|
+
async function mkdirIfNeeded(platform, filePath) {
|
|
27
|
+
// This will harmlessly throw on windows if the dirname is the root directory.
|
|
28
|
+
await platform.fs().promises.mkdir(platform.path().dirname(filePath), {
|
|
29
|
+
recursive: true
|
|
30
|
+
}).catch(() => {});
|
|
31
|
+
}
|
package/lib/client/frame.js
CHANGED
|
@@ -5,22 +5,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Frame = void 0;
|
|
7
7
|
exports.verifyLoadState = verifyLoadState;
|
|
8
|
-
var
|
|
8
|
+
var _eventEmitter = require("./eventEmitter");
|
|
9
9
|
var _channelOwner = require("./channelOwner");
|
|
10
|
-
var
|
|
11
|
-
var _locatorUtils = require("../utils/isomorphic/locatorUtils");
|
|
10
|
+
var _clientHelper = require("./clientHelper");
|
|
12
11
|
var _elementHandle = require("./elementHandle");
|
|
12
|
+
var _events = require("./events");
|
|
13
13
|
var _jsHandle = require("./jsHandle");
|
|
14
|
-
var
|
|
14
|
+
var _locator = require("./locator");
|
|
15
15
|
var network = _interopRequireWildcard(require("./network"));
|
|
16
|
-
var _events = require("events");
|
|
17
|
-
var _waiter = require("./waiter");
|
|
18
|
-
var _events2 = require("./events");
|
|
19
16
|
var _types = require("./types");
|
|
20
|
-
var
|
|
17
|
+
var _waiter = require("./waiter");
|
|
18
|
+
var _assert = require("../utils/isomorphic/assert");
|
|
19
|
+
var _locatorUtils = require("../utils/isomorphic/locatorUtils");
|
|
20
|
+
var _urlMatch = require("../utils/isomorphic/urlMatch");
|
|
21
21
|
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); }
|
|
22
|
-
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 &&
|
|
23
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
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 && {}.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; }
|
|
24
23
|
/**
|
|
25
24
|
* Copyright 2017 Google Inc. All rights reserved.
|
|
26
25
|
* Modifications copyright (c) Microsoft Corporation.
|
|
@@ -55,7 +54,7 @@ class Frame extends _channelOwner.ChannelOwner {
|
|
|
55
54
|
this._detached = false;
|
|
56
55
|
this._childFrames = new Set();
|
|
57
56
|
this._page = void 0;
|
|
58
|
-
this._eventEmitter = new
|
|
57
|
+
this._eventEmitter = new _eventEmitter.EventEmitter(parent._platform);
|
|
59
58
|
this._eventEmitter.setMaxListeners(0);
|
|
60
59
|
this._parentFrame = Frame.fromNullable(initializer.parentFrame);
|
|
61
60
|
if (this._parentFrame) this._parentFrame._childFrames.add(this);
|
|
@@ -68,14 +67,14 @@ class Frame extends _channelOwner.ChannelOwner {
|
|
|
68
67
|
this._eventEmitter.emit('loadstate', event.add);
|
|
69
68
|
}
|
|
70
69
|
if (event.remove) this._loadStates.delete(event.remove);
|
|
71
|
-
if (!this._parentFrame && event.add === 'load' && this._page) this._page.emit(
|
|
72
|
-
if (!this._parentFrame && event.add === 'domcontentloaded' && this._page) this._page.emit(
|
|
70
|
+
if (!this._parentFrame && event.add === 'load' && this._page) this._page.emit(_events.Events.Page.Load, this._page);
|
|
71
|
+
if (!this._parentFrame && event.add === 'domcontentloaded' && this._page) this._page.emit(_events.Events.Page.DOMContentLoaded, this._page);
|
|
73
72
|
});
|
|
74
73
|
this._channel.on('navigated', event => {
|
|
75
74
|
this._url = event.url;
|
|
76
75
|
this._name = event.name;
|
|
77
76
|
this._eventEmitter.emit('navigated', event);
|
|
78
|
-
if (!event.error && this._page) this._page.emit(
|
|
77
|
+
if (!event.error && this._page) this._page.emit(_events.Events.Page.FrameNavigated, this);
|
|
79
78
|
});
|
|
80
79
|
}
|
|
81
80
|
page() {
|
|
@@ -92,9 +91,9 @@ class Frame extends _channelOwner.ChannelOwner {
|
|
|
92
91
|
_setupNavigationWaiter(options) {
|
|
93
92
|
const waiter = new _waiter.Waiter(this._page, '');
|
|
94
93
|
if (this._page.isClosed()) waiter.rejectImmediately(this._page._closeErrorWithReason());
|
|
95
|
-
waiter.rejectOnEvent(this._page,
|
|
96
|
-
waiter.rejectOnEvent(this._page,
|
|
97
|
-
waiter.rejectOnEvent(this._page,
|
|
94
|
+
waiter.rejectOnEvent(this._page, _events.Events.Page.Close, () => this._page._closeErrorWithReason());
|
|
95
|
+
waiter.rejectOnEvent(this._page, _events.Events.Page.Crash, new Error('Navigation failed because page crashed!'));
|
|
96
|
+
waiter.rejectOnEvent(this._page, _events.Events.Page.FrameDetached, new Error('Navigating frame was detached!'), frame => frame === this);
|
|
98
97
|
const timeout = this._page._timeoutSettings.navigationTimeout(options);
|
|
99
98
|
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded.`);
|
|
100
99
|
return waiter;
|
|
@@ -110,7 +109,7 @@ class Frame extends _channelOwner.ChannelOwner {
|
|
|
110
109
|
// Any failed navigation results in a rejection.
|
|
111
110
|
if (event.error) return true;
|
|
112
111
|
waiter.log(` navigated to "${event.url}"`);
|
|
113
|
-
return (0,
|
|
112
|
+
return (0, _urlMatch.urlMatches)((_this$_page = this._page) === null || _this$_page === void 0 ? void 0 : _this$_page.context()._options.baseURL, event.url, options.url);
|
|
114
113
|
});
|
|
115
114
|
if (navigatedEvent.error) {
|
|
116
115
|
const e = new Error(navigatedEvent.error);
|
|
@@ -146,7 +145,7 @@ class Frame extends _channelOwner.ChannelOwner {
|
|
|
146
145
|
}
|
|
147
146
|
async waitForURL(url, options = {}) {
|
|
148
147
|
var _this$_page2;
|
|
149
|
-
if ((0,
|
|
148
|
+
if ((0, _urlMatch.urlMatches)((_this$_page2 = this._page) === null || _this$_page2 === void 0 ? void 0 : _this$_page2.context()._options.baseURL, this.url(), url)) return await this.waitForLoadState(options.waitUntil, options);
|
|
150
149
|
await this.waitForNavigation({
|
|
151
150
|
url,
|
|
152
151
|
...options
|
|
@@ -155,21 +154,23 @@ class Frame extends _channelOwner.ChannelOwner {
|
|
|
155
154
|
async frameElement() {
|
|
156
155
|
return _elementHandle.ElementHandle.from((await this._channel.frameElement()).element);
|
|
157
156
|
}
|
|
158
|
-
async evaluateHandle(pageFunction, arg) {
|
|
159
|
-
(0, _jsHandle.assertMaxArguments)(arguments.length,
|
|
157
|
+
async evaluateHandle(pageFunction, arg, isolatedContext = true) {
|
|
158
|
+
(0, _jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
160
159
|
const result = await this._channel.evaluateExpressionHandle({
|
|
161
160
|
expression: String(pageFunction),
|
|
162
161
|
isFunction: typeof pageFunction === 'function',
|
|
163
|
-
arg: (0, _jsHandle.serializeArgument)(arg)
|
|
162
|
+
arg: (0, _jsHandle.serializeArgument)(arg),
|
|
163
|
+
isolatedContext: isolatedContext
|
|
164
164
|
});
|
|
165
165
|
return _jsHandle.JSHandle.from(result.handle);
|
|
166
166
|
}
|
|
167
|
-
async evaluate(pageFunction, arg) {
|
|
168
|
-
(0, _jsHandle.assertMaxArguments)(arguments.length,
|
|
167
|
+
async evaluate(pageFunction, arg, isolatedContext = true) {
|
|
168
|
+
(0, _jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
169
169
|
const result = await this._channel.evaluateExpression({
|
|
170
170
|
expression: String(pageFunction),
|
|
171
171
|
isFunction: typeof pageFunction === 'function',
|
|
172
|
-
arg: (0, _jsHandle.serializeArgument)(arg)
|
|
172
|
+
arg: (0, _jsHandle.serializeArgument)(arg),
|
|
173
|
+
isolatedContext: isolatedContext
|
|
173
174
|
});
|
|
174
175
|
return (0, _jsHandle.parseResult)(result.value);
|
|
175
176
|
}
|
|
@@ -268,7 +269,7 @@ class Frame extends _channelOwner.ChannelOwner {
|
|
|
268
269
|
...options
|
|
269
270
|
};
|
|
270
271
|
if (copy.path) {
|
|
271
|
-
copy.content = (await
|
|
272
|
+
copy.content = (await this._platform.fs().promises.readFile(copy.path)).toString();
|
|
272
273
|
copy.content = (0, _clientHelper.addSourceUrlToScript)(copy.content, copy.path);
|
|
273
274
|
}
|
|
274
275
|
return _elementHandle.ElementHandle.from((await this._channel.addScriptTag({
|
|
@@ -280,7 +281,7 @@ class Frame extends _channelOwner.ChannelOwner {
|
|
|
280
281
|
...options
|
|
281
282
|
};
|
|
282
283
|
if (copy.path) {
|
|
283
|
-
copy.content = (await
|
|
284
|
+
copy.content = (await this._platform.fs().promises.readFile(copy.path)).toString();
|
|
284
285
|
copy.content += '/*# sourceURL=' + copy.path.replace(/\n/g, '') + '*/';
|
|
285
286
|
}
|
|
286
287
|
return _elementHandle.ElementHandle.from((await this._channel.addStyleTag({
|
|
@@ -440,7 +441,7 @@ class Frame extends _channelOwner.ChannelOwner {
|
|
|
440
441
|
})).values;
|
|
441
442
|
}
|
|
442
443
|
async setInputFiles(selector, files, options = {}) {
|
|
443
|
-
const converted = await (0, _elementHandle.convertInputFiles)(files, this.page().context());
|
|
444
|
+
const converted = await (0, _elementHandle.convertInputFiles)(this._platform, files, this.page().context());
|
|
444
445
|
await this._channel.setInputFiles({
|
|
445
446
|
selector,
|
|
446
447
|
...converted,
|
|
@@ -482,7 +483,7 @@ class Frame extends _channelOwner.ChannelOwner {
|
|
|
482
483
|
});
|
|
483
484
|
}
|
|
484
485
|
async waitForFunction(pageFunction, arg, options = {}) {
|
|
485
|
-
if (typeof options.polling === 'string') (0,
|
|
486
|
+
if (typeof options.polling === 'string') (0, _assert.assert)(options.polling === 'raf', 'Unknown polling option: ' + options.polling);
|
|
486
487
|
const result = await this._channel.waitForFunction({
|
|
487
488
|
...options,
|
|
488
489
|
pollingInterval: options.polling === 'raf' ? undefined : options.polling,
|
package/lib/client/harRouter.js
CHANGED
|
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.HarRouter = void 0;
|
|
7
|
-
var _debugLogger = require("../utils/debugLogger");
|
|
8
|
-
let _Symbol$asyncDispose;
|
|
9
7
|
/**
|
|
10
8
|
* Copyright (c) Microsoft Corporation.
|
|
11
9
|
*
|
|
@@ -21,13 +19,13 @@ let _Symbol$asyncDispose;
|
|
|
21
19
|
* See the License for the specific language governing permissions and
|
|
22
20
|
* limitations under the License.
|
|
23
21
|
*/
|
|
24
|
-
|
|
22
|
+
|
|
25
23
|
class HarRouter {
|
|
26
24
|
static async create(localUtils, file, notFoundAction, options) {
|
|
27
25
|
const {
|
|
28
26
|
harId,
|
|
29
27
|
error
|
|
30
|
-
} = await localUtils.
|
|
28
|
+
} = await localUtils.harOpen({
|
|
31
29
|
file
|
|
32
30
|
});
|
|
33
31
|
if (error) throw new Error(error);
|
|
@@ -45,7 +43,7 @@ class HarRouter {
|
|
|
45
43
|
}
|
|
46
44
|
async _handle(route) {
|
|
47
45
|
const request = route.request();
|
|
48
|
-
const response = await this._localUtils.
|
|
46
|
+
const response = await this._localUtils.harLookup({
|
|
49
47
|
harId: this._harId,
|
|
50
48
|
url: request.url(),
|
|
51
49
|
method: request.method(),
|
|
@@ -54,7 +52,7 @@ class HarRouter {
|
|
|
54
52
|
isNavigationRequest: request.isNavigationRequest()
|
|
55
53
|
});
|
|
56
54
|
if (response.action === 'redirect') {
|
|
57
|
-
|
|
55
|
+
route._platform.log('api', `HAR: ${route.request().url()} redirected to ${response.redirectURL}`);
|
|
58
56
|
await route._redirectNavigationRequest(response.redirectURL);
|
|
59
57
|
return;
|
|
60
58
|
}
|
|
@@ -72,7 +70,7 @@ class HarRouter {
|
|
|
72
70
|
});
|
|
73
71
|
return;
|
|
74
72
|
}
|
|
75
|
-
if (response.action === 'error')
|
|
73
|
+
if (response.action === 'error') route._platform.log('api', 'HAR: ' + response.message);
|
|
76
74
|
// Report the error, but fall through to the default handler.
|
|
77
75
|
|
|
78
76
|
if (this._notFoundAction === 'abort') {
|
|
@@ -87,11 +85,11 @@ class HarRouter {
|
|
|
87
85
|
async addPageRoute(page) {
|
|
88
86
|
await page.route(this._options.urlMatch || '**/*', route => this._handle(route));
|
|
89
87
|
}
|
|
90
|
-
async [
|
|
88
|
+
async [Symbol.asyncDispose]() {
|
|
91
89
|
await this.dispose();
|
|
92
90
|
}
|
|
93
91
|
dispose() {
|
|
94
|
-
this._localUtils.
|
|
92
|
+
this._localUtils.harClose({
|
|
95
93
|
harId: this._harId
|
|
96
94
|
}).catch(() => {});
|
|
97
95
|
}
|
package/lib/client/jsHandle.js
CHANGED
|
@@ -8,9 +8,8 @@ exports.assertMaxArguments = assertMaxArguments;
|
|
|
8
8
|
exports.parseResult = parseResult;
|
|
9
9
|
exports.serializeArgument = serializeArgument;
|
|
10
10
|
var _channelOwner = require("./channelOwner");
|
|
11
|
-
var _serializers = require("../protocol/serializers");
|
|
12
11
|
var _errors = require("./errors");
|
|
13
|
-
|
|
12
|
+
var _serializers = require("../protocol/serializers");
|
|
14
13
|
/**
|
|
15
14
|
* Copyright (c) Microsoft Corporation.
|
|
16
15
|
*
|
|
@@ -26,7 +25,7 @@ let _Symbol$asyncDispose;
|
|
|
26
25
|
* See the License for the specific language governing permissions and
|
|
27
26
|
* limitations under the License.
|
|
28
27
|
*/
|
|
29
|
-
|
|
28
|
+
|
|
30
29
|
class JSHandle extends _channelOwner.ChannelOwner {
|
|
31
30
|
static from(handle) {
|
|
32
31
|
return handle._object;
|
|
@@ -75,7 +74,7 @@ class JSHandle extends _channelOwner.ChannelOwner {
|
|
|
75
74
|
asElement() {
|
|
76
75
|
return null;
|
|
77
76
|
}
|
|
78
|
-
async [
|
|
77
|
+
async [Symbol.asyncDispose]() {
|
|
79
78
|
await this.dispose();
|
|
80
79
|
}
|
|
81
80
|
async dispose() {
|
package/lib/client/localUtils.js
CHANGED
|
@@ -32,5 +32,29 @@ class LocalUtils extends _channelOwner.ChannelOwner {
|
|
|
32
32
|
descriptor
|
|
33
33
|
} of initializer.deviceDescriptors) this.devices[name] = descriptor;
|
|
34
34
|
}
|
|
35
|
+
async zip(params) {
|
|
36
|
+
return await this._channel.zip(params);
|
|
37
|
+
}
|
|
38
|
+
async harOpen(params) {
|
|
39
|
+
return await this._channel.harOpen(params);
|
|
40
|
+
}
|
|
41
|
+
async harLookup(params) {
|
|
42
|
+
return await this._channel.harLookup(params);
|
|
43
|
+
}
|
|
44
|
+
async harClose(params) {
|
|
45
|
+
return await this._channel.harClose(params);
|
|
46
|
+
}
|
|
47
|
+
async harUnzip(params) {
|
|
48
|
+
return await this._channel.harUnzip(params);
|
|
49
|
+
}
|
|
50
|
+
async tracingStarted(params) {
|
|
51
|
+
return await this._channel.tracingStarted(params);
|
|
52
|
+
}
|
|
53
|
+
async traceDiscarded(params) {
|
|
54
|
+
return await this._channel.traceDiscarded(params);
|
|
55
|
+
}
|
|
56
|
+
async addStackToTracingNoReply(params) {
|
|
57
|
+
return await this._channel.addStackToTracingNoReply(params);
|
|
58
|
+
}
|
|
35
59
|
}
|
|
36
60
|
exports.LocalUtils = LocalUtils;
|