commit 48532131c7bfc7f4587e8738a59cdd95d56da576 parent b9e0f209c655474b6d0373f7a52f925c49bbd53e Author: Sandor Molnar <smolnar@mozilla.com> Date: Wed, 7 Jan 2026 19:17:28 +0200 Revert "Bug 2008770 - Fix HTMLDialogElement mock to prevent coverage reporting failures. r=home-newtab-reviewers,reemhamz" on devs request. This reverts commit 74395b07a6c495b92bf1050e59ba6f31cc027ac7. Diffstat:
| M | browser/extensions/newtab/test/unit/unit-entry.js | | | 21 | +++++++++------------ |
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/browser/extensions/newtab/test/unit/unit-entry.js b/browser/extensions/newtab/test/unit/unit-entry.js @@ -37,20 +37,17 @@ chai.use(chaiAssertions); const overrider = new GlobalOverrider(); -// Create HTMLDialogElement mock if it doesn't exist -if (typeof window.HTMLDialogElement === "undefined") { - window.HTMLDialogElement = function () {}; - window.HTMLDialogElement.prototype = Object.create(HTMLElement.prototype); +// Patch dialog element's .showModal()/close() functions to prevent errors in tests +// Some test environments may not have proper HTMLDialogElement support +if (typeof HTMLDialogElement !== "undefined") { + HTMLDialogElement.prototype.showModal = function () { + this.open = true; + }; + HTMLDialogElement.prototype.close = function () { + this.open = false; + }; } -// Patch the showModal and close methods -window.HTMLDialogElement.prototype.showModal = function () { - this.open = true; -}; -window.HTMLDialogElement.prototype.close = function () { - this.open = false; -}; - const RemoteSettings = name => ({ get: () => { if (name === "attachment") {