// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. // jsdom lacks a few browser features the UI uses. if (typeof HTMLDialogElement !== "undefined") { const p = HTMLDialogElement.prototype as HTMLDialogElement & Record; if (!p.showModal) { p.showModal = function (this: HTMLDialogElement) { this.setAttribute("open", ""); }; p.show = function (this: HTMLDialogElement) { this.setAttribute("open", ""); }; p.close = function (this: HTMLDialogElement) { this.removeAttribute("open"); }; } } const clipboard = { text: "", writeText: async (t: string) => void (clipboard.text = t) }; Object.defineProperty(globalThis.navigator, "clipboard", { value: clipboard, configurable: true }); (globalThis as unknown as { __clipboard: typeof clipboard }).__clipboard = clipboard; if (!("BroadcastChannel" in globalThis)) { (globalThis as unknown as { BroadcastChannel: unknown }).BroadcastChannel = class { onmessage: unknown = null; postMessage() {} close() {} }; } if (!("randomUUID" in crypto)) { Object.defineProperty(crypto, "randomUUID", { value: () => Math.random().toString(36).slice(2) }); } window.open = () => null; HTMLAnchorElement.prototype.click = function () {};