You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Goal**: For Out-of-Process Iframes, find the target, attach to it, and obtain the `frameId` from the target's frame tree.
720
+
**Goal**: For Out-of-Process Iframes, find the correct target, attach to it, and obtain the `frameId` from the target's frame tree (and the routing `sessionId` when needed).
721
+
722
+
**When this runs**:
723
+
724
+
- Same-origin / in-process iframes that already have a `frameId` and **no**`backendNodeId` skip this step (they are handled directly).
725
+
- Cross-origin / OOPIF iframes (with `backendNodeId`) or iframes whose `frameId` could not be resolved via Step 2 use this step.
721
726
722
727
**Strategy**:
723
728
724
-
**3a. Direct child target lookup**:
729
+
**3a. Direct child target lookup (fast path)**:
730
+
731
+
1. Call `Target.getTargets()` to list all debugging targets.
732
+
2. Filter targets where `type` is `"iframe"` or `"page"` and `parentFrameId` matches our parent frame.
733
+
3. If there is **exactly one** matching child **and we don't have a `backendNodeId`**, attach directly to that target with `Target.attachToTarget(targetId, flatten=true)`.
734
+
4. Fetch `Page.getFrameTree(sessionId)` for that target; the root frame of this tree is our iframe's frame.
735
+
736
+
When there are **multiple** direct children or we have a `backendNodeId` (typical OOPIF case), Pydoll iterates over each child target:
725
737
726
-
1. Call `Target.getTargets()` to list all debugging targets
727
-
2. Filter targets where `type` is `"iframe"` or `"page"` and `parentFrameId` matches our parent frame
728
-
3. If found, attach to that target with `Target.attachToTarget(targetId, flatten=true)`
729
-
4. The response includes a `sessionId`
730
-
5. Fetch `Page.getFrameTree(sessionId)` for that target
731
-
6. The root frame of this tree is our iframe's frame
738
+
1. Attach via `Target.attachToTarget(flatten=true)`.
739
+
2. Fetch `Page.getFrameTree(sessionId)` and read the root `frame.id`.
740
+
3. Call `DOM.getFrameOwner(frameId=root_id)` on the **main** connection.
741
+
4. Compare the returned `backendNodeId` with our iframe element's `backendNodeId`.
742
+
5. The child whose root owner matches is selected as the correct OOPIF target.
732
743
733
-
**3b. Fallback: Scan all targets**:
744
+
**3b. Fallback: Scan all targets (root owner + child search)**:
734
745
735
-
1. Iterate all iframe/page targets
736
-
2. Attach to each and fetch its frame tree
737
-
3. Look for a child frame whose `parentId` matches our parent frame
738
-
4.**OR** check if the root frame's owner (via `DOM.getFrameOwner`) matches our iframe's `backendNodeId`
746
+
If no suitable direct child is found (or when `parentFrameId` information is incomplete), Pydoll falls back to scanning **all** iframe/page targets:
747
+
748
+
1. Iterate all iframe/page targets.
749
+
2. Attach to each and fetch its frame tree.
750
+
3. First, try to match the **root frame owner** via `DOM.getFrameOwner(root_frame_id)` against our iframe's `backendNodeId`.
751
+
4. If that does not match, look for a **child frame** whose `parentId` equals our `parent_frame_id` (this covers cases where the OOPIF is nested under an intermediate frame).
**Objetivo**: Para Iframes Fora de Processo, encontrar o alvo (target), anexar a ele, e obter o `frameId` da árvore de frames do alvo.
720
+
**Objetivo**: Para Iframes Fora de Processo, encontrar o alvo correto, anexar a ele e obter o `frameId` da árvore de frames do alvo (e o `sessionId` de roteamento quando necessário).
721
+
722
+
**Quando esse passo roda**:
723
+
724
+
- Iframes de **mesma origem** / in-process que já têm um `frameId` e **não** têm `backendNodeId` pulam esse passo (são tratados diretamente).
725
+
- Iframes **cross-origin / OOPIF** (com `backendNodeId`) ou iframes cujo `frameId` não pôde ser resolvido no Passo 2 usam esse passo.
721
726
722
727
**Estratégia**:
723
728
724
-
**3a. Busca por alvo filho direto**:
729
+
**3a. Busca por alvo filho direto (caminho rápido)**:
730
+
731
+
1. Chamar `Target.getTargets()` para listar todos os alvos de depuração.
732
+
2. Filtrar alvos onde `type` é `"iframe"` ou `"page"` e `parentFrameId` bate com nosso frame pai.
733
+
3. Se houver **apenas um** filho direto **e não houver `backendNodeId`**, anexar diretamente a esse alvo com `Target.attachToTarget(targetId, flatten=true)`.
734
+
4. Buscar `Page.getFrameTree(sessionId)` para aquele alvo; o frame raiz dessa árvore é o frame do nosso iframe.
735
+
736
+
Quando existem **múltiplos** filhos diretos ou temos um `backendNodeId` (caso típico de OOPIF), o Pydoll itera sobre cada alvo filho:
725
737
726
-
1. Chamar `Target.getTargets()` para listar todos os alvos de depuração
727
-
2. Filtrar alvos onde `type` é `"iframe"` ou `"page"` e `parentFrameId` bate com nosso frame pai
728
-
3. Se encontrado, anexar àquele alvo com `Target.attachToTarget(targetId, flatten=true)`
729
-
4. A resposta inclui um `sessionId`
730
-
5. Buscar `Page.getFrameTree(sessionId)` para aquele alvo
731
-
6. O frame raiz desta árvore é o frame do nosso iframe
738
+
1. Anexa com `Target.attachToTarget(flatten=true)`.
739
+
2. Busca `Page.getFrameTree(sessionId)` e lê o `frame.id` raiz.
740
+
3. Chama `DOM.getFrameOwner(frameId=root_id)` na conexão principal.
741
+
4. Compara o `backendNodeId` retornado com o `backendNodeId` do elemento `<iframe>` original.
742
+
5. O filho cujo dono raiz coincide é selecionado como o alvo OOPIF correto.
732
743
733
-
**3b. Fallback: Escanear todos os alvos**:
744
+
**3b. Fallback: Escanear todos os alvos (dono raiz + busca por filho)**:
734
745
735
-
1. Iterar todos os alvos iframe/page
736
-
2. Anexar a cada um e buscar sua árvore de frames
737
-
3. Procurar por um frame filho cujo `parentId` bate com nosso frame pai
738
-
4.**OU** checar se o dono do frame raiz (via `DOM.getFrameOwner`) bate com o `backendNodeId` do nosso iframe
746
+
Se nenhum filho direto adequado for encontrado (ou se `parentFrameId` estiver incompleto), o Pydoll recorre a escanear **todos** os alvos iframe/page:
747
+
748
+
1. Iterar todos os alvos iframe/page.
749
+
2. Anexar a cada um e buscar sua árvore de frames.
750
+
3. Primeiro, tentar casar o **dono do frame raiz** via `DOM.getFrameOwner(root_frame_id)` com o `backendNodeId` do iframe.
751
+
4. Se isso não bater, procurar um **frame filho** cujo `parentId` seja o `parent_frame_id` (isso cobre casos em que o OOPIF está aninhado sob um frame intermediário).
0 commit comments