commit 74395b07a6c495b92bf1050e59ba6f31cc027ac7 parent 73f3240120eb777af86695f90afdc9c71d89a008 Author: Maxx Crawford <mcrawford@mozilla.com> Date: Tue, 6 Jan 2026 23:53:07 +0000 Bug 2008770 - Fix HTMLDialogElement mock to prevent coverage reporting failures. r=home-newtab-reviewers,reemhamz Differential Revision: https://phabricator.services.mozilla.com/D278057 Diffstat:
| M | browser/extensions/newtab/test/unit/unit-entry.js | | | 21 | ++++++++++++--------- |
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/browser/extensions/newtab/test/unit/unit-entry.js b/browser/extensions/newtab/test/unit/unit-entry.js @@ -37,17 +37,20 @@ chai.use(chaiAssertions); const overrider = new GlobalOverrider(); -// 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; - }; +// Create HTMLDialogElement mock if it doesn't exist +if (typeof window.HTMLDialogElement === "undefined") { + window.HTMLDialogElement = function () {}; + window.HTMLDialogElement.prototype = Object.create(HTMLElement.prototype); } +// 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") {