Closed Bug 1909822 Opened 4 months ago Closed 4 months ago

BiDi sessions should automatically handle prompts based on unhandledPromptBehavior

Categories

(Remote Protocol :: WebDriver BiDi, defect)

defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1905086

People

(Reporter: jdescottes, Unassigned)

Details

At the moment, the only time our WebDriver implementation automatically handles a prompt is at https://searchfox.org/mozilla-central/rev/d353cfa1fbd207e13dc974f30e5f88535a4303ae/remote/marionette/driver.sys.mjs#221-234

GeckoDriver.prototype.handleOpenModalDialog = function (eventName, data) {
  this.dialog = data.prompt;

  if (this.dialog.promptType === "beforeunload" && !this.currentSession?.bidi) {
    // Only implicitly accept the prompt when its not a BiDi session.
    lazy.logger.trace(`Implicitly accepted "beforeunload" prompt`);
    this.dialog.accept();
    return;
  }

  if (!this._isShuttingDown) {
    this.getActor().notifyDialogOpened(this.dialog);
  }
};

As we can see in the code, this only applies to HTTP only sessions.

For BiDi sessions, we never attempt to handle prompts automatically. However according to https://github.com/whatwg/html/pull/10189 we should automatically handle them if a userPromptHandler is configured for this prompt type.

Note that the WebDriver classic spec was a bit confusing for me, especially the part reading:

Whenever active sessions is a list containing exactly one item, and that item is a HTTP session, but is not a BiDi session, then in the steps to fire beforeunload, implementations must act as if showing an unload prompt is likely to be annoying, deceptive, or pointless.

which made it sound like for BiDi enabled sessions we should do nothing. But it's not the intent. When a prompt is opened HTML will invoke https://w3c.github.io/webdriver-bidi/#webdriver-bidi-user-prompt-opened and use the returned handler to decide what to do with the prompt.

For instance configuring { default: "dismiss" } should automatically dismiss all user prompts, whatever their type is.

Was already filed as Bug 1905086

Status: NEW → RESOLVED
Closed: 4 months ago
Duplicate of bug: 1905086
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.