@skrillex1224/playwright-toolkit 2.1.250 → 2.1.251
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/dist/browser.js +5 -1
- package/dist/browser.js.map +2 -2
- package/dist/index.cjs +33 -16
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +33 -16
- package/dist/index.js.map +2 -2
- package/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -536,6 +536,8 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
536
536
|
pushCandidate(root);
|
|
537
537
|
pushCandidate(body);
|
|
538
538
|
document.querySelectorAll("*").forEach(pushCandidate);
|
|
539
|
+
const scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
540
|
+
const clippingOverflow = /* @__PURE__ */ new Set(["hidden", "clip"]);
|
|
539
541
|
const isDocumentElement = (el) => el === root || el === body || el === scrollingElement;
|
|
540
542
|
const isVisible = (el, style, rect) => {
|
|
541
543
|
if (!el || !style || !rect) return false;
|
|
@@ -545,6 +547,27 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
545
547
|
if (Number(style.opacity) === 0) return false;
|
|
546
548
|
return rect.width > 0 && rect.height > 0;
|
|
547
549
|
};
|
|
550
|
+
const hasOverflowValue = (style, values) => {
|
|
551
|
+
const overflowY = String(style?.overflowY || "").toLowerCase();
|
|
552
|
+
const overflow = String(style?.overflow || "").toLowerCase();
|
|
553
|
+
return values.has(overflowY) || values.has(overflow);
|
|
554
|
+
};
|
|
555
|
+
const isLargeVerticalClipper = (el, rect) => {
|
|
556
|
+
if (!el || !rect) return false;
|
|
557
|
+
const viewportHeight = window.innerHeight || 0;
|
|
558
|
+
const visibleHeight = Math.ceil(rect.height || 0);
|
|
559
|
+
const clientHeight = Math.ceil(el.clientHeight || 0);
|
|
560
|
+
const boxHeight = Math.max(visibleHeight, clientHeight);
|
|
561
|
+
return boxHeight >= Math.max(320, viewportHeight * 0.45);
|
|
562
|
+
};
|
|
563
|
+
const hasLargeVerticalOverflow = (el, rect) => {
|
|
564
|
+
if (!isLargeVerticalClipper(el, rect)) return false;
|
|
565
|
+
const viewportHeight = window.innerHeight || 0;
|
|
566
|
+
const scrollHeight = Math.ceil(el.scrollHeight || 0);
|
|
567
|
+
const clientHeight = Math.ceil(el.clientHeight || 0);
|
|
568
|
+
const overflowDelta = scrollHeight - clientHeight;
|
|
569
|
+
return overflowDelta >= Math.max(160, viewportHeight * 0.18);
|
|
570
|
+
};
|
|
548
571
|
const rememberOriginalBoxStyles = (el, { includeDocumentElement = false } = {}) => {
|
|
549
572
|
if (!el || !includeDocumentElement && isDocumentElement(el) || el.classList.contains(className)) {
|
|
550
573
|
return;
|
|
@@ -579,19 +602,10 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
579
602
|
if (isDocumentElement(el)) {
|
|
580
603
|
return true;
|
|
581
604
|
}
|
|
582
|
-
|
|
583
|
-
const overflow = String(style.overflow || "").toLowerCase();
|
|
584
|
-
const scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
585
|
-
if (scrollableOverflow.has(overflowY) || scrollableOverflow.has(overflow)) {
|
|
605
|
+
if (hasOverflowValue(style, scrollableOverflow)) {
|
|
586
606
|
return true;
|
|
587
607
|
}
|
|
588
|
-
|
|
589
|
-
const clipsY = clippingOverflow.has(overflowY) || clippingOverflow.has(overflow);
|
|
590
|
-
if (!clipsY || !rect) {
|
|
591
|
-
return false;
|
|
592
|
-
}
|
|
593
|
-
const viewportHeight = window.innerHeight || 0;
|
|
594
|
-
return rect.height >= viewportHeight * 0.25 || el.scrollHeight >= viewportHeight * 0.75;
|
|
608
|
+
return hasOverflowValue(style, clippingOverflow) && hasLargeVerticalOverflow(el, rect);
|
|
595
609
|
};
|
|
596
610
|
const measureNeededHeight = (el) => {
|
|
597
611
|
if (!el) return 0;
|
|
@@ -624,10 +638,9 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
624
638
|
const style = window.getComputedStyle(node);
|
|
625
639
|
const rect = node.getBoundingClientRect();
|
|
626
640
|
if (!isVisible(node, style, rect)) continue;
|
|
627
|
-
const
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
if (!clipsContent) continue;
|
|
641
|
+
const scrollableClip = hasOverflowValue(style, scrollableOverflow);
|
|
642
|
+
const visualClip = hasOverflowValue(style, clippingOverflow);
|
|
643
|
+
if (!scrollableClip && (!visualClip || !isLargeVerticalClipper(node, rect))) continue;
|
|
631
644
|
rememberOriginalBoxStyles(node);
|
|
632
645
|
node.style.setProperty("overflow", "visible", "important");
|
|
633
646
|
node.style.setProperty("max-height", "none", "important");
|
|
@@ -1991,7 +2004,11 @@ var RuntimeEnv = {
|
|
|
1991
2004
|
// 指纹、时区、UA、viewport 的回放发生在 launch.js 启动阶段,不在这里做。
|
|
1992
2005
|
async applyToPage(page, source = {}, options = {}) {
|
|
1993
2006
|
if (!page) return;
|
|
1994
|
-
|
|
2007
|
+
let state = normalizeRuntimeState(source, options?.actor || "");
|
|
2008
|
+
if (typeof options?.preapply === "function") {
|
|
2009
|
+
state = await options.preapply(state) || state;
|
|
2010
|
+
rememberRuntimeState(state);
|
|
2011
|
+
}
|
|
1995
2012
|
Object.defineProperty(page, PageRuntimeStateKey, {
|
|
1996
2013
|
configurable: true,
|
|
1997
2014
|
enumerable: false,
|