rebrowser-playwright-core 1.47.100 → 1.49.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/README.md +1 -1
- package/ThirdPartyNotices.txt +70 -384
- package/bin/reinstall_chrome_beta_linux.sh +10 -8
- package/bin/reinstall_chrome_stable_linux.sh +10 -8
- package/bin/reinstall_msedge_beta_linux.sh +11 -9
- package/bin/reinstall_msedge_dev_linux.sh +11 -9
- package/bin/reinstall_msedge_stable_linux.sh +11 -9
- package/browsers.json +24 -12
- package/lib/cli/program.js +49 -19
- package/lib/client/api.js +6 -0
- package/lib/client/browserContext.js +20 -2
- package/lib/client/channelOwner.js +6 -2
- package/lib/client/connection.js +3 -0
- package/lib/client/fetch.js +16 -21
- package/lib/client/jsHandle.js +0 -8
- package/lib/client/localUtils.js +1 -0
- package/lib/client/locator.js +7 -0
- package/lib/client/network.js +180 -17
- package/lib/client/page.js +25 -2
- package/lib/client/playwright.js +6 -3
- package/lib/client/tracing.js +29 -20
- package/lib/client/waiter.js +15 -11
- package/lib/generated/consoleApiSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +7 -0
- package/lib/generated/webSocketMockSource.js +7 -0
- package/lib/protocol/validator.js +103 -17
- package/lib/server/ariaSnapshot.js +33 -0
- package/lib/server/bidi/bidiBrowser.js +23 -8
- package/lib/server/bidi/bidiChromium.js +124 -0
- package/lib/server/bidi/bidiConnection.js +1 -3
- package/lib/server/bidi/bidiExecutionContext.js +0 -6
- package/lib/server/bidi/bidiFirefox.js +15 -21
- package/lib/server/bidi/bidiInput.js +16 -32
- package/lib/server/bidi/bidiNetworkManager.js +39 -5
- package/lib/server/bidi/bidiOverCdp.js +103 -0
- package/lib/server/bidi/bidiPage.js +98 -25
- package/lib/server/bidi/bidiPdf.js +140 -0
- package/lib/server/bidi/third_party/firefoxPrefs.js +221 -0
- package/lib/server/browser.js +13 -2
- package/lib/server/browserContext.js +6 -23
- package/lib/server/browserType.js +43 -12
- package/lib/server/chromium/chromium.js +9 -17
- package/lib/server/chromium/chromiumSwitches.js +3 -1
- package/lib/server/chromium/crBrowser.js +4 -3
- package/lib/server/chromium/crConnection.js +153 -0
- package/lib/server/chromium/crExecutionContext.js +0 -20
- package/lib/server/chromium/crPage.js +13 -7
- package/lib/server/chromium/videoRecorder.js +1 -1
- package/lib/server/codegen/csharp.js +12 -17
- package/lib/server/codegen/java.js +5 -8
- package/lib/server/codegen/javascript.js +29 -7
- package/lib/server/codegen/language.js +14 -2
- package/lib/server/codegen/python.js +13 -17
- package/lib/server/cookieStore.js +73 -0
- package/lib/server/debugController.js +10 -7
- package/lib/server/deviceDescriptorsSource.json +127 -127
- package/lib/server/dialog.js +1 -0
- package/lib/server/dispatchers/androidDispatcher.js +13 -2
- package/lib/server/dispatchers/browserContextDispatcher.js +19 -2
- package/lib/server/dispatchers/debugControllerDispatcher.js +1 -1
- package/lib/server/dispatchers/dispatcher.js +1 -1
- package/lib/server/dispatchers/frameDispatcher.js +8 -1
- package/lib/server/dispatchers/jsHandleDispatcher.js +0 -5
- package/lib/server/dispatchers/pageDispatcher.js +9 -0
- package/lib/server/dispatchers/playwrightDispatcher.js +2 -1
- package/lib/server/dispatchers/tracingDispatcher.js +10 -0
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +189 -0
- package/lib/server/dom.js +79 -36
- package/lib/server/download.js +9 -2
- package/lib/server/fetch.js +105 -96
- package/lib/server/firefox/ffBrowser.js +6 -4
- package/lib/server/firefox/ffExecutionContext.js +0 -15
- package/lib/server/firefox/ffNetworkManager.js +1 -1
- package/lib/server/firefox/ffPage.js +6 -3
- package/lib/server/firefox/firefox.js +2 -13
- package/lib/server/frameSelectors.js +1 -1
- package/lib/server/frames.js +68 -67
- package/lib/server/har/harTracer.js +11 -0
- package/lib/server/index.js +0 -6
- package/lib/server/input.js +0 -1
- package/lib/server/javascript.js +0 -13
- package/lib/server/page.js +53 -9
- package/lib/server/playwright.js +5 -2
- package/lib/server/progress.js +0 -3
- package/lib/server/recorder/contextRecorder.js +33 -50
- package/lib/server/recorder/recorderApp.js +22 -25
- package/lib/server/recorder/recorderCollection.js +68 -79
- package/lib/server/recorder/recorderInTraceViewer.js +144 -0
- package/lib/server/recorder/recorderRunner.js +75 -97
- package/lib/server/recorder/recorderUtils.js +48 -6
- package/lib/server/recorder.js +87 -47
- package/lib/server/registry/index.js +154 -26
- package/lib/server/registry/nativeDeps.js +6 -3
- package/lib/server/socksClientCertificatesInterceptor.js +15 -3
- package/lib/server/trace/recorder/snapshotter.js +2 -12
- package/lib/server/trace/recorder/snapshotterInjected.js +21 -3
- package/lib/server/trace/recorder/tracing.js +127 -17
- package/lib/server/trace/test/inMemorySnapshotter.js +4 -4
- package/lib/server/trace/viewer/traceViewer.js +4 -6
- package/lib/server/webkit/webkit.js +1 -1
- package/lib/server/webkit/wkBrowser.js +8 -7
- package/lib/server/webkit/wkExecutionContext.js +0 -16
- package/lib/server/webkit/wkPage.js +11 -4
- package/lib/utils/comparators.js +12 -30
- package/lib/utils/crypto.js +1 -4
- package/lib/utils/happy-eyeballs.js +13 -0
- package/lib/utils/hostPlatform.js +8 -2
- package/lib/utils/httpServer.js +1 -0
- package/lib/utils/isomorphic/ariaSnapshot.js +267 -0
- package/lib/utils/isomorphic/locatorGenerators.js +30 -21
- package/lib/utils/isomorphic/locatorParser.js +2 -2
- package/lib/utils/isomorphic/recorderUtils.js +227 -0
- package/lib/utils/isomorphic/stringUtils.js +30 -0
- package/lib/utils/isomorphic/urlMatch.js +5 -1
- package/lib/utils/network.js +1 -1
- package/lib/utils/sequence.js +64 -0
- package/lib/utils/stackTrace.js +16 -3
- package/lib/utils/zones.js +32 -23
- package/lib/utilsBundle.js +4 -5
- package/lib/utilsBundleImpl/index.js +190 -33
- package/lib/vite/htmlReport/index.html +19 -16
- package/lib/vite/recorder/assets/codeMirrorModule-AFvV6hAs.js +24 -0
- package/lib/vite/recorder/assets/index-_cTWgVuJ.js +184 -0
- package/lib/vite/recorder/assets/{index-B-MT5gKo.css → index-iA1aAGZg.css} +1 -1
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-KatbITLF.js +24 -0
- package/lib/vite/traceViewer/assets/inspectorTab-DdpLd2bb.js +68 -0
- package/lib/vite/traceViewer/assets/workbench-CdYbzWFD.js +9 -0
- package/lib/vite/traceViewer/embedded.6m3UZh7r.js +2 -0
- package/lib/vite/traceViewer/embedded.html +5 -3
- package/lib/vite/traceViewer/index.WUV-8boJ.js +2 -0
- package/lib/vite/traceViewer/index.html +24 -5
- package/lib/vite/traceViewer/inspectorTab.DEOUW62d.css +1 -0
- package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
- package/lib/vite/traceViewer/recorder.OT2tVHgn.js +2 -0
- package/lib/vite/traceViewer/recorder.html +17 -0
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/uiMode.BZBTyvGn.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +6 -4
- package/lib/vite/traceViewer/{uiMode.D3cNFP6u.css → uiMode.voC1ZiOQ.css} +1 -1
- package/lib/vite/traceViewer/workbench.C-zR9ysA.css +1 -0
- package/package.json +1 -1
- package/types/protocol.d.ts +135 -16
- package/types/types.d.ts +2149 -965
- package/lib/generated/recorderSource.js +0 -7
- package/lib/third_party/diff_match_patch.js +0 -2222
- package/lib/vite/recorder/assets/codeMirrorModule-aW6Vz3gf.js +0 -24
- package/lib/vite/recorder/assets/index-DCpXOVIh.js +0 -47
- package/lib/vite/traceViewer/assets/codeMirrorModule-eFKCUIu2.js +0 -24
- package/lib/vite/traceViewer/assets/workbench-D0cirtfA.js +0 -72
- package/lib/vite/traceViewer/embedded.BkuvsLJp.js +0 -2
- package/lib/vite/traceViewer/index.C968kAiC.js +0 -2
- package/lib/vite/traceViewer/uiMode.BkFnr4V0.js +0 -10
- package/lib/vite/traceViewer/workbench.DjbIuxix.css +0 -1
- /package/lib/server/recorder/{recorderActions.js → recorderFrontend.js} +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RecorderInTraceViewer = void 0;
|
|
7
|
+
var _path = _interopRequireDefault(require("path"));
|
|
8
|
+
var _events = require("events");
|
|
9
|
+
var _traceViewer = require("../trace/viewer/traceViewer");
|
|
10
|
+
var _manualPromise = require("../../utils/manualPromise");
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
/**
|
|
13
|
+
* Copyright (c) Microsoft Corporation.
|
|
14
|
+
*
|
|
15
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License.
|
|
17
|
+
* You may obtain a copy of the License at
|
|
18
|
+
*
|
|
19
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
+
*
|
|
21
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
22
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
23
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
+
* See the License for the specific language governing permissions and
|
|
25
|
+
* limitations under the License.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
class RecorderInTraceViewer extends _events.EventEmitter {
|
|
29
|
+
static factory(context) {
|
|
30
|
+
return async recorder => {
|
|
31
|
+
const transport = new RecorderTransport();
|
|
32
|
+
const trace = _path.default.join(context._browser.options.tracesDir, 'trace');
|
|
33
|
+
const {
|
|
34
|
+
wsEndpointForTest,
|
|
35
|
+
tracePage,
|
|
36
|
+
traceServer
|
|
37
|
+
} = await openApp(trace, {
|
|
38
|
+
transport,
|
|
39
|
+
headless: !context._browser.options.headful
|
|
40
|
+
});
|
|
41
|
+
return new RecorderInTraceViewer(transport, tracePage, traceServer, wsEndpointForTest);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
constructor(transport, tracePage, traceServer, wsEndpointForTest) {
|
|
45
|
+
super();
|
|
46
|
+
this.wsEndpointForTest = void 0;
|
|
47
|
+
this._transport = void 0;
|
|
48
|
+
this._tracePage = void 0;
|
|
49
|
+
this._traceServer = void 0;
|
|
50
|
+
this._transport = transport;
|
|
51
|
+
this._transport.eventSink.resolve(this);
|
|
52
|
+
this._tracePage = tracePage;
|
|
53
|
+
this._traceServer = traceServer;
|
|
54
|
+
this.wsEndpointForTest = wsEndpointForTest;
|
|
55
|
+
this._tracePage.once('close', () => {
|
|
56
|
+
this.close();
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async close() {
|
|
60
|
+
await this._tracePage.context().close({
|
|
61
|
+
reason: 'Recorder window closed'
|
|
62
|
+
});
|
|
63
|
+
await this._traceServer.stop();
|
|
64
|
+
}
|
|
65
|
+
async setPaused(paused) {
|
|
66
|
+
this._transport.deliverEvent('setPaused', {
|
|
67
|
+
paused
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async setMode(mode) {
|
|
71
|
+
this._transport.deliverEvent('setMode', {
|
|
72
|
+
mode
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async setRunningFile(file) {
|
|
76
|
+
this._transport.deliverEvent('setRunningFile', {
|
|
77
|
+
file
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
async elementPicked(elementInfo, userGesture) {
|
|
81
|
+
this._transport.deliverEvent('elementPicked', {
|
|
82
|
+
elementInfo,
|
|
83
|
+
userGesture
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
async updateCallLogs(callLogs) {
|
|
87
|
+
this._transport.deliverEvent('updateCallLogs', {
|
|
88
|
+
callLogs
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
async setSources(sources) {
|
|
92
|
+
this._transport.deliverEvent('setSources', {
|
|
93
|
+
sources
|
|
94
|
+
});
|
|
95
|
+
if (process.env.PWTEST_CLI_IS_UNDER_TEST && sources.length) {
|
|
96
|
+
if (process._didSetSourcesForTest(sources[0].text)) this.close();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async setActions(actions, sources) {
|
|
100
|
+
this._transport.deliverEvent('setActions', {
|
|
101
|
+
actions,
|
|
102
|
+
sources
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.RecorderInTraceViewer = RecorderInTraceViewer;
|
|
107
|
+
async function openApp(trace, options) {
|
|
108
|
+
const traceServer = await (0, _traceViewer.startTraceViewerServer)(options);
|
|
109
|
+
await (0, _traceViewer.installRootRedirect)(traceServer, [trace], {
|
|
110
|
+
...options,
|
|
111
|
+
webApp: 'recorder.html'
|
|
112
|
+
});
|
|
113
|
+
const page = await (0, _traceViewer.openTraceViewerApp)(traceServer.urlPrefix('precise'), 'chromium', options);
|
|
114
|
+
return {
|
|
115
|
+
wsEndpointForTest: page.context()._browser.options.wsEndpoint,
|
|
116
|
+
tracePage: page,
|
|
117
|
+
traceServer
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
class RecorderTransport {
|
|
121
|
+
constructor() {
|
|
122
|
+
this._connected = new _manualPromise.ManualPromise();
|
|
123
|
+
this.eventSink = new _manualPromise.ManualPromise();
|
|
124
|
+
this.sendEvent = void 0;
|
|
125
|
+
this.close = void 0;
|
|
126
|
+
}
|
|
127
|
+
onconnect() {
|
|
128
|
+
this._connected.resolve();
|
|
129
|
+
}
|
|
130
|
+
async dispatch(method, params) {
|
|
131
|
+
const eventSink = await this.eventSink;
|
|
132
|
+
eventSink.emit('event', {
|
|
133
|
+
event: method,
|
|
134
|
+
params
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
onclose() {}
|
|
138
|
+
deliverEvent(method, params) {
|
|
139
|
+
this._connected.then(() => {
|
|
140
|
+
var _this$sendEvent;
|
|
141
|
+
return (_this$sendEvent = this.sendEvent) === null || _this$sendEvent === void 0 ? void 0 : _this$sendEvent.call(this, method, params);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -4,9 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.performAction = performAction;
|
|
7
|
+
exports.toClickOptions = toClickOptions;
|
|
7
8
|
var _utils = require("../../utils");
|
|
8
9
|
var _language = require("../codegen/language");
|
|
9
10
|
var _recorderUtils = require("./recorderUtils");
|
|
11
|
+
var _recorderUtils2 = require("../../utils/isomorphic/recorderUtils");
|
|
10
12
|
/**
|
|
11
13
|
* Copyright (c) Microsoft Corporation.
|
|
12
14
|
*
|
|
@@ -23,125 +25,93 @@ var _recorderUtils = require("./recorderUtils");
|
|
|
23
25
|
* limitations under the License.
|
|
24
26
|
*/
|
|
25
27
|
|
|
26
|
-
async function
|
|
27
|
-
const
|
|
28
|
-
id: `call@${(0, _utils.createGuid)()}`,
|
|
29
|
-
apiName: 'frame.' + action,
|
|
30
|
-
objectId: mainFrame.guid,
|
|
31
|
-
pageId: mainFrame._page.guid,
|
|
32
|
-
frameId: mainFrame.guid,
|
|
33
|
-
startTime: (0, _utils.monotonicTime)(),
|
|
34
|
-
endTime: 0,
|
|
35
|
-
type: 'Frame',
|
|
36
|
-
method: action,
|
|
37
|
-
params,
|
|
38
|
-
log: []
|
|
39
|
-
};
|
|
40
|
-
try {
|
|
41
|
-
await mainFrame.instrumentation.onBeforeCall(mainFrame, callMetadata);
|
|
42
|
-
await cb(callMetadata);
|
|
43
|
-
} catch (e) {
|
|
44
|
-
callMetadata.endTime = (0, _utils.monotonicTime)();
|
|
45
|
-
await mainFrame.instrumentation.onAfterCall(mainFrame, callMetadata);
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
callMetadata.endTime = (0, _utils.monotonicTime)();
|
|
49
|
-
await mainFrame.instrumentation.onAfterCall(mainFrame, callMetadata);
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
async function performAction(pageAliases, actionInContext) {
|
|
53
|
-
var _find;
|
|
54
|
-
const pageAlias = actionInContext.frame.pageAlias;
|
|
55
|
-
const page = (_find = [...pageAliases.entries()].find(([, alias]) => pageAlias === alias)) === null || _find === void 0 ? void 0 : _find[0];
|
|
56
|
-
if (!page) throw new Error('Internal error: page not found');
|
|
57
|
-
const mainFrame = page.mainFrame();
|
|
28
|
+
async function performAction(callMetadata, pageAliases, actionInContext) {
|
|
29
|
+
const mainFrame = (0, _recorderUtils.mainFrameForAction)(pageAliases, actionInContext);
|
|
58
30
|
const {
|
|
59
31
|
action
|
|
60
32
|
} = actionInContext;
|
|
61
33
|
const kActionTimeout = 5000;
|
|
62
|
-
if (action.name === 'navigate')
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
34
|
+
if (action.name === 'navigate') {
|
|
35
|
+
await mainFrame.goto(callMetadata, action.url, {
|
|
36
|
+
timeout: kActionTimeout
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
67
40
|
if (action.name === 'openPage') throw Error('Not reached');
|
|
68
|
-
if (action.name === 'closePage')
|
|
69
|
-
|
|
41
|
+
if (action.name === 'closePage') {
|
|
42
|
+
await mainFrame._page.close(callMetadata);
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const selector = (0, _recorderUtils2.buildFullSelector)(actionInContext.frame.framePath, action.selector);
|
|
70
46
|
if (action.name === 'click') {
|
|
71
|
-
const options =
|
|
72
|
-
|
|
73
|
-
selector
|
|
74
|
-
}, callMetadata => mainFrame.click(callMetadata, selector, {
|
|
47
|
+
const options = toClickOptions(action);
|
|
48
|
+
await mainFrame.click(callMetadata, selector, {
|
|
75
49
|
...options,
|
|
76
50
|
timeout: kActionTimeout,
|
|
77
51
|
strict: true
|
|
78
|
-
})
|
|
52
|
+
});
|
|
53
|
+
return;
|
|
79
54
|
}
|
|
80
55
|
if (action.name === 'press') {
|
|
81
56
|
const modifiers = (0, _language.toKeyboardModifiers)(action.modifiers);
|
|
82
57
|
const shortcut = [...modifiers, action.key].join('+');
|
|
83
|
-
|
|
58
|
+
await mainFrame.press(callMetadata, selector, shortcut, {
|
|
59
|
+
timeout: kActionTimeout,
|
|
60
|
+
strict: true
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (action.name === 'fill') {
|
|
65
|
+
await mainFrame.fill(callMetadata, selector, action.text, {
|
|
66
|
+
timeout: kActionTimeout,
|
|
67
|
+
strict: true
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (action.name === 'setInputFiles') {
|
|
72
|
+
await mainFrame.setInputFiles(callMetadata, selector, {
|
|
84
73
|
selector,
|
|
85
|
-
|
|
86
|
-
}, callMetadata => mainFrame.press(callMetadata, selector, shortcut, {
|
|
74
|
+
payloads: [],
|
|
87
75
|
timeout: kActionTimeout,
|
|
88
76
|
strict: true
|
|
89
|
-
})
|
|
77
|
+
});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (action.name === 'check') {
|
|
81
|
+
await mainFrame.check(callMetadata, selector, {
|
|
82
|
+
timeout: kActionTimeout,
|
|
83
|
+
strict: true
|
|
84
|
+
});
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (action.name === 'uncheck') {
|
|
88
|
+
await mainFrame.uncheck(callMetadata, selector, {
|
|
89
|
+
timeout: kActionTimeout,
|
|
90
|
+
strict: true
|
|
91
|
+
});
|
|
92
|
+
return;
|
|
90
93
|
}
|
|
91
|
-
if (action.name === 'fill') return await innerPerformAction(mainFrame, 'fill', {
|
|
92
|
-
selector,
|
|
93
|
-
text: action.text
|
|
94
|
-
}, callMetadata => mainFrame.fill(callMetadata, selector, action.text, {
|
|
95
|
-
timeout: kActionTimeout,
|
|
96
|
-
strict: true
|
|
97
|
-
}));
|
|
98
|
-
if (action.name === 'setInputFiles') return await innerPerformAction(mainFrame, 'setInputFiles', {
|
|
99
|
-
selector,
|
|
100
|
-
files: action.files
|
|
101
|
-
}, callMetadata => mainFrame.setInputFiles(callMetadata, selector, {
|
|
102
|
-
selector,
|
|
103
|
-
payloads: [],
|
|
104
|
-
timeout: kActionTimeout,
|
|
105
|
-
strict: true
|
|
106
|
-
}));
|
|
107
|
-
if (action.name === 'check') return await innerPerformAction(mainFrame, 'check', {
|
|
108
|
-
selector
|
|
109
|
-
}, callMetadata => mainFrame.check(callMetadata, selector, {
|
|
110
|
-
timeout: kActionTimeout,
|
|
111
|
-
strict: true
|
|
112
|
-
}));
|
|
113
|
-
if (action.name === 'uncheck') return await innerPerformAction(mainFrame, 'uncheck', {
|
|
114
|
-
selector
|
|
115
|
-
}, callMetadata => mainFrame.uncheck(callMetadata, selector, {
|
|
116
|
-
timeout: kActionTimeout,
|
|
117
|
-
strict: true
|
|
118
|
-
}));
|
|
119
94
|
if (action.name === 'select') {
|
|
120
95
|
const values = action.options.map(value => ({
|
|
121
96
|
value
|
|
122
97
|
}));
|
|
123
|
-
|
|
124
|
-
selector,
|
|
125
|
-
values
|
|
126
|
-
}, callMetadata => mainFrame.selectOption(callMetadata, selector, [], values, {
|
|
98
|
+
await mainFrame.selectOption(callMetadata, selector, [], values, {
|
|
127
99
|
timeout: kActionTimeout,
|
|
128
100
|
strict: true
|
|
129
|
-
})
|
|
101
|
+
});
|
|
102
|
+
return;
|
|
130
103
|
}
|
|
131
104
|
if (action.name === 'assertChecked') {
|
|
132
|
-
|
|
133
|
-
selector
|
|
134
|
-
}, callMetadata => mainFrame.expect(callMetadata, selector, {
|
|
105
|
+
await mainFrame.expect(callMetadata, selector, {
|
|
135
106
|
selector,
|
|
136
107
|
expression: 'to.be.checked',
|
|
137
108
|
isNot: !action.checked,
|
|
138
109
|
timeout: kActionTimeout
|
|
139
|
-
})
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
140
112
|
}
|
|
141
113
|
if (action.name === 'assertText') {
|
|
142
|
-
|
|
143
|
-
selector
|
|
144
|
-
}, callMetadata => mainFrame.expect(callMetadata, selector, {
|
|
114
|
+
await mainFrame.expect(callMetadata, selector, {
|
|
145
115
|
selector,
|
|
146
116
|
expression: 'to.have.text',
|
|
147
117
|
expectedText: (0, _utils.serializeExpectedTextValues)([action.text], {
|
|
@@ -150,28 +120,36 @@ async function performAction(pageAliases, actionInContext) {
|
|
|
150
120
|
}),
|
|
151
121
|
isNot: false,
|
|
152
122
|
timeout: kActionTimeout
|
|
153
|
-
})
|
|
123
|
+
});
|
|
124
|
+
return;
|
|
154
125
|
}
|
|
155
126
|
if (action.name === 'assertValue') {
|
|
156
|
-
|
|
157
|
-
selector
|
|
158
|
-
}, callMetadata => mainFrame.expect(callMetadata, selector, {
|
|
127
|
+
await mainFrame.expect(callMetadata, selector, {
|
|
159
128
|
selector,
|
|
160
129
|
expression: 'to.have.value',
|
|
161
130
|
expectedValue: action.value,
|
|
162
131
|
isNot: false,
|
|
163
132
|
timeout: kActionTimeout
|
|
164
|
-
})
|
|
133
|
+
});
|
|
134
|
+
return;
|
|
165
135
|
}
|
|
166
136
|
if (action.name === 'assertVisible') {
|
|
167
|
-
|
|
168
|
-
selector
|
|
169
|
-
}, callMetadata => mainFrame.expect(callMetadata, selector, {
|
|
137
|
+
await mainFrame.expect(callMetadata, selector, {
|
|
170
138
|
selector,
|
|
171
139
|
expression: 'to.be.visible',
|
|
172
140
|
isNot: false,
|
|
173
141
|
timeout: kActionTimeout
|
|
174
|
-
})
|
|
142
|
+
});
|
|
143
|
+
return;
|
|
175
144
|
}
|
|
176
145
|
throw new Error('Internal error: unexpected action ' + action.name);
|
|
146
|
+
}
|
|
147
|
+
function toClickOptions(action) {
|
|
148
|
+
const modifiers = (0, _language.toKeyboardModifiers)(action.modifiers);
|
|
149
|
+
const options = {};
|
|
150
|
+
if (action.button !== 'left') options.button = action.button;
|
|
151
|
+
if (modifiers.length) options.modifiers = modifiers;
|
|
152
|
+
if (action.clickCount > 1) options.clickCount = action.clickCount;
|
|
153
|
+
if (action.position) options.position = action.position;
|
|
154
|
+
return options;
|
|
177
155
|
}
|
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.callMetadataForAction = callMetadataForAction;
|
|
7
|
+
exports.collapseActions = collapseActions;
|
|
7
8
|
exports.frameForAction = frameForAction;
|
|
8
9
|
exports.mainFrameForAction = mainFrameForAction;
|
|
9
10
|
exports.metadataToCallLog = metadataToCallLog;
|
|
11
|
+
var _utils = require("../../utils");
|
|
12
|
+
var _recorderUtils = require("../../utils/isomorphic/recorderUtils");
|
|
10
13
|
/**
|
|
11
14
|
* Copyright (c) Microsoft Corporation.
|
|
12
15
|
*
|
|
@@ -49,14 +52,11 @@ function metadataToCallLog(metadata, status) {
|
|
|
49
52
|
};
|
|
50
53
|
return callLog;
|
|
51
54
|
}
|
|
52
|
-
function buildFullSelector(framePath, selector) {
|
|
53
|
-
return [...framePath, selector].join(' >> internal:control=enter-frame >> ');
|
|
54
|
-
}
|
|
55
55
|
function mainFrameForAction(pageAliases, actionInContext) {
|
|
56
56
|
var _find;
|
|
57
57
|
const pageAlias = actionInContext.frame.pageAlias;
|
|
58
58
|
const page = (_find = [...pageAliases.entries()].find(([, alias]) => pageAlias === alias)) === null || _find === void 0 ? void 0 : _find[0];
|
|
59
|
-
if (!page) throw new Error(
|
|
59
|
+
if (!page) throw new Error(`Internal error: page ${pageAlias} not found in [${[...pageAliases.values()]}]`);
|
|
60
60
|
return page.mainFrame();
|
|
61
61
|
}
|
|
62
62
|
async function frameForAction(pageAliases, actionInContext, action) {
|
|
@@ -64,8 +64,50 @@ async function frameForAction(pageAliases, actionInContext, action) {
|
|
|
64
64
|
const pageAlias = actionInContext.frame.pageAlias;
|
|
65
65
|
const page = (_find2 = [...pageAliases.entries()].find(([, alias]) => pageAlias === alias)) === null || _find2 === void 0 ? void 0 : _find2[0];
|
|
66
66
|
if (!page) throw new Error('Internal error: page not found');
|
|
67
|
-
const fullSelector = buildFullSelector(actionInContext.frame.framePath, action.selector);
|
|
67
|
+
const fullSelector = (0, _recorderUtils.buildFullSelector)(actionInContext.frame.framePath, action.selector);
|
|
68
68
|
const result = await page.mainFrame().selectors.resolveFrameForSelector(fullSelector);
|
|
69
69
|
if (!result) throw new Error('Internal error: frame not found');
|
|
70
70
|
return result.frame;
|
|
71
|
+
}
|
|
72
|
+
function callMetadataForAction(pageAliases, actionInContext) {
|
|
73
|
+
const mainFrame = mainFrameForAction(pageAliases, actionInContext);
|
|
74
|
+
const {
|
|
75
|
+
method,
|
|
76
|
+
apiName,
|
|
77
|
+
params
|
|
78
|
+
} = (0, _recorderUtils.traceParamsForAction)(actionInContext);
|
|
79
|
+
const callMetadata = {
|
|
80
|
+
id: `call@${(0, _utils.createGuid)()}`,
|
|
81
|
+
apiName,
|
|
82
|
+
objectId: mainFrame.guid,
|
|
83
|
+
pageId: mainFrame._page.guid,
|
|
84
|
+
frameId: mainFrame.guid,
|
|
85
|
+
startTime: actionInContext.startTime,
|
|
86
|
+
endTime: 0,
|
|
87
|
+
type: 'Frame',
|
|
88
|
+
method,
|
|
89
|
+
params,
|
|
90
|
+
log: []
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
callMetadata,
|
|
94
|
+
mainFrame
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function collapseActions(actions) {
|
|
98
|
+
const result = [];
|
|
99
|
+
for (const action of actions) {
|
|
100
|
+
const lastAction = result[result.length - 1];
|
|
101
|
+
const isSameAction = lastAction && lastAction.action.name === action.action.name && lastAction.frame.pageAlias === action.frame.pageAlias && lastAction.frame.framePath.join('|') === action.frame.framePath.join('|');
|
|
102
|
+
const isSameSelector = lastAction && 'selector' in lastAction.action && 'selector' in action.action && action.action.selector === lastAction.action.selector;
|
|
103
|
+
const shouldMerge = isSameAction && (action.action.name === 'navigate' || action.action.name === 'fill' && isSameSelector);
|
|
104
|
+
if (!shouldMerge) {
|
|
105
|
+
result.push(action);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const startTime = result[result.length - 1].startTime;
|
|
109
|
+
result[result.length - 1] = action;
|
|
110
|
+
result[result.length - 1].startTime = startTime;
|
|
111
|
+
}
|
|
112
|
+
return result;
|
|
71
113
|
}
|