rebrowser-playwright-core 1.48.2 → 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 +2 -2
- 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 +19 -11
- package/lib/cli/program.js +23 -5
- package/lib/client/channelOwner.js +2 -2
- package/lib/client/locator.js +7 -0
- package/lib/client/network.js +5 -0
- package/lib/client/page.js +4 -2
- package/lib/client/tracing.js +13 -0
- 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 +1 -1
- package/lib/generated/webSocketMockSource.js +1 -1
- package/lib/protocol/validator.js +23 -3
- package/lib/server/ariaSnapshot.js +33 -0
- package/lib/server/bidi/bidiChromium.js +1 -1
- package/lib/server/bidi/bidiConnection.js +0 -2
- package/lib/server/bidi/bidiExecutionContext.js +0 -3
- package/lib/server/browserType.js +4 -1
- package/lib/server/chromium/chromium.js +6 -2
- package/lib/server/chromium/crConnection.js +153 -0
- package/lib/server/chromium/crExecutionContext.js +0 -13
- package/lib/server/chromium/crPage.js +6 -10
- package/lib/server/codegen/csharp.js +11 -16
- package/lib/server/codegen/java.js +4 -7
- package/lib/server/codegen/javascript.js +28 -6
- package/lib/server/codegen/python.js +12 -16
- package/lib/server/debugController.js +8 -5
- package/lib/server/deviceDescriptorsSource.json +127 -127
- package/lib/server/dispatchers/androidDispatcher.js +13 -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/tracingDispatcher.js +10 -0
- package/lib/server/dom.js +79 -36
- package/lib/server/fetch.js +30 -17
- package/lib/server/firefox/ffExecutionContext.js +0 -12
- package/lib/server/firefox/ffNetworkManager.js +1 -1
- package/lib/server/frames.js +66 -196
- package/lib/server/index.js +0 -6
- package/lib/server/javascript.js +0 -6
- package/lib/server/page.js +48 -8
- package/lib/server/progress.js +0 -3
- package/lib/server/recorder/recorderApp.js +6 -15
- package/lib/server/recorder/recorderInTraceViewer.js +3 -3
- package/lib/server/recorder/recorderUtils.js +2 -1
- package/lib/server/recorder.js +66 -31
- package/lib/server/registry/index.js +70 -23
- package/lib/server/registry/nativeDeps.js +6 -3
- package/lib/server/socksClientCertificatesInterceptor.js +1 -1
- package/lib/server/trace/recorder/snapshotter.js +1 -12
- package/lib/server/trace/recorder/snapshotterInjected.js +19 -1
- package/lib/server/trace/recorder/tracing.js +69 -15
- package/lib/server/trace/test/inMemorySnapshotter.js +3 -3
- package/lib/server/trace/viewer/traceViewer.js +2 -1
- package/lib/server/webkit/wkBrowser.js +2 -2
- package/lib/server/webkit/wkExecutionContext.js +0 -13
- package/lib/server/webkit/wkPage.js +4 -0
- package/lib/utils/comparators.js +12 -30
- package/lib/utils/crypto.js +1 -4
- package/lib/utils/hostPlatform.js +6 -0
- package/lib/utils/isomorphic/ariaSnapshot.js +267 -0
- package/lib/utils/isomorphic/locatorGenerators.js +23 -5
- package/lib/utils/isomorphic/recorderUtils.js +36 -4
- 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-BW-aOBcL.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.BlHoW5LY.js → embedded.6m3UZh7r.js} +1 -1
- package/lib/vite/traceViewer/embedded.html +5 -5
- package/lib/vite/traceViewer/{index.DaWVfou1.js → index.WUV-8boJ.js} +1 -1
- package/lib/vite/traceViewer/index.html +24 -7
- package/lib/vite/traceViewer/{inspectorTab.DLjBDrQR.css → inspectorTab.DEOUW62d.css} +1 -1
- package/lib/vite/traceViewer/recorder.OT2tVHgn.js +2 -0
- package/lib/vite/traceViewer/recorder.html +3 -3
- 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 -6
- package/lib/vite/traceViewer/{uiMode.CAYqod-m.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 +58 -10
- package/types/types.d.ts +116 -20
- package/lib/third_party/diff_match_patch.js +0 -2222
- package/lib/vite/recorder/assets/codeMirrorModule-baozm8ur.js +0 -24
- package/lib/vite/recorder/assets/index-2ElAIWFB.js +0 -42
- package/lib/vite/traceViewer/assets/codeMirrorModule-Bh1rfd2w.js +0 -24
- package/lib/vite/traceViewer/assets/inspectorTab-7GHnKvSD.js +0 -64
- package/lib/vite/traceViewer/assets/workbench-DPQnTHYP.js +0 -9
- package/lib/vite/traceViewer/recorder.C4zxcvd2.js +0 -2
- package/lib/vite/traceViewer/uiMode.mTXWniJb.js +0 -5
- package/lib/vite/traceViewer/workbench.D3JVcA9K.css +0 -1
package/lib/server/frames.js
CHANGED
|
@@ -22,7 +22,6 @@ var _selectorParser = require("../utils/isomorphic/selectorParser");
|
|
|
22
22
|
var _frameSelectors = require("./frameSelectors");
|
|
23
23
|
var _errors = require("./errors");
|
|
24
24
|
var _fileUploadUtils = require("./fileUploadUtils");
|
|
25
|
-
var _crExecutionContext = require("./chromium/crExecutionContext");
|
|
26
25
|
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); }
|
|
27
26
|
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; }
|
|
28
27
|
/**
|
|
@@ -61,7 +60,6 @@ class FrameManager {
|
|
|
61
60
|
this._webSockets = new Map();
|
|
62
61
|
this._openedDialogs = new Set();
|
|
63
62
|
this._closeAllOpeningDialogs = false;
|
|
64
|
-
this.__re__contexts = undefined;
|
|
65
63
|
this._page = page;
|
|
66
64
|
this._mainFrame = undefined;
|
|
67
65
|
}
|
|
@@ -197,6 +195,11 @@ class FrameManager {
|
|
|
197
195
|
frameCommittedSameDocumentNavigation(frameId, url) {
|
|
198
196
|
const frame = this._frames.get(frameId);
|
|
199
197
|
if (!frame) return;
|
|
198
|
+
const pending = frame.pendingDocument();
|
|
199
|
+
if (pending && pending.documentId === undefined && pending.request === undefined) {
|
|
200
|
+
// WebKit has notified about the same-document navigation being requested, so clear it.
|
|
201
|
+
frame.setPendingDocument(undefined);
|
|
202
|
+
}
|
|
200
203
|
frame._url = url;
|
|
201
204
|
const navigationEvent = {
|
|
202
205
|
url,
|
|
@@ -429,7 +432,8 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
429
432
|
if (this._inflightRequests.size === 0) this._startNetworkIdleTimer();
|
|
430
433
|
this._page.mainFrame()._recalculateNetworkIdle(this);
|
|
431
434
|
this._onLifecycleEvent('commit');
|
|
432
|
-
this.
|
|
435
|
+
const crSession = (this._page._delegate._sessions.get(this._id) || this._page._delegate._mainFrameSession)._client;
|
|
436
|
+
crSession.emit('Runtime.executionContextsCleared');
|
|
433
437
|
}
|
|
434
438
|
setPendingDocument(documentInfo) {
|
|
435
439
|
this._pendingDocument = documentInfo;
|
|
@@ -584,174 +588,29 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
584
588
|
async frameElement() {
|
|
585
589
|
return this._page._delegate.getFrameElement(this);
|
|
586
590
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
// random name to make it harder to detect for any 3rd party script by watching window object and events
|
|
594
|
-
const randomName = [...Array(Math.floor(Math.random() * (10 + 1)) + 10)].map(() => Math.random().toString(36)[2]).join('');
|
|
595
|
-
process.env['REBROWSER_PATCHES_DEBUG'] && console.log(`[rebrowser-patches][getMainWorld] binding name = ${randomName}`);
|
|
596
|
-
|
|
597
|
-
// add the binding
|
|
598
|
-
await client.send('Runtime.addBinding', {
|
|
599
|
-
name: randomName
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
// listen for 'Runtime.bindingCalled' event
|
|
603
|
-
const bindingCalledHandler = ({
|
|
604
|
-
name,
|
|
605
|
-
payload,
|
|
606
|
-
executionContextId
|
|
607
|
-
}) => {
|
|
608
|
-
process.env['REBROWSER_PATCHES_DEBUG'] && console.log('[rebrowser-patches][bindingCalledHandler]', {
|
|
609
|
-
name,
|
|
610
|
-
payload,
|
|
611
|
-
executionContextId
|
|
612
|
-
});
|
|
613
|
-
if (contextId > 0) {
|
|
614
|
-
// already acquired the id
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
if (name !== randomName) {
|
|
618
|
-
// ignore irrelevant bindings
|
|
619
|
-
return;
|
|
620
|
-
}
|
|
621
|
-
if (payload !== frameId) {
|
|
622
|
-
// ignore irrelevant frames
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
contextId = executionContextId;
|
|
626
|
-
// remove this listener
|
|
627
|
-
client.off('Runtime.bindingCalled', bindingCalledHandler);
|
|
628
|
-
};
|
|
629
|
-
client.on('Runtime.bindingCalled', bindingCalledHandler);
|
|
630
|
-
|
|
631
|
-
// we could call the binding right from addScriptToEvaluateOnNewDocument, but this way it will be called in all existing frames and it's hard to distinguish children from the parent
|
|
632
|
-
await client.send('Page.addScriptToEvaluateOnNewDocument', {
|
|
633
|
-
source: `document.addEventListener('${randomName}', (e) => self['${randomName}'](e.detail.frameId))`,
|
|
634
|
-
runImmediately: true
|
|
635
|
-
});
|
|
636
|
-
|
|
637
|
-
// create new isolated world for this frame
|
|
638
|
-
const createIsolatedWorldResult = await client.send('Page.createIsolatedWorld', {
|
|
639
|
-
frameId,
|
|
640
|
-
// use randomName for worldName to distinguish from normal utility world
|
|
641
|
-
worldName: randomName,
|
|
642
|
-
grantUniveralAccess: true
|
|
643
|
-
});
|
|
644
|
-
|
|
645
|
-
// emit event in the specific frame from the isolated world
|
|
646
|
-
await client.send('Runtime.evaluate', {
|
|
647
|
-
expression: `document.dispatchEvent(new CustomEvent('${randomName}', { detail: { frameId: '${frameId}' } }))`,
|
|
648
|
-
contextId: createIsolatedWorldResult.executionContextId
|
|
649
|
-
});
|
|
650
|
-
process.env['REBROWSER_PATCHES_DEBUG'] && console.log(`[rebrowser-patches][getMainWorld] result:`, {
|
|
651
|
-
contextId
|
|
652
|
-
});
|
|
653
|
-
return contextId;
|
|
654
|
-
}
|
|
655
|
-
async __re__getIsolatedWorld({
|
|
656
|
-
client,
|
|
657
|
-
frameId,
|
|
658
|
-
worldName
|
|
659
|
-
}) {
|
|
660
|
-
const createIsolatedWorldResult = await client.send('Page.createIsolatedWorld', {
|
|
661
|
-
frameId,
|
|
662
|
-
worldName,
|
|
663
|
-
grantUniveralAccess: true
|
|
664
|
-
});
|
|
665
|
-
process.env['REBROWSER_PATCHES_DEBUG'] && console.log(`[rebrowser-patches][getIsolatedWorld] result:`, createIsolatedWorldResult);
|
|
666
|
-
return createIsolatedWorldResult.executionContextId;
|
|
667
|
-
}
|
|
668
|
-
_context(world) {
|
|
669
|
-
const fixMode = process.env['REBROWSER_PATCHES_RUNTIME_FIX_MODE'] || 'addBinding';
|
|
670
|
-
process.env['REBROWSER_PATCHES_DEBUG'] && console.log(`[rebrowser-patches][frames._context] frameId = ${this._id}, world = ${world}, fixMode = ${fixMode}`);
|
|
671
|
-
if (fixMode !== '0') {
|
|
672
|
-
if (typeof this.__re__contexts === 'undefined') {
|
|
673
|
-
this.__re__contexts = {};
|
|
674
|
-
}
|
|
675
|
-
const frameSession = this._page._delegate._sessions.get(this._id) || this._page._delegate._mainFrameSession;
|
|
676
|
-
const client = frameSession._client;
|
|
677
|
-
const utilityWorldName = process.env['REBROWSER_PATCHES_UTILITY_WORLD_NAME'] !== '0' ? process.env['REBROWSER_PATCHES_UTILITY_WORLD_NAME'] || 'util' : '__playwright_utility_world__';
|
|
678
|
-
let getWorldPromise;
|
|
679
|
-
if (fixMode === 'addBinding') {
|
|
680
|
-
if (this.__re__contexts[world] !== undefined) {
|
|
681
|
-
return Promise.resolve(this.__re__contexts[world]);
|
|
682
|
-
}
|
|
683
|
-
if (world === 'utility') {
|
|
684
|
-
getWorldPromise = this.__re__getIsolatedWorld({
|
|
685
|
-
client,
|
|
686
|
-
frameId: this._id,
|
|
687
|
-
worldName: utilityWorldName
|
|
688
|
-
}).then(contextId => {
|
|
689
|
-
return {
|
|
690
|
-
id: contextId,
|
|
691
|
-
name: utilityWorldName,
|
|
692
|
-
auxData: {
|
|
693
|
-
frameId: this._id,
|
|
694
|
-
isDefault: false
|
|
695
|
-
}
|
|
696
|
-
};
|
|
697
|
-
});
|
|
698
|
-
} else if (world === 'main') {
|
|
699
|
-
getWorldPromise = this.__re__getMainWorld({
|
|
700
|
-
client,
|
|
701
|
-
frameId: this._id
|
|
702
|
-
}).then(contextId => {
|
|
703
|
-
return {
|
|
704
|
-
id: contextId,
|
|
705
|
-
name: '',
|
|
706
|
-
auxData: {
|
|
707
|
-
frameId: this._id,
|
|
708
|
-
isDefault: true
|
|
709
|
-
}
|
|
710
|
-
};
|
|
711
|
-
});
|
|
712
|
-
}
|
|
713
|
-
getWorldPromise = getWorldPromise.then(contextPayload => {
|
|
714
|
-
const delegate = new _crExecutionContext.CRExecutionContext(client, contextPayload);
|
|
715
|
-
this.__re__contexts[world] = new dom.FrameExecutionContext(delegate, this, world);
|
|
716
|
-
return this.__re__contexts[world];
|
|
717
|
-
});
|
|
718
|
-
} else if (fixMode === 'alwaysIsolated') {
|
|
719
|
-
// use only utility context
|
|
720
|
-
if (this.__re__contexts.utility !== undefined) {
|
|
721
|
-
return Promise.resolve(this.__re__contexts.utility);
|
|
722
|
-
}
|
|
723
|
-
getWorldPromise = this.__re__getIsolatedWorld({
|
|
724
|
-
client,
|
|
725
|
-
frameId: this._id,
|
|
726
|
-
worldName: utilityWorldName
|
|
727
|
-
}).then(contextId => {
|
|
728
|
-
const contextPayload = {
|
|
729
|
-
id: contextId,
|
|
730
|
-
name: utilityWorldName,
|
|
731
|
-
auxData: {
|
|
732
|
-
frameId: this._id,
|
|
733
|
-
isDefault: false
|
|
734
|
-
}
|
|
735
|
-
};
|
|
736
|
-
const delegate = new _crExecutionContext.CRExecutionContext(client, contextPayload);
|
|
737
|
-
this.__re__contexts.utility = new dom.FrameExecutionContext(delegate, this, 'utility');
|
|
738
|
-
return this.__re__contexts.utility;
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
return getWorldPromise.catch(error => {
|
|
742
|
-
if (error.message.includes('No frame for given id found')) {
|
|
743
|
-
// ignore, frame is already gone
|
|
744
|
-
return {
|
|
745
|
-
destroyedReason: 'Frame was detached'
|
|
746
|
-
};
|
|
747
|
-
}
|
|
748
|
-
_debugLogger.debugLogger.log('error', error);
|
|
749
|
-
console.error('[rebrowser-patches][frames._context] cannot get world, error:', error);
|
|
591
|
+
_context(world, useContextPromise = false) {
|
|
592
|
+
if (process.env['REBROWSER_PATCHES_RUNTIME_FIX_MODE'] === '0' || this._contextData.get(world).context || useContextPromise) {
|
|
593
|
+
return this._contextData.get(world).contextPromise.then(contextOrDestroyedReason => {
|
|
594
|
+
if (contextOrDestroyedReason instanceof js.ExecutionContext) return contextOrDestroyedReason;
|
|
595
|
+
throw new Error(contextOrDestroyedReason.destroyedReason);
|
|
750
596
|
});
|
|
751
597
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
598
|
+
const crSession = (this._page._delegate._sessions.get(this._id) || this._page._delegate._mainFrameSession)._client;
|
|
599
|
+
return crSession.__re__emitExecutionContext({
|
|
600
|
+
world,
|
|
601
|
+
targetId: this._id,
|
|
602
|
+
frame: this
|
|
603
|
+
}).then(() => {
|
|
604
|
+
return this._context(world, true);
|
|
605
|
+
}).catch(error => {
|
|
606
|
+
if (error.message.includes('No frame for given id found')) {
|
|
607
|
+
// ignore, frame is already gone
|
|
608
|
+
return {
|
|
609
|
+
destroyedReason: 'Frame was detached'
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
_debugLogger.debugLogger.log('error', error);
|
|
613
|
+
console.error('[rebrowser-patches][frames._context] cannot get world, error:', error);
|
|
755
614
|
});
|
|
756
615
|
}
|
|
757
616
|
_mainContext() {
|
|
@@ -793,12 +652,12 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
793
652
|
return await this.waitForSelectorInternal(progress, selector, true, options, scope);
|
|
794
653
|
}, this._page._timeoutSettings.timeout(options));
|
|
795
654
|
}
|
|
796
|
-
async waitForSelectorInternal(progress, selector,
|
|
655
|
+
async waitForSelectorInternal(progress, selector, performActionPreChecks, options, scope) {
|
|
797
656
|
const {
|
|
798
657
|
state = 'visible'
|
|
799
658
|
} = options;
|
|
800
659
|
const promise = this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async continuePolling => {
|
|
801
|
-
if (
|
|
660
|
+
if (performActionPreChecks) await this._page.performActionPreChecks(progress);
|
|
802
661
|
const resolved = await this.selectors.resolveInjectedForSelector(selector, options, scope);
|
|
803
662
|
progress.throwIfAborted();
|
|
804
663
|
if (!resolved) {
|
|
@@ -809,6 +668,7 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
809
668
|
info,
|
|
810
669
|
root
|
|
811
670
|
}) => {
|
|
671
|
+
if (root && !root.isConnected) throw injected.createStacklessError('Element is not attached to the DOM');
|
|
812
672
|
const elements = injected.querySelectorAll(info.parsed, root || document);
|
|
813
673
|
const element = elements[0];
|
|
814
674
|
const visible = element ? injected.utils.isElementVisible(element) : false;
|
|
@@ -1114,19 +974,21 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1114
974
|
// Retry upon all other errors.
|
|
1115
975
|
return false;
|
|
1116
976
|
}
|
|
1117
|
-
async _retryWithProgressIfNotConnected(progress, selector, strict,
|
|
977
|
+
async _retryWithProgressIfNotConnected(progress, selector, strict, performActionPreChecks, action) {
|
|
1118
978
|
progress.log(`waiting for ${this._asLocator(selector)}`);
|
|
1119
979
|
return this.retryWithProgressAndTimeouts(progress, [0, 20, 50, 100, 100, 500], async continuePolling => {
|
|
1120
|
-
if (
|
|
980
|
+
if (performActionPreChecks) await this._page.performActionPreChecks(progress);
|
|
1121
981
|
const resolved = await this.selectors.resolveInjectedForSelector(selector, {
|
|
1122
982
|
strict
|
|
1123
983
|
});
|
|
1124
984
|
progress.throwIfAborted();
|
|
1125
985
|
if (!resolved) return continuePolling;
|
|
1126
986
|
const result = await resolved.injected.evaluateHandle((injected, {
|
|
1127
|
-
info
|
|
987
|
+
info,
|
|
988
|
+
callId
|
|
1128
989
|
}) => {
|
|
1129
990
|
const elements = injected.querySelectorAll(info.parsed, document);
|
|
991
|
+
if (callId) injected.markTargetElements(new Set(elements), callId);
|
|
1130
992
|
const element = elements[0];
|
|
1131
993
|
let log = '';
|
|
1132
994
|
if (elements.length > 1) {
|
|
@@ -1141,7 +1003,8 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1141
1003
|
element
|
|
1142
1004
|
};
|
|
1143
1005
|
}, {
|
|
1144
|
-
info: resolved.info
|
|
1006
|
+
info: resolved.info,
|
|
1007
|
+
callId: progress.metadata.id
|
|
1145
1008
|
});
|
|
1146
1009
|
const {
|
|
1147
1010
|
log,
|
|
@@ -1170,7 +1033,7 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1170
1033
|
});
|
|
1171
1034
|
}
|
|
1172
1035
|
async rafrafTimeoutScreenshotElementWithProgress(progress, selector, timeout, options) {
|
|
1173
|
-
return await this._retryWithProgressIfNotConnected(progress, selector, true /* strict */, true /*
|
|
1036
|
+
return await this._retryWithProgressIfNotConnected(progress, selector, true /* strict */, true /* performActionPreChecks */, async handle => {
|
|
1174
1037
|
await handle._frame.rafrafTimeout(timeout);
|
|
1175
1038
|
return await this._page._screenshotter.screenshotElement(progress, handle, options);
|
|
1176
1039
|
});
|
|
@@ -1178,7 +1041,7 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1178
1041
|
async click(metadata, selector, options) {
|
|
1179
1042
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1180
1043
|
return controller.run(async progress => {
|
|
1181
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /*
|
|
1044
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._click(progress, {
|
|
1182
1045
|
...options,
|
|
1183
1046
|
waitAfter: !options.noWaitAfter
|
|
1184
1047
|
})));
|
|
@@ -1187,13 +1050,13 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1187
1050
|
async dblclick(metadata, selector, options = {}) {
|
|
1188
1051
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1189
1052
|
return controller.run(async progress => {
|
|
1190
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /*
|
|
1053
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._dblclick(progress, options)));
|
|
1191
1054
|
}, this._page._timeoutSettings.timeout(options));
|
|
1192
1055
|
}
|
|
1193
1056
|
async dragAndDrop(metadata, source, target, options = {}) {
|
|
1194
1057
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1195
1058
|
await controller.run(async progress => {
|
|
1196
|
-
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, source, options.strict, !options.force /*
|
|
1059
|
+
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, source, options.strict, !options.force /* performActionPreChecks */, async handle => {
|
|
1197
1060
|
return handle._retryPointerAction(progress, 'move and down', false, async point => {
|
|
1198
1061
|
await this._page.mouse.move(point.x, point.y);
|
|
1199
1062
|
await this._page.mouse.down();
|
|
@@ -1205,7 +1068,7 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1205
1068
|
});
|
|
1206
1069
|
}));
|
|
1207
1070
|
// Note: do not perform locator handlers checkpoint to avoid moving the mouse in the middle of a drag operation.
|
|
1208
|
-
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, target, options.strict, false /*
|
|
1071
|
+
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, target, options.strict, false /* performActionPreChecks */, async handle => {
|
|
1209
1072
|
return handle._retryPointerAction(progress, 'move and up', false, async point => {
|
|
1210
1073
|
await this._page.mouse.move(point.x, point.y);
|
|
1211
1074
|
await this._page.mouse.up();
|
|
@@ -1222,25 +1085,25 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1222
1085
|
if (!this._page._browserContext._options.hasTouch) throw new Error('The page does not support tap. Use hasTouch context option to enable touch support.');
|
|
1223
1086
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1224
1087
|
return controller.run(async progress => {
|
|
1225
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /*
|
|
1088
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._tap(progress, options)));
|
|
1226
1089
|
}, this._page._timeoutSettings.timeout(options));
|
|
1227
1090
|
}
|
|
1228
1091
|
async fill(metadata, selector, value, options) {
|
|
1229
1092
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1230
1093
|
return controller.run(async progress => {
|
|
1231
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /*
|
|
1094
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._fill(progress, value, options)));
|
|
1232
1095
|
}, this._page._timeoutSettings.timeout(options));
|
|
1233
1096
|
}
|
|
1234
1097
|
async focus(metadata, selector, options = {}) {
|
|
1235
1098
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1236
1099
|
await controller.run(async progress => {
|
|
1237
|
-
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true /*
|
|
1100
|
+
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true /* performActionPreChecks */, handle => handle._focus(progress)));
|
|
1238
1101
|
}, this._page._timeoutSettings.timeout(options));
|
|
1239
1102
|
}
|
|
1240
1103
|
async blur(metadata, selector, options = {}) {
|
|
1241
1104
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1242
1105
|
await controller.run(async progress => {
|
|
1243
|
-
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true /*
|
|
1106
|
+
dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true /* performActionPreChecks */, handle => handle._blur(progress)));
|
|
1244
1107
|
}, this._page._timeoutSettings.timeout(options));
|
|
1245
1108
|
}
|
|
1246
1109
|
async textContent(metadata, selector, options = {}, scope) {
|
|
@@ -1340,44 +1203,44 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1340
1203
|
async hover(metadata, selector, options = {}) {
|
|
1341
1204
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1342
1205
|
return controller.run(async progress => {
|
|
1343
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /*
|
|
1206
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._hover(progress, options)));
|
|
1344
1207
|
}, this._page._timeoutSettings.timeout(options));
|
|
1345
1208
|
}
|
|
1346
1209
|
async selectOption(metadata, selector, elements, values, options = {}) {
|
|
1347
1210
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1348
1211
|
return controller.run(async progress => {
|
|
1349
|
-
return await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /*
|
|
1212
|
+
return await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._selectOption(progress, elements, values, options));
|
|
1350
1213
|
}, this._page._timeoutSettings.timeout(options));
|
|
1351
1214
|
}
|
|
1352
1215
|
async setInputFiles(metadata, selector, params) {
|
|
1353
1216
|
const inputFileItems = await (0, _fileUploadUtils.prepareFilesForUpload)(this, params);
|
|
1354
1217
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1355
1218
|
return controller.run(async progress => {
|
|
1356
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, params.strict, true /*
|
|
1219
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, params.strict, true /* performActionPreChecks */, handle => handle._setInputFiles(progress, inputFileItems)));
|
|
1357
1220
|
}, this._page._timeoutSettings.timeout(params));
|
|
1358
1221
|
}
|
|
1359
1222
|
async type(metadata, selector, text, options = {}) {
|
|
1360
1223
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1361
1224
|
return controller.run(async progress => {
|
|
1362
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true /*
|
|
1225
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true /* performActionPreChecks */, handle => handle._type(progress, text, options)));
|
|
1363
1226
|
}, this._page._timeoutSettings.timeout(options));
|
|
1364
1227
|
}
|
|
1365
1228
|
async press(metadata, selector, key, options = {}) {
|
|
1366
1229
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1367
1230
|
return controller.run(async progress => {
|
|
1368
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true /*
|
|
1231
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, true /* performActionPreChecks */, handle => handle._press(progress, key, options)));
|
|
1369
1232
|
}, this._page._timeoutSettings.timeout(options));
|
|
1370
1233
|
}
|
|
1371
1234
|
async check(metadata, selector, options = {}) {
|
|
1372
1235
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1373
1236
|
return controller.run(async progress => {
|
|
1374
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /*
|
|
1237
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._setChecked(progress, true, options)));
|
|
1375
1238
|
}, this._page._timeoutSettings.timeout(options));
|
|
1376
1239
|
}
|
|
1377
1240
|
async uncheck(metadata, selector, options = {}) {
|
|
1378
1241
|
const controller = new _progress.ProgressController(metadata, this);
|
|
1379
1242
|
return controller.run(async progress => {
|
|
1380
|
-
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /*
|
|
1243
|
+
return dom.assertDone(await this._retryWithProgressIfNotConnected(progress, selector, options.strict, !options.force /* performActionPreChecks */, handle => handle._setChecked(progress, false, options)));
|
|
1381
1244
|
}, this._page._timeoutSettings.timeout(options));
|
|
1382
1245
|
}
|
|
1383
1246
|
async waitForTimeout(metadata, timeout) {
|
|
@@ -1386,6 +1249,12 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1386
1249
|
await new Promise(resolve => setTimeout(resolve, timeout));
|
|
1387
1250
|
});
|
|
1388
1251
|
}
|
|
1252
|
+
async ariaSnapshot(metadata, selector, options = {}) {
|
|
1253
|
+
const controller = new _progress.ProgressController(metadata, this);
|
|
1254
|
+
return controller.run(async progress => {
|
|
1255
|
+
return await this._retryWithProgressIfNotConnected(progress, selector, true /* strict */, true /* performActionPreChecks */, handle => handle.ariaSnapshot());
|
|
1256
|
+
}, this._page._timeoutSettings.timeout(options));
|
|
1257
|
+
}
|
|
1389
1258
|
async expect(metadata, selector, options) {
|
|
1390
1259
|
const result = await this._expectImpl(metadata, selector, options);
|
|
1391
1260
|
// Library mode special case for the expect errors which are return values, not exceptions.
|
|
@@ -1409,7 +1278,7 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1409
1278
|
await new _progress.ProgressController(metadata, this).run(async progress => {
|
|
1410
1279
|
progress.log(`${metadata.apiName}${timeout ? ` with timeout ${timeout}ms` : ''}`);
|
|
1411
1280
|
progress.log(`waiting for ${this._asLocator(selector)}`);
|
|
1412
|
-
await this._page.
|
|
1281
|
+
await this._page.performActionPreChecks(progress);
|
|
1413
1282
|
}, timeout);
|
|
1414
1283
|
|
|
1415
1284
|
// Step 2: perform one-shot expect check without a timeout.
|
|
@@ -1430,7 +1299,7 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1430
1299
|
}
|
|
1431
1300
|
if (timeout < 0) return {
|
|
1432
1301
|
matches: options.isNot,
|
|
1433
|
-
log: metadata.log,
|
|
1302
|
+
log: (0, _utils.compressCallLog)(metadata.log),
|
|
1434
1303
|
timedOut: true,
|
|
1435
1304
|
received: lastIntermediateResult.received
|
|
1436
1305
|
};
|
|
@@ -1438,7 +1307,7 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1438
1307
|
// Step 3: auto-retry expect with increasing timeouts. Bounded by the total remaining time.
|
|
1439
1308
|
return await new _progress.ProgressController(metadata, this).run(async progress => {
|
|
1440
1309
|
return await this.retryWithProgressAndTimeouts(progress, [100, 250, 500, 1000], async continuePolling => {
|
|
1441
|
-
await this._page.
|
|
1310
|
+
await this._page.performActionPreChecks(progress);
|
|
1442
1311
|
const {
|
|
1443
1312
|
matches,
|
|
1444
1313
|
received
|
|
@@ -1461,7 +1330,7 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1461
1330
|
if (js.isJavaScriptErrorInEvaluate(e) || (0, _selectorParser.isInvalidSelectorError)(e)) throw e;
|
|
1462
1331
|
const result = {
|
|
1463
1332
|
matches: options.isNot,
|
|
1464
|
-
log: metadata.log
|
|
1333
|
+
log: (0, _utils.compressCallLog)(metadata.log)
|
|
1465
1334
|
};
|
|
1466
1335
|
if (lastIntermediateResult.isSet) result.received = lastIntermediateResult.received;
|
|
1467
1336
|
if (e instanceof _errors.TimeoutError) result.timedOut = true;
|
|
@@ -1496,10 +1365,10 @@ class Frame extends _instrumentation.SdkObject {
|
|
|
1496
1365
|
callId
|
|
1497
1366
|
}) => {
|
|
1498
1367
|
const elements = info ? injected.querySelectorAll(info.parsed, document) : [];
|
|
1368
|
+
if (callId) injected.markTargetElements(new Set(elements), callId);
|
|
1499
1369
|
const isArray = options.expression === 'to.have.count' || options.expression.endsWith('.array');
|
|
1500
1370
|
let log = '';
|
|
1501
1371
|
if (isArray) log = ` locator resolved to ${elements.length} element${elements.length === 1 ? '' : 's'}`;else if (elements.length > 1) throw injected.strictModeViolationError(info.parsed, elements);else if (elements.length) log = ` locator resolved to ${injected.previewNode(elements[0])}`;
|
|
1502
|
-
if (callId) injected.markTargetElements(new Set(elements), callId);
|
|
1503
1372
|
return {
|
|
1504
1373
|
log,
|
|
1505
1374
|
...(await injected.expect(elements[0], options, elements))
|
|
@@ -1817,5 +1686,6 @@ function renderUnexpectedValue(expression, received) {
|
|
|
1817
1686
|
if (expression === 'to.be.readonly') return received ? 'readonly' : 'editable';
|
|
1818
1687
|
if (expression === 'to.be.empty') return received ? 'empty' : 'not empty';
|
|
1819
1688
|
if (expression === 'to.be.focused') return received ? 'focused' : 'not focused';
|
|
1689
|
+
if (expression === 'to.match.aria') return received ? received.raw : received;
|
|
1820
1690
|
return received;
|
|
1821
1691
|
}
|
package/lib/server/index.js
CHANGED
|
@@ -45,12 +45,6 @@ Object.defineProperty(exports, "installBrowsersForNpmInstall", {
|
|
|
45
45
|
return _registry.installBrowsersForNpmInstall;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
Object.defineProperty(exports, "installDefaultBrowsersForNpmInstall", {
|
|
49
|
-
enumerable: true,
|
|
50
|
-
get: function () {
|
|
51
|
-
return _registry.installDefaultBrowsersForNpmInstall;
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
48
|
Object.defineProperty(exports, "installRootRedirect", {
|
|
55
49
|
enumerable: true,
|
|
56
50
|
get: function () {
|
package/lib/server/javascript.js
CHANGED
|
@@ -55,9 +55,6 @@ class ExecutionContext extends _instrumentation.SdkObject {
|
|
|
55
55
|
rawEvaluateHandle(expression) {
|
|
56
56
|
return this._raceAgainstContextDestroyed(this._delegate.rawEvaluateHandle(expression));
|
|
57
57
|
}
|
|
58
|
-
rawCallFunctionNoReply(func, ...args) {
|
|
59
|
-
this._delegate.rawCallFunctionNoReply(func, ...args);
|
|
60
|
-
}
|
|
61
58
|
evaluateWithArguments(expression, returnByValue, utilityScript, values, objectIds) {
|
|
62
59
|
return this._raceAgainstContextDestroyed(this._delegate.evaluateWithArguments(expression, returnByValue, utilityScript, values, objectIds));
|
|
63
60
|
}
|
|
@@ -108,9 +105,6 @@ class JSHandle extends _instrumentation.SdkObject {
|
|
|
108
105
|
this._preview = this._objectId ? preview || `JSHandle@${this._objectType}` : String(value);
|
|
109
106
|
if (this._objectId && globalThis.leakedJSHandles) globalThis.leakedJSHandles.set(this, new Error('Leaked JSHandle'));
|
|
110
107
|
}
|
|
111
|
-
callFunctionNoReply(func, arg) {
|
|
112
|
-
this._context.rawCallFunctionNoReply(func, this, arg);
|
|
113
|
-
}
|
|
114
108
|
async evaluate(pageFunction, arg) {
|
|
115
109
|
return evaluate(this._context, true /* returnByValue */, pageFunction, this, arg);
|
|
116
110
|
}
|
package/lib/server/page.js
CHANGED
|
@@ -22,6 +22,7 @@ var _instrumentation = require("./instrumentation");
|
|
|
22
22
|
var _selectorParser = require("../utils/isomorphic/selectorParser");
|
|
23
23
|
var _utilityScriptSerializers = require("./isomorphic/utilityScriptSerializers");
|
|
24
24
|
var _errors = require("./errors");
|
|
25
|
+
var _helper = require("./helper");
|
|
25
26
|
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); }
|
|
26
27
|
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; }
|
|
27
28
|
/**
|
|
@@ -308,7 +309,29 @@ class Page extends _instrumentation.SdkObject {
|
|
|
308
309
|
unregisterLocatorHandler(uid) {
|
|
309
310
|
this._locatorHandlers.delete(uid);
|
|
310
311
|
}
|
|
311
|
-
async
|
|
312
|
+
async performActionPreChecks(progress) {
|
|
313
|
+
await this._performWaitForNavigationCheck(progress);
|
|
314
|
+
progress.throwIfAborted();
|
|
315
|
+
await this._performLocatorHandlersCheckpoint(progress);
|
|
316
|
+
progress.throwIfAborted();
|
|
317
|
+
// Wait once again, just in case a locator handler caused a navigation.
|
|
318
|
+
await this._performWaitForNavigationCheck(progress);
|
|
319
|
+
}
|
|
320
|
+
async _performWaitForNavigationCheck(progress) {
|
|
321
|
+
var _mainFrame$pendingDoc;
|
|
322
|
+
if (process.env.PLAYWRIGHT_SKIP_NAVIGATION_CHECK) return;
|
|
323
|
+
const mainFrame = this._frameManager.mainFrame();
|
|
324
|
+
if (!mainFrame || !mainFrame.pendingDocument()) return;
|
|
325
|
+
const url = (_mainFrame$pendingDoc = mainFrame.pendingDocument()) === null || _mainFrame$pendingDoc === void 0 || (_mainFrame$pendingDoc = _mainFrame$pendingDoc.request) === null || _mainFrame$pendingDoc === void 0 ? void 0 : _mainFrame$pendingDoc.url();
|
|
326
|
+
const toUrl = url ? `" ${(0, _utils.trimStringWithEllipsis)(url, 200)}"` : '';
|
|
327
|
+
progress.log(` waiting for${toUrl} navigation to finish...`);
|
|
328
|
+
await _helper.helper.waitForEvent(progress, mainFrame, frames.Frame.Events.InternalNavigation, e => {
|
|
329
|
+
if (!e.isPublic) return false;
|
|
330
|
+
if (!e.error) progress.log(` navigated to "${(0, _utils.trimStringWithEllipsis)(mainFrame.url(), 200)}"`);
|
|
331
|
+
return true;
|
|
332
|
+
}).promise;
|
|
333
|
+
}
|
|
334
|
+
async _performLocatorHandlersCheckpoint(progress) {
|
|
312
335
|
// Do not run locator handlers from inside locator handler callbacks to avoid deadlocks.
|
|
313
336
|
if (this._locatorHandlerRunningCounter) return;
|
|
314
337
|
for (const [uid, handler] of this._locatorHandlers) {
|
|
@@ -409,7 +432,7 @@ class Page extends _instrumentation.SdkObject {
|
|
|
409
432
|
const rafrafScreenshot = locator ? async (progress, timeout) => {
|
|
410
433
|
return await locator.frame.rafrafTimeoutScreenshotElementWithProgress(progress, locator.selector, timeout, options || {});
|
|
411
434
|
} : async (progress, timeout) => {
|
|
412
|
-
await this.
|
|
435
|
+
await this.performActionPreChecks(progress);
|
|
413
436
|
await this.mainFrame().rafrafTimeout(timeout);
|
|
414
437
|
return await this._screenshotter.screenshotPage(progress, options || {});
|
|
415
438
|
};
|
|
@@ -472,19 +495,23 @@ class Page extends _instrumentation.SdkObject {
|
|
|
472
495
|
progress.log(`screenshot matched expectation`);
|
|
473
496
|
return {};
|
|
474
497
|
}
|
|
475
|
-
if (areEqualScreenshots(actual, options.expected,
|
|
498
|
+
if (areEqualScreenshots(actual, options.expected, undefined)) {
|
|
476
499
|
progress.log(`screenshot matched expectation`);
|
|
477
500
|
return {};
|
|
478
501
|
}
|
|
479
502
|
throw new Error(intermediateResult.errorMessage);
|
|
480
503
|
}, callTimeout).catch(e => {
|
|
504
|
+
var _intermediateResult;
|
|
481
505
|
// Q: Why not throw upon isSessionClosedError(e) as in other places?
|
|
482
506
|
// A: We want user to receive a friendly diff between actual and expected/previous.
|
|
483
507
|
if (js.isJavaScriptErrorInEvaluate(e) || (0, _selectorParser.isInvalidSelectorError)(e)) throw e;
|
|
508
|
+
let errorMessage = e.message;
|
|
509
|
+
if (e instanceof _errors.TimeoutError && (_intermediateResult = intermediateResult) !== null && _intermediateResult !== void 0 && _intermediateResult.previous) errorMessage = `Failed to take two consecutive stable screenshots.`;
|
|
484
510
|
return {
|
|
485
|
-
log: e.message ? [...metadata.log, e.message] : metadata.log,
|
|
511
|
+
log: (0, _utils.compressCallLog)(e.message ? [...metadata.log, e.message] : metadata.log),
|
|
486
512
|
...intermediateResult,
|
|
487
|
-
errorMessage
|
|
513
|
+
errorMessage,
|
|
514
|
+
timedOut: e instanceof _errors.TimeoutError
|
|
488
515
|
};
|
|
489
516
|
});
|
|
490
517
|
}
|
|
@@ -596,16 +623,20 @@ Page.Events = {
|
|
|
596
623
|
Worker: 'worker'
|
|
597
624
|
};
|
|
598
625
|
class Worker extends _instrumentation.SdkObject {
|
|
599
|
-
constructor(parent, url) {
|
|
626
|
+
constructor(parent, url, targetId, session) {
|
|
600
627
|
super(parent, 'worker');
|
|
601
628
|
this._url = void 0;
|
|
602
629
|
this._executionContextPromise = void 0;
|
|
603
630
|
this._executionContextCallback = void 0;
|
|
604
631
|
this._existingExecutionContext = null;
|
|
605
632
|
this.openScope = new _utils.LongStandingScope();
|
|
633
|
+
this._targetId = void 0;
|
|
634
|
+
this._session = void 0;
|
|
606
635
|
this._url = url;
|
|
607
636
|
this._executionContextCallback = () => {};
|
|
608
637
|
this._executionContextPromise = new Promise(x => this._executionContextCallback = x);
|
|
638
|
+
this._targetId = targetId;
|
|
639
|
+
this._session = session;
|
|
609
640
|
}
|
|
610
641
|
_createExecutionContext(delegate) {
|
|
611
642
|
this._existingExecutionContext = new js.ExecutionContext(this, delegate, 'worker');
|
|
@@ -619,14 +650,23 @@ class Worker extends _instrumentation.SdkObject {
|
|
|
619
650
|
this.emit(Worker.Events.Close, this);
|
|
620
651
|
this.openScope.close(new Error('Worker closed'));
|
|
621
652
|
}
|
|
653
|
+
async getExecutionContext() {
|
|
654
|
+
if (process.env['REBROWSER_PATCHES_RUNTIME_FIX_MODE'] !== '0' && !this._existingExecutionContext) {
|
|
655
|
+
await this._session.__re__emitExecutionContext({
|
|
656
|
+
world: 'main',
|
|
657
|
+
targetId: this._targetId
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
return this._executionContextPromise;
|
|
661
|
+
}
|
|
622
662
|
async evaluateExpression(expression, isFunction, arg) {
|
|
623
|
-
return js.evaluateExpression(await this.
|
|
663
|
+
return js.evaluateExpression(await this.getExecutionContext(), expression, {
|
|
624
664
|
returnByValue: true,
|
|
625
665
|
isFunction
|
|
626
666
|
}, arg);
|
|
627
667
|
}
|
|
628
668
|
async evaluateExpressionHandle(expression, isFunction, arg) {
|
|
629
|
-
return js.evaluateExpression(await this.
|
|
669
|
+
return js.evaluateExpression(await this.getExecutionContext(), expression, {
|
|
630
670
|
returnByValue: false,
|
|
631
671
|
isFunction
|
|
632
672
|
}, arg);
|
package/lib/server/progress.js
CHANGED
|
@@ -70,9 +70,6 @@ class ProgressController {
|
|
|
70
70
|
throwIfAborted: () => {
|
|
71
71
|
if (this._state === 'aborted') throw new AbortedError();
|
|
72
72
|
},
|
|
73
|
-
beforeInputAction: async element => {
|
|
74
|
-
await this.instrumentation.onBeforeInputAction(this.sdkObject, this.metadata, element);
|
|
75
|
-
},
|
|
76
73
|
metadata: this.metadata
|
|
77
74
|
};
|
|
78
75
|
const timeoutError = new _errors.TimeoutError(`Timeout ${this._timeout}ms exceeded.`);
|