**Attach (recommended) or Link to PDF file here:**
[document-protected.pdf](https://github.com/mozilla/pdf.js/files/9377476/document-protected.pdf) (pwd: helloWorld)

**Configuration**:
- Web browser and Operating system : 
Safari (15.3) on macOS Monterey (12.2.1) and
Firefox (91.9.1esr) on Windows 11
- PDF.js version: latest
- Is a browser extension: N/A

**Steps to reproduce the problem:**
1. In Legacy viewer open password protected file.
2. Type password 

**What is the expected behavior? (add screenshot)**
You should be able to view the file.

**What went wrong? (add screenshot)**

Dialog close() is not supported which throws an error and interrupts the password verification 

Error: No given password

<img width="1342" alt="Screen Shot 2022-08-18 at 5 15 14 PM" src="https://user-images.githubusercontent.com/6955509/185496508-25fabb44-55fa-492b-8e96-3697951c230e.png">



Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension):
https://mozilla.github.io/pdf.js/legacy/web/viewer.html
#updateCallback = null;
  #reason = null;
  /**
   * @param {PasswordPromptOptions} options
   * @param {OverlayManager} overlayManager - Manager for the viewer overlays.
   * @param {IL10n} l10n - Localization service.
   * @param {boolean} [isViewerEmbedded] - If the viewer is embedded, in e.g.
   *   an <iframe> or an <object>. The default value is `false`.
   */
  constructor(options, overlayManager, l10n, isViewerEmbedded = false) {
    this.dialog = options.dialog;
    this.label = options.label;
    this.input = options.input;
    this.submitButton = options.submitButton;
    this.cancelButton = options.cancelButton;
    this.overlayManager = overlayManager;
    this.l10n = l10n;
    this._isViewerEmbedded = isViewerEmbedded;
    
    this.submitButton.addEventListener("click", this.#verify.bind(this));
    this.cancelButton.addEventListener("click", this.#cancel.bind(this));
    this.input.addEventListener("keydown", e => {
      if (e.keyCode ===  13) {
        this.#verify();
      }
    });
    this.overlayManager.register(this.dialog,  true);
    this.dialog.addEventListener("close", this.#cancel.bind(this));
  }
  async open() {