@rpascene/shared 0.30.13 → 0.30.14
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.
|
@@ -322,12 +322,10 @@ export async function extractTreeNode(
|
|
|
322
322
|
initNode: globalThis.Node,
|
|
323
323
|
debugMode: boolean = false,
|
|
324
324
|
basePoint: Point = { left: 0, top: 0 },
|
|
325
|
-
baseZoom: number = 1
|
|
326
|
-
containerPaths: any[] = []
|
|
325
|
+
baseZoom: number = 1
|
|
327
326
|
): Promise<WebElementNode> {
|
|
328
327
|
setDebugMode(debugMode);
|
|
329
328
|
indexId = 0;
|
|
330
|
-
let containerPathClone = [...containerPaths]
|
|
331
329
|
const topDocument = getTopDocument();
|
|
332
330
|
const startNode = initNode || topDocument;
|
|
333
331
|
const topChildren: WebElementNode[] = [];
|
|
@@ -358,11 +356,6 @@ export async function extractTreeNode(
|
|
|
358
356
|
false
|
|
359
357
|
);
|
|
360
358
|
|
|
361
|
-
if (elementInfo) {
|
|
362
|
-
const allPaths = getLocators(node);
|
|
363
|
-
elementInfo.allPaths = allPaths;
|
|
364
|
-
elementInfo.containerPaths = containerPathClone;
|
|
365
|
-
}
|
|
366
359
|
if (node instanceof currentWindow.HTMLIFrameElement) {
|
|
367
360
|
if (
|
|
368
361
|
(node as HTMLIFrameElement).contentWindow &&
|
|
@@ -449,51 +442,25 @@ export async function extractTreeNode(
|
|
|
449
442
|
for (let i = 0; i < iframes.length; i++) {
|
|
450
443
|
const iframe = iframes[i];
|
|
451
444
|
const iframeInfo = collectElementInfo(iframe, window, document, 1);
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
containerPathClone = containerPathClone.concat(containerPath)
|
|
445
|
+
// 这里不再生成containerPath
|
|
446
|
+
const baseZoom = getCssScale(iframe).cssScaleX;
|
|
455
447
|
if (iframeInfo) {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
iframe.contentDocument.body,
|
|
461
|
-
iframe.contentWindow as any,
|
|
462
|
-
iframe.contentDocument,
|
|
463
|
-
baseZoom,
|
|
464
|
-
{
|
|
448
|
+
const iframeChildren = await postWindowMessage(iframe.contentWindow, window, {
|
|
449
|
+
action: 'extractTreeNode',
|
|
450
|
+
data: {
|
|
451
|
+
basePoint: {
|
|
465
452
|
left: iframeInfo.rect.left,
|
|
466
453
|
top: iframeInfo.rect.top,
|
|
467
454
|
},
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
console.log(iframeInfo, 'iframe跨域了')
|
|
476
|
-
|
|
477
|
-
// 跨域了,请求获取tree
|
|
478
|
-
const iframeChildren = await postWindowMessage(iframe.contentWindow, window, {
|
|
479
|
-
action: 'extractTreeNode',
|
|
480
|
-
data: {
|
|
481
|
-
basePoint: {
|
|
482
|
-
left: iframeInfo.rect.left,
|
|
483
|
-
top: iframeInfo.rect.top,
|
|
484
|
-
},
|
|
485
|
-
baseZoom,
|
|
486
|
-
containerPaths: containerPathClone
|
|
487
|
-
},
|
|
488
|
-
})
|
|
489
|
-
if (Array.isArray(iframeChildren)) {
|
|
490
|
-
topChildren.push(...iframeChildren);
|
|
491
|
-
} else if (iframeChildren) {
|
|
492
|
-
topChildren.push(iframeChildren);
|
|
493
|
-
}
|
|
455
|
+
baseZoom,
|
|
456
|
+
},
|
|
457
|
+
})
|
|
458
|
+
if (Array.isArray(iframeChildren)) {
|
|
459
|
+
topChildren.push(...iframeChildren);
|
|
460
|
+
} else if (iframeChildren) {
|
|
461
|
+
topChildren.push(iframeChildren);
|
|
494
462
|
}
|
|
495
463
|
}
|
|
496
|
-
|
|
497
464
|
}
|
|
498
465
|
}
|
|
499
466
|
|
|
@@ -548,7 +515,7 @@ if (typeof window !== 'undefined') {
|
|
|
548
515
|
if (action === 'extractTreeNode') {
|
|
549
516
|
// @ts-ignore
|
|
550
517
|
try {
|
|
551
|
-
return await extractTreeNode(document.body, false, data.basePoint, data.baseZoom
|
|
518
|
+
return await extractTreeNode(document.body, false, data.basePoint, data.baseZoom)
|
|
552
519
|
} catch (error) {
|
|
553
520
|
return {
|
|
554
521
|
error: 'error message'
|