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

Navigating to some websites is not possible #2709

Open
OrKoN opened this issue Oct 22, 2024 · 7 comments
Open

Navigating to some websites is not possible #2709

OrKoN opened this issue Oct 22, 2024 · 7 comments
Assignees
Labels
bug Something isn't working P1

Comments

@OrKoN
Copy link
Collaborator

OrKoN commented Oct 22, 2024

import puppeteer from "puppeteer";

const browser = await puppeteer.launch({
	protocol: "webDriverBiDi"
});

const page = await browser.newPage();

await page.goto("https://x.com/"); // Crash!

await browser.close();

Results in

file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:89
    #error = new ProtocolError();
             ^

ProtocolError: Protocol error (browsingContext.navigate): unknown error navigation canceled, as new navigation is requested by scriptInitiated Error
    at new UnknownErrorException (/Users/alexrudenko/src/pptr-test/node_modules/chromium-bidi/lib/cjs/protocol/ErrorResponse.js:122:39)
    at /Users/alexrudenko/src/pptr-test/node_modules/chromium-bidi/lib/cjs/bidiMapper/modules/context/BrowsingContextImpl.js:348:52
    at /Users/alexrudenko/src/pptr-test/node_modules/mitt/dist/mitt.js:1:255
    at Array.map (<anonymous>)
    at Object.emit (/Users/alexrudenko/src/pptr-test/node_modules/mitt/dist/mitt.js:1:239)
    at CDPClientAdapter.emit (/Users/alexrudenko/src/pptr-test/node_modules/chromium-bidi/lib/cjs/utils/EventEmitter.js:55:23)
    at #forwardMessage (file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/puppeteer/bidi/BidiOverCdp.js:98:14)
    at file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/third_party/mitt/mitt.js:38:7
    at Array.map (<anonymous>)
    at Object.emit (file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/third_party/mitt/mitt.js:37:39) at https://x.com/
    at <instance_members_initializer> (file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:89:14)
    at new Callback (file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:93:16)
    at CallbackRegistry.create (file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/puppeteer/common/CallbackRegistry.js:19:26)
    at BidiConnection.send (file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/puppeteer/bidi/Connection.js:51:32)
    at Session.send (file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/puppeteer/bidi/core/Session.js:134:42)
    at Session.<anonymous> (file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/puppeteer/util/decorators.js:96:27)
    at BrowsingContext.navigate (file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/puppeteer/bidi/core/BrowsingContext.js:306:33)
    at BrowsingContext.<anonymous> (file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/puppeteer/util/decorators.js:96:27)
    at BidiFrame.goto (file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/puppeteer/bidi/Frame.js:336:22)
    at BidiFrame.<anonymous> (file:///Users/alexrudenko/src/pptr-test/node_modules/puppeteer-core/lib/esm/puppeteer/util/decorators.js:96:27)

Originally reported in puppeteer/puppeteer#12929

@OrKoN
Copy link
Collaborator Author

OrKoN commented Oct 22, 2024

@sadym-chromium would you be able to take a look?

@OrKoN OrKoN added bug Something isn't working P1 labels Oct 22, 2024
@OrKoN OrKoN changed the title Navigating to real-world websites is not possible Navigating to some websites is not possible Oct 22, 2024
@sadym-chromium
Copy link
Collaborator

on it

@sadym-chromium
Copy link
Collaborator

sadym-chromium commented Oct 22, 2024

It looks like this is what WebDriver BiDi specifies to do:

  1. Puppeteer sends he command 'browsingContext.navigate' with wait: 'interactive' and url: 'https://x.com'. The navigation will be finished on 'domContentLoaded' or 'navigation failed' event.
  2. (for whatever reason I cannot get the response body of the initial navigation to https://x.com, so this is my speculation) x.com sets window.location to https://twitter.com/x/migrate?tok=....
  3. This causes navigation, and specifically this HTML spec step:
  4. The Unloading documents causes the initial navigation (requested by the user) to fail.

@OrKoN
Copy link
Collaborator Author

OrKoN commented Oct 22, 2024

We looked offline and we could not confirm that unload counter step is actually the reason. At least, we should add a specific error code for this situation so that the client knows to wait for subsequent navigation IDs to implement waiting.

@sadym-chromium
Copy link
Collaborator

Spec:

@juliandescottes
Copy link

Spec:

* [`browsingContext.navigate`](https://w3c.github.io/webdriver-bidi/#command-browsingContext-navigate)

* [Aawait a navigation](https://w3c.github.io/webdriver-bidi/#await-a-navigation):

* [Navigate](https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate) navigable...

* [navigate](https://html.spec.whatwg.org/#navigate), step 22.3: [abort a document and its descendants](https://html.spec.whatwg.org/#abort-a-document-and-its-descendants) given navigable's [active document](https://html.spec.whatwg.org/#nav-document).

* [Abort a document and its descendants](https://html.spec.whatwg.org/#abort-a-document-and-its-descendants):

* [Abort a document](https://html.spec.whatwg.org/#abort-a-document)

* If document's [during-loading navigation ID for WebDriver BiDi](https://html.spec.whatwg.org/#concept-document-navigation-id) is non-null, then:

* Invoke [WebDriver BiDi navigation aborted](https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-aborted) (emits `browsingContext.navigationAborted` event).

* This case does not fall under **_"If event received is "navigation failed" return [error](https://w3c.github.io/webdriver/#dfn-errors) with [error code](https://w3c.github.io/webdriver/#dfn-error-code) [unknown error](https://w3c.github.io/webdriver/#dfn-unknown-error)"_**

* The command should **_"Return [success](https://w3c.github.io/webdriver/#dfn-success) with data body."_**

Thanks for checking this! So as it looks like we should not fail the navigation for abort scenarios? I assume the current tests at web-platform-tests/wpt#48751 need to be updated to reflect this?

@OrKoN
Copy link
Collaborator Author

OrKoN commented Oct 22, 2024

Spec:

* [`browsingContext.navigate`](https://w3c.github.io/webdriver-bidi/#command-browsingContext-navigate)

* [Aawait a navigation](https://w3c.github.io/webdriver-bidi/#await-a-navigation):

* [Navigate](https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate) navigable...

* [navigate](https://html.spec.whatwg.org/#navigate), step 22.3: [abort a document and its descendants](https://html.spec.whatwg.org/#abort-a-document-and-its-descendants) given navigable's [active document](https://html.spec.whatwg.org/#nav-document).

* [Abort a document and its descendants](https://html.spec.whatwg.org/#abort-a-document-and-its-descendants):

* [Abort a document](https://html.spec.whatwg.org/#abort-a-document)

* If document's [during-loading navigation ID for WebDriver BiDi](https://html.spec.whatwg.org/#concept-document-navigation-id) is non-null, then:

* Invoke [WebDriver BiDi navigation aborted](https://w3c.github.io/webdriver-bidi/#webdriver-bidi-navigation-aborted) (emits `browsingContext.navigationAborted` event).

* This case does not fall under **_"If event received is "navigation failed" return [error](https://w3c.github.io/webdriver/#dfn-errors) with [error code](https://w3c.github.io/webdriver/#dfn-error-code) [unknown error](https://w3c.github.io/webdriver/#dfn-unknown-error)"_**

* The command should **_"Return [success](https://w3c.github.io/webdriver/#dfn-success) with data body."_**

Thanks for checking this! So as it looks like we should not fail the navigation for abort scenarios? I assume the current tests at web-platform-tests/wpt#48751 need to be updated to reflect this?

I suspect it is not the intention not to fail here so perhaps we need to discuss what's expected in this situation.

sadym-chromium added a commit that referenced this issue Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1
Projects
None yet
Development

No branches or pull requests

3 participants