Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: The popup listener can't catch popups. #12440

Open
2 tasks
alpgul opened this issue May 14, 2024 · 4 comments
Open
2 tasks

[Bug]: The popup listener can't catch popups. #12440

alpgul opened this issue May 14, 2024 · 4 comments

Comments

@alpgul
Copy link

alpgul commented May 14, 2024

Minimal, reproducible example

const puppeteer = require("puppeteer");
async function main() {

  const browser = await puppeteer.launch({
    //ignoreDefaultArgs: ["--enable-automation"],
    args: [],
    //executablePath: localExecutablePath,
    headless: false,
  });
  console.log("Browser is created.");
  const pages = await browser.pages();
  const page = pages[0];
  page.on('popup', async (popup) => {
    console.log(await popup.url());
    await popup.close();
  });
}
main();

Error string

no error

Bug behavior

  • Flaky
  • PDF

Background

Popup1:

    const c = document.createElement("a")
                  , d = document.createEvent("MouseEvents");
                c.href = "https://example.com/test/7",
                d.initMouseEvent("click", !1, !0, window, 0, 0, 0, 0, 0, !0, !1, !1, !0, 0, null),
                c.dispatchEvent(d)

Popup2:

 <a href="https://example.com/test/12" id="id4"></a>
document.getElementById("id4").dispatchEvent(new MouseEvent("click",{
                        button: 1
                    }));

The two popups mentioned above are not being detected. I conducted the tests on the following website: https://webbrowsertools.com/popup-blocker/.

Expectation

It was expected that the popups would show their URLs and then close.

Reality

The popup listener isn't working.

Puppeteer configuration file (if used)

No response

Puppeteer version

22.8.1

Node version

v21.7.1

Package manager

npm

Package manager version

10.6.0

Operating system

Windows

Copy link

This issue was not reproducible. Please check that your example runs locally and the following:

  • Ensure the script does not rely on dependencies outside of puppeteer and puppeteer-core.
  • Ensure the error string is just the error message.
    • Bad:

      Error: something went wrong
        at Object.<anonymous> (/Users/username/repository/script.js:2:1)
        at Module._compile (node:internal/modules/cjs/loader:1159:14)
        at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
        at Module.load (node:internal/modules/cjs/loader:1037:32)
        at Module._load (node:internal/modules/cjs/loader:878:12)
        at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
        at node:internal/main/run_main_module:23:47
    • Good: Error: something went wrong.

  • Ensure your configuration file (if applicable) is valid.
  • If the issue is flaky (does not reproduce all the time), make sure 'Flaky' is checked.
  • If the issue is not expected to error, make sure to write 'no error'.

Once the above checks are satisfied, please edit your issue with the changes and we will
try to reproduce the bug again.


Analyzer run

@OrKoN
Copy link
Collaborator

OrKoN commented May 14, 2024

CDP does not report openerId for those. Therefore, Puppeteer is not able to associate two pages https://chromedevtools.github.io/devtools-protocol/tot/Target/#type-TargetInfo This issue needs to be reported to crbug.com

@OrKoN OrKoN added the upstream label May 14, 2024
@OrKoN
Copy link
Collaborator

OrKoN commented May 14, 2024

For future reference, the CDP event is '{"method":"Target.targetCreated","params":{"targetInfo":{"targetId":"82DB46C028FD16D794AF3041E3936B0B","type":"page","title":"","url":"https://example.com/test/7","attached":false,"canAccessOpener":false,"browserContextId":"C667CFDC10271A29C516732812EAC3D2"}}}'

@OrKoN
Copy link
Collaborator

OrKoN commented May 14, 2024

Probably related #10546

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants