**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
/* Copyright 2012 Mozilla Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { PasswordResponses } from "pdfjs-lib";
/**
 * @typedef {Object} PasswordPromptOptions
 * @property {HTMLDialogElement} dialog - The overlay's DOM element.
 * @property {HTMLParagraphElement} label - Label containing instructions for
 *                                          entering the password.
 * @property {HTMLInputElement} input - Input field for entering the password.
 * @property {HTMLButtonElement} submitButton - Button for submitting the
 *                                              password.
 * @property {HTMLButtonElement} cancelButton - Button for cancelling password
 *                                              entry.
 */
class PasswordPrompt {