chromedp / chromedp

A faster, simpler way to drive browsers supporting the Chrome DevTools Protocol.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GetOuterHTML().WithPierce(true) not returning <iframe> contents

azurda opened this issue · comments

What versions are you running?

$ go list -m github.com/chromedp/chromedp
github.com/chromedp/chromedp v0.9.5
$ 123.0.6312.87 
go version
 go1.20.5 darwin/arm64

What did you do? Include clear steps.

Reproducible file: https://github.com/go-rod/rod/blob/main/fixtures/click-iframe.html

Relevant code section contained in chromedp.ActionFunc :

rootNode, err := dom.GetDocument().WithPierce(true).WithDepth(-1).Do(ctx)

if err != nil {
  return err 
}

htmlSource, err := dom.GetOuterHTML().WithNodeID(rootNode.NodeID).Do(ctx)

if err != nil {
 return err 
}

fmt.Println(htmlSource)

What did you expect to see?

I expected to see the whole DOM including the nested rendered content when using WithPierce(true). I know it is possible to create a context from the iframe target but that would require inserting the content later into the output of GetOuterHTML()

image

What did you see instead?

<html><head><style>
    iframe {
      margin: 100px;
      height: 200px;
      width: 200px;
    }
  </style>
  </head><body>
    <iframe src="./click.html"></iframe>

    <script>
      function testIsolation() {
        return 'ok'
      }
      testIsolation()
    </script>


</body></html