**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
if (this.overlayManager.active === this.dialog) {
      this.overlayManager.close(this.dialog);
    }
  }
  #verify() {
    const password = this.input.value;
    if (password?.length > 0) {
      this.#invokeCallback(password);
    }
  }
  #cancel() {
    this.#invokeCallback(new Error("PasswordPrompt cancelled."));
  }
  #invokeCallback(password) {
    if (!this.#updateCallback) {
      return; 
    }
    this.close();
    this.input.value = "";
    this.#updateCallback(password);
    this.#updateCallback = null;
  }
  setUpdateCallback(updateCallback, reason) {
    this.#updateCallback = updateCallback;
    this.#reason = reason;
  }
}
export { PasswordPrompt };