{"record":{"id":"41517284483ea6d9","repo":"alibaba/page-agent","slug":"unable-to-access-iframe","errorCode":null,"errorMessage":"Unable to access iframe:","messagePattern":"Unable to access iframe:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/page-controller/src/dom/dom_tree/index.js","lineNumber":1682,"sourceCode":"\t\t\t}\n\t\t}\n\n\t\t// Process children, with special handling for iframes and rich text editors\n\t\tif (node.tagName) {\n\t\t\tconst tagName = node.tagName.toLowerCase()\n\n\t\t\t// Handle iframes\n\t\t\tif (tagName === 'iframe') {\n\t\t\t\ttry {\n\t\t\t\t\tconst iframeDoc = node.contentDocument || node.contentWindow?.document\n\t\t\t\t\tif (iframeDoc) {\n\t\t\t\t\t\tfor (const child of iframeDoc.childNodes) {\n\t\t\t\t\t\t\tconst domElement = buildDomTree(child, node, false)\n\t\t\t\t\t\t\tif (domElement) nodeData.children.push(domElement)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tconsole.warn('Unable to access iframe:', e)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Handle rich text editors and contenteditable elements\n\t\t\telse if (\n\t\t\t\tnode.isContentEditable ||\n\t\t\t\tnode.getAttribute('contenteditable') === 'true' ||\n\t\t\t\tnode.id === 'tinymce' ||\n\t\t\t\tnode.classList.contains('mce-content-body') ||\n\t\t\t\t(tagName === 'body' && node.getAttribute('data-id')?.startsWith('mce_'))\n\t\t\t) {\n\t\t\t\t// Process all child nodes to capture formatted text\n\t\t\t\tfor (const child of node.childNodes) {\n\t\t\t\t\tconst domElement = buildDomTree(child, parentIframe, nodeWasHighlighted)\n\t\t\t\t\tif (domElement) nodeData.children.push(domElement)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// Handle shadow DOM\n\t\t\t\tif (node.shadowRoot) {","sourceCodeStart":1664,"sourceCodeEnd":1700,"githubUrl":"https://github.com/alibaba/page-agent/blob/d02db1ee7c41f5315beda88bab2fe935c580f662/packages/page-controller/src/dom/dom_tree/index.js#L1664-L1700","documentation":"While building the DOM tree, the extractor tries to descend into an iframe's contentDocument to index its children; if access throws (cross-origin iframe, or the frame navigated away mid-read) it logs 'Unable to access iframe:' with the underlying exception and skips that subtree. This is the browser's same-origin policy at work, not a bug in the library.","triggerScenarios":"The page embeds a cross-origin iframe (payment widget, embedded ad, third-party app); the iframe navigated or was removed between the frame check and child traversal; sandboxed iframes that deny document access.","commonSituations":"Login pages with third-party SSO frames; sites embedding Stripe/Stripe-like widgets, ads, or videos; extension contexts where frame origin differs from page origin.","solutions":["Accept the skip: cross-origin iframes cannot be automated from the parent page by design","If you control the iframe, serve it from the same origin (or set document.domain is NOT recommended; prefer same-origin hosting)","For extension automation, inject the page-controller into the iframe itself (content_scripts all_frames: true) and drive it per-frame","Re-run updateTree() if the failure was a transient navigation race"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":"function canAccessIframe(frame: HTMLIFrameElement): boolean { try { return !!frame.contentDocument } catch { return false } }","tryCatchPattern":null,"preventionTips":["Expect cross-origin iframes to be skipped; design flows around them","For extensions, inject into all frames (all_frames: true) and drive each frame separately","Re-index after iframe navigations settle"],"tags":["iframe","cross-origin","same-origin-policy","non-fatal"],"backgroundTag":"cross-origin-iframe-access-denied","analyzedSha":"d02db1ee7c41f5315beda88bab2fe935c580f662","analyzedAt":"2026-08-28T19:39:48.634Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}