diff --git a/docs/en/deep-dive/architecture/tab-domain.md b/docs/en/deep-dive/architecture/tab-domain.md index 474c1574..d444fac1 100644 --- a/docs/en/deep-dive/architecture/tab-domain.md +++ b/docs/en/deep-dive/architecture/tab-domain.md @@ -222,7 +222,7 @@ except KeyError: raise TopLevelTargetRequired(...) # Guide users to WebElement.take_screenshot() ``` -**Design implication:** IFrame tabs (created via `get_frame()`) inherit all Tab methods but screenshots fail by design. Alternative: `WebElement.take_screenshot()` works for iframe content. +**Design implication:** Historically, Pydoll created dedicated Tab instances for iframes. The new model keeps iframe interaction inside `WebElement`, so screenshots and other helpers should target elements within the frame (for example, `await iframe_element.find(...).take_screenshot()`). **PDF Generation:** `Page.printToPDF` returns base64-encoded data. Pydoll abstracts file I/O, but underlying data is always base64 (CDP spec). diff --git a/docs/en/deep-dive/fundamentals/iframes-and-contexts.md b/docs/en/deep-dive/fundamentals/iframes-and-contexts.md new file mode 100644 index 00000000..cf81673a --- /dev/null +++ b/docs/en/deep-dive/fundamentals/iframes-and-contexts.md @@ -0,0 +1,1292 @@ +# Iframes, OOPIFs and Execution Contexts (Deep Dive) + +Understanding how browser automation handles iframes is critical for building robust automation tools. This comprehensive guide explores the technical foundations of iframe handling in Pydoll, covering the Document Object Model (DOM), Chrome DevTools Protocol (CDP) mechanics, execution contexts, isolated worlds, and the sophisticated resolution pipeline that makes iframe interaction seamless. + +!!! info "Practical usage first" + If you just need to use iframes in your automation scripts, start with the feature guide: **Features → Automation → IFrames**. + This deep dive explains the architectural decisions, protocol nuances, and internal implementation details. + +--- + +## Table of Contents + +1. [Foundation: The Document Object Model (DOM)](#foundation-the-document-object-model-dom) +2. [What are Iframes and Why They Matter](#what-are-iframes-and-why-they-matter) +3. [The Challenge: Out-of-Process Iframes (OOPIFs)](#the-challenge-out-of-process-iframes-oopifs) +4. [Chrome DevTools Protocol and Frame Management](#chrome-devtools-protocol-and-frame-management) +5. [Execution Contexts and Isolated Worlds](#execution-contexts-and-isolated-worlds) +6. [CDP Identifiers Reference](#cdp-identifiers-reference) +7. [Pydoll's Resolution Pipeline](#pydolls-resolution-pipeline) +8. [Session Routing and Flattened Mode](#session-routing-and-flattened-mode) +9. [Implementation Deep Dive](#implementation-deep-dive) +10. [Performance Considerations](#performance-considerations) +11. [Failure Modes and Debugging](#failure-modes-and-debugging) + +--- + +## Foundation: The Document Object Model (DOM) + +Before diving into iframes, we must understand the DOM—the tree structure that represents an HTML document in memory. + +### What is the DOM? + +The **Document Object Model** is a programming interface for HTML and XML documents. It represents the page structure as a tree of nodes, where each node corresponds to a part of the document: + +- **Element nodes**: HTML tags like `