Repository: puppeteer
Issue: [Bug]: puppeteer does not detect the popup page if the document is created using document.write
Labels: bug,confirmed,P3

### Minimal, reproducible example

```TypeScript
(async () => {
  const puppeteer = require('puppeteer');
  const options = {
    headless: true,
  };
  const browser = await puppeteer.launch(options);
  const [page] = await browser.pages();
  page.on('popup', async (popup) => {
    console.log('popup');
  });
  await page.setContent(`
      <!DOCTYPE html>
        <html>

        <head>
          <title>test page</title>
        </head>

        <body>
          <button id="openButton">open</button>
          <script>
            document.getElementById("openButton").addEventListener("click", function () {
              var data = "<h1>test</h1>";
              var win = window.open("data:text/html,popup", "", "scrollbars=yes,resizable=1,modal=false,height=900,width=500,left=10,top=10");
              win.document.write(data);
            });    
          </script>
        </body>

        </html>
    `);
  await page.click('#openButton');
  await page.waitForTimeout(1000);
  if ((await browser.pages()).length === 1) {
    await browser.close();
    throw new Error('Popup is not detected')
  }
  await browser.close();
})();
```


### Error string

Popup is not detected

### Bug behavior

- [ ] Flaky
- [ ] PDF

### Background

A.html 
```
<!DOCTYPE html>
<html>

<head>
  <title>test page</title>
</head>

<body>
  <button id="openButton">open</button>
  <script>
    document.getElementById("openButton").addEventListener("click", function () {
      var data = "<h1>test</h1>";
      var win = window.open("B.html", "", "scrollbars=yes,resizable=1,modal=false,height=900,width=500,left=10,top=10");
      win.document.write(data);
    });    
  </script>
</body>

</html>
```
Then I open this page and simulate clicking the "openButton" with puppeteer as follows:
```
await page.goto("file:///...A.html");
await page.click('#openButton');
```
Next, I will read the pages:
```
const pages = await browser.pages();
```
I am unable to retrieve the pop-up page
And even setting up a pop up event is useless
```
page.on('popup', async (popup) => {
        console.log('popup');
});
```
I tried various methods but couldn't get a new pop-up page.
until I remove the "win. document. write (data)" in the code in A.html; 
```
<!DOCTYPE html>
<html>

<head>
  <title>test page</title>
</head>

<body>
  <button id="openButton">open</button>
  <script>
    document.getElementById("openButton").addEventListener("click", function () {
      var data = "<h1>test</h1>";
      var win = window.open("B.html", "", "scrollbars=yes,resizable=1,modal=false,height=900,width=500,left=10,top=10");
      //win.document.write(data);//---Annotate this line and everything will be fine
    });    
  </script>
</body>

</html>
```

### Expectation

I need to capture the new page that pops up in this situation and save it as a PDF

### Reality

I am unable to obtain the pop-up page

### Puppeteer configuration

```TypeScript
```


### Puppeteer version

20.8.2

### Node version

18.13.0

### Package manager

npm

### Package manager version

9.6.7

### Operating system

Windows