commit d6d0055082ffa41e4275301a380e9e615554bf0c
parent 382ceaa59195161d14c4d9ea8c5d446276285fc8
Author: Cristina Horotan <chorotan@mozilla.com>
Date: Mon, 12 Jan 2026 03:55:43 +0200
Revert "Bug 2008770 - Fix HTMLDialogElement mock to prevent coverage reporting failures. r=home-newtab-reviewers,nina-py" on request for causing frequent failures
This reverts commit db0a1bb9944c78cf37b8953a9158f2367c601e31.
Diffstat:
3 files changed, 11 insertions(+), 24 deletions(-)
diff --git a/browser/extensions/newtab/test/unit/content-src/components/ModalOverlay.test.jsx b/browser/extensions/newtab/test/unit/content-src/components/ModalOverlay.test.jsx
@@ -2,18 +2,6 @@ import { ModalOverlayWrapper } from "content-src/components/ModalOverlay/ModalOv
import { mount } from "enzyme";
import React from "react";
-// Patch dialog element's .showModal()/close() functions to prevent errors in tests
-before(() => {
- if (typeof HTMLDialogElement !== "undefined") {
- HTMLDialogElement.prototype.showModal = function () {
- this.open = true;
- };
- HTMLDialogElement.prototype.close = function () {
- this.open = false;
- };
- }
-});
-
describe("ModalOverlayWrapper", () => {
let sandbox;
beforeEach(() => {
diff --git a/browser/extensions/newtab/test/unit/content-src/components/TopSites.test.jsx b/browser/extensions/newtab/test/unit/content-src/components/TopSites.test.jsx
@@ -25,18 +25,6 @@ import { TopSiteFormInput } from "content-src/components/TopSites/TopSiteFormInp
import { _TopSites as TopSites } from "content-src/components/TopSites/TopSites";
import { ContextMenuButton } from "content-src/components/ContextMenu/ContextMenuButton";
-// Patch dialog element's .showModal()/close() functions to prevent errors in tests
-before(() => {
- if (typeof HTMLDialogElement !== "undefined") {
- HTMLDialogElement.prototype.showModal = function () {
- this.open = true;
- };
- HTMLDialogElement.prototype.close = function () {
- this.open = false;
- };
- }
-});
-
const perfSvc = {
mark() {},
getMostRecentAbsMarkStartByName() {},
diff --git a/browser/extensions/newtab/test/unit/unit-entry.js b/browser/extensions/newtab/test/unit/unit-entry.js
@@ -37,6 +37,17 @@ 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;
+ };
+}
+
const RemoteSettings = name => ({
get: () => {
if (name === "attachment") {