Open Bug 1908515 Opened 3 months ago Updated 2 months ago

[meta] "browsingContext.navigate" fails with NS_BINDING_ABORTED

Categories

(Remote Protocol :: WebDriver BiDi, task)

task

Tracking

(Not tracked)

People

(Reporter: jdescottes, Unassigned)

References

(Depends on 3 open bugs, Blocks 1 open bug)

Details

(Keywords: meta)

Attachments

(1 file)

STRs:

  • start bidi session
  • open a tab
  • send browsingContext.navigate with { url: "https://www.mozilla.org/", wait: "complete" } (also reproduces with "interactive", not with "none")

ER:
Command should succeed.
AR:
Command fails with an NS_BINDING_ABORTED error

Some things to note:

// Handle an aborted navigation. While for an initial document another
// navigation to the real document will happen it's not the case for
// normal documents. Here we need to stop the listener immediately.
if (status == Cr.NS_BINDING_ABORTED && this.isInitialDocument) {
  this.#trace(
    "Ignore aborted navigation error to the initial document."
  );
  return;
}

this.stop({ error: new Error(errorName) });
return;

As you can see, we do ignore NS_BINDING_ABORTED for navigations from the initial document, but maybe we should do it in other situations?

Olli, do you know if it's expected to get a state change to "NS_BINDING_ABORTED" for a navigation which involves redirects? We currently treat those state changes as navigation errors and we fail the command, but maybe there are cases in which those should be ignored?

Flags: needinfo?(smaug)
Attached file http_logs.txt

Attaching http logs for the navigation

So which request is being aborted?

Flags: needinfo?(smaug)

And is that redirection http redirect or does https://www.mozilla.org/en-US/ page itself do something?

And does request.canceledReason https://searchfox.org/mozilla-central/rev/95935109bbbd4a39d612a917e59025f9c81f9d76/netwerk/base/nsIRequest.idl#210 reveal anything?

[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange({isTopLevel:1, isLoadingDocument:0}, {URI:https://www.mozilla.org/, originalURI:https://www.mozilla.org/}, NS_NET_STATUS_WAITING_FOR, "www.mozilla.org") on {top:1, id:b, url:https://www.mozilla.org/en-US/?v=1}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange({isTopLevel:1, isLoadingDocument:0}, {URI:https://www.mozilla.org/en-US/, originalURI:https://www.mozilla.org/}, NS_NET_STATUS_WAITING_FOR, "www.mozilla.org") on {top:1, id:b, url:https://www.mozilla.org/en-US/?v=1}
[Parent 48966: Main Thread]: I/BCWebProgress OnStateChange({isTopLevel:1, isLoadingDocument:0}, {URI:https://www.mozilla.org/en-US/, originalURI:https://www.mozilla.org/}, STATE_START|STATE_IS_REQUEST|STATE_IS_DOCUMENT|STATE_IS_NETWORK|STATE_IS_WINDOW, NS_OK) on {top:1, id:c, url:about:blank}
[Parent 48966: Main Thread]: I/BCWebProgress OnContentBlockingEvent({isTopLevel:1, isLoadingDocument:1}, {URI:https://www.mozilla.org/en-US/, originalURI:https://www.mozilla.org/}, 8000) on {top:1, id:c, url:about:blank}
[Parent 48966: Main Thread]: I/BCWebProgress OnLocationChange({isTopLevel:1, isLoadingDocument:1}, {URI:https://www.mozilla.org/en-US/, originalURI:https://www.mozilla.org/}, https://www.mozilla.org/en-US/, 0) on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnSecurityChange(<null>, <null>, 2) on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Read www.mozilla.org") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Waiting for www.mozilla.org…") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Read www.mozilla.org") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Waiting for www.mozilla.org…") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Read www.mozilla.org") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Waiting for www.mozilla.org…") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Read www.mozilla.org") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Waiting for www.mozilla.org…") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Read www.mozilla.org") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Waiting for www.mozilla.org…") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Read www.mozilla.org") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Waiting for www.mozilla.org…") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Read www.mozilla.org") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Waiting for www.mozilla.org…") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Read www.mozilla.org") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Waiting for www.mozilla.org…") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Read www.mozilla.org") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Waiting for www.mozilla.org…") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Transferring data from www.mozilla.org…") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStateChange({isTopLevel:1, isLoadingDocument:1}, {URI:https://www.mozilla.org/en-US/, originalURI:https://www.mozilla.org/}, STATE_STOP|STATE_IS_NETWORK|STATE_IS_WINDOW, NS_BINDING_ABORTED) on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStateChange({isTopLevel:1, isLoadingDocument:0}, {URI:https://www.mozilla.org/en-US/?v=1, originalURI:https://www.mozilla.org/en-US/?v=1}, STATE_START|STATE_IS_REQUEST|STATE_IS_DOCUMENT|STATE_IS_NETWORK|STATE_IS_WINDOW, NS_OK) on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange({isTopLevel:1, isLoadingDocument:1}, {URI:https://www.mozilla.org/en-US/?v=1, originalURI:https://www.mozilla.org/en-US/?v=1}, NS_NET_STATUS_WAITING_FOR, "www.mozilla.org") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange({isTopLevel:1, isLoadingDocument:1}, {URI:https://www.mozilla.org/en-US/?v=1, originalURI:https://www.mozilla.org/en-US/?v=1}, NS_NET_STATUS_READING, "www.mozilla.org") on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnContentBlockingEvent({isTopLevel:1, isLoadingDocument:1}, {URI:https://www.mozilla.org/en-US/?v=1, originalURI:https://www.mozilla.org/en-US/?v=1}, 8000) on {top:1, id:c, url:https://www.mozilla.org/en-US/}
[Parent 48966: Main Thread]: I/BCWebProgress OnLocationChange({isTopLevel:1, isLoadingDocument:1}, {URI:https://www.mozilla.org/en-US/?v=1, originalURI:https://www.mozilla.org/en-US/?v=1}, https://www.mozilla.org/en-US/?v=1, 0) on {top:1, id:c, url:https://www.mozilla.org/en-US/?v=1}
[Parent 48966: Main Thread]: I/BCWebProgress OnSecurityChange(<null>, <null>, 2) on {top:1, id:c, url:https://www.mozilla.org/en-US/?v=1}
[Parent 48966: Main Thread]: I/BCWebProgress OnStatusChange(<null>, <null>, NS_OK, "Read www.mozilla.org") on {top:1, id:c, url:https://www.mozilla.org/en-US/?v=1}
[Parent 48966: Main Thread]: I/BCWebProgress OnStateChange({isTopLevel:1, isLoadingDocument:1}, {URI:https://www.mozilla.org/en-US/?v=1, originalURI:https://www.mozilla.org/en-US/?v=1}, STATE_STOP|STATE_IS_NETWORK|STATE_IS_WINDOW, NS_OK) on {top:1, id:c, url:https://www.mozilla.org/en-US/?v=1}

Based on the logs above, I think it's the request to https://www.mozilla.org/en-US/, which gets redirected to https://www.mozilla.org/en-US/?v=1 right after ?

(In reply to Olli Pettay [:smaug][bugs@pettay.fi] from comment #5)

And is that redirection http redirect or does https://www.mozilla.org/en-US/ page itself do something?

Good point, it's actually a redirect from https://www.mozilla.org/media/js/fundraising-nav-cta.fb981a2bb772.js which updates window.location.href in JS.

So it's not a real redirect, and it seems to happen before the page had time to fully load.

And does request.canceledReason https://searchfox.org/mozilla-central/rev/95935109bbbd4a39d612a917e59025f9c81f9d76/netwerk/base/nsIRequest.idl#210 reveal anything?

Doesn't seem to hold any value for that request.

Let's keep this bug to properly fail the command when we have a NS_BINDING_ABORTED.
We should file a follow up to check if this is inline with the spec.

Points: --- → 3
Priority: -- → P3
Whiteboard: [webdriver:m12]

Looking at the spec (see https://w3c.github.io/webdriver-bidi/#await-a-navigation step 11), in case we hit navigation-failed case (so the case when we are supposed to send "browsingContext.navigationFailed" event) we should fail the command with "unknown error", and with my patches on bug 1846601 we will send "browsingContext.navigationFailed" event (this falls in the scenario when one navigation is interrupted by the next one), so failing the command seems right as well and the error type is correct as well.
The only thing is that now we basically propagate the exception, and maybe in the future we want to do something more elegant and return a more user-friendly error message.

It could be interesting to check Chrome's behavior in this case and if there's a difference discuss it a bit with Google folks.

See Also: → 1905083

(In reply to Julian Descottes [:jdescottes] from comment #10)

It could be interesting to check Chrome's behavior in this case and if there's a difference discuss it a bit with Google folks.

I've checked Chrome, and it looks like it doesn't fail the navigation in this case. But I've also tried to run the tests for "browsingContext.navigationFailed" for the case of interrupted navigation, and Chrome fails them. So maybe they just don't support this use case yet.

I discovered another case where this bug appears. WebdriverIO initiates some preload scripts and runs into issues when loading certain web pages. Ultimately the command fails with the following error:

{"type":"error","id":3,"error":"unknown error","message":"Error: NS_BINDING_ABORTED","stacktrace":"#checkLoadingState@chrome://remote/content/shared/Navigate.sys.mjs:286:28\nonStateChange@chrome://remote/content/shared/Navigate.sys.mjs:345:28\n"}

It seems to only happen in Nightly and when these certain additional commands are called before:

session.subscribe {"events":["log.entryAdded","browsingContext.contextCreated","browsingContext.contextDestroyed"]}
script.addPreloadScript {"functionDeclaration":"function customElementWrapper() {\n    const origFn = customElements.define.bind(customElements);\n    customElements.define = function (name, Constructor, options) {\n        class WdioWrapperElement extends Constructor {\n            connectedCallback() {\n                super.connectedCallback && super.connectedCallback();\n                let parentNode = this;\n                while (parentNode.parentNode) {\n                    parentNode = parentNode.parentNode;\n                }\n                console.debug('[WDIO]', 'newShadowRoot', this, parentNode);\n            }\n            disconnectedCallback() {\n                super.disconnectedCallback && super.disconnectedCallback();\n                console.debug('[WDIO]', 'removeShadowRoot', this);\n            }\n        }\n        return origFn(name, WdioWrapperElement, options);\n    };\n}"}

I've created a reproduction case: https://github.com/christian-bromann/bidi-issue-ff .. just run npm install and then node test.js.

The severity field is not set for this bug.
:whimboo, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(hskupin)

(In reply to Christian Bromann from comment #12)

I've created a reproduction case: https://github.com/christian-bromann/bidi-issue-ff .. just run npm install and then node test.js.

As it looks like this happens only for the first time I navigate to that page. Further navigation commands return success. To reproduce the following code can be run in the BiDi demo client:

(async function() {
    await sendCommand("session.new", { capabilities: {} });

    await sendCommand("session.subscribe", {"events":["log.entryAdded","browsingContext.contextCreated","browsingContext.contextDestroyed"]});
    await sendCommand("script.addPreloadScript", {"functionDeclaration":"function customElementWrapper() {\n    const origFn = customElements.define.bind(customElements);\n    customElements.define = function (name, Constructor, options) {\n        class WdioWrapperElement extends Constructor {\n            connectedCallback() {\n                super.connectedCallback && super.connectedCallback();\n                let parentNode = this;\n                while (parentNode.parentNode) {\n                    parentNode = parentNode.parentNode;\n                }\n                console.debug('[WDIO]', 'newShadowRoot', this, parentNode);\n            }\n            disconnectedCallback() {\n                super.disconnectedCallback && super.disconnectedCallback();\n                console.debug('[WDIO]', 'removeShadowRoot', this);\n            }\n        }\n        return origFn(name, WdioWrapperElement, options);\n    };\n}"});
  
    let res = await sendCommand("browsingContext.getTree", {});

    const context = res.result.contexts[0].context;
    await sendCommand("browsingContext.navigate", {
      context,
      url: "http://guinea-pig.webdriver.io/",
      wait: "complete"
    });

    // Do stuff ...
  })()

I wonder if we should make that bug a meta one and file individual bugs covering this scenario.

Severity: -- → S3
Flags: needinfo?(hskupin)

I did a bit of testing and I think with the http://guinea-pig.webdriver.io/ page the issue is that it's http page, I've tried also a couple other pages (e.g. http://help.websiteos.com/websiteos/example_of_a_simple_html_page.htm) and they also triggered NS_BINDING_ABORTED error on the first navigation.

Ah, could this be maybe related to the HTTPS-only mode and that we are trying to forward to https://guinea-pig.webdriver.io/ but that is not available and we run into an error page.

Whiteboard: [webdriver:m12] → [webdriver:m12][webdriver:triage]

As discussed in our triage meeting on Monday we are going to make that a meta bug given that we see the same kind of failure for different sites, which itself could have different underlying issues. All will file new bugs for the known websites and mark them all blocking this bug.

Severity: S3 → --
Type: defect → task
Points: 3 → ---
Keywords: meta
Priority: P3 → --
Summary: browsingContext.navigate fails with NS_BINDING_ABORTED → [meta] "browsingContext.navigate" fails with NS_BINDING_ABORTED
Whiteboard: [webdriver:m12][webdriver:triage]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: