summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dom/html/HTMLDialogElement.cpp29
-rw-r--r--dom/html/HTMLDialogElement.h2
-rw-r--r--dom/tests/mochitest/general/test_interfaces.html2
-rw-r--r--dom/webidl/HTMLDialogElement.webidl1
-rw-r--r--modules/libpref/init/all.js3
-rw-r--r--testing/web-platform/meta/html/dom/interfaces.html.ini2
-rw-r--r--testing/web-platform/meta/html/dom/reflection-misc.html.ini2
-rw-r--r--testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-close.html.ini3
-rw-r--r--testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-open.html.ini3
-rw-r--r--testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html.ini1
-rw-r--r--testing/web-platform/meta/html/semantics/interfaces.html.ini2
11 files changed, 45 insertions, 5 deletions
diff --git a/dom/html/HTMLDialogElement.cpp b/dom/html/HTMLDialogElement.cpp
index 1f65b602f..48666628e 100644
--- a/dom/html/HTMLDialogElement.cpp
+++ b/dom/html/HTMLDialogElement.cpp
@@ -6,8 +6,20 @@
#include "mozilla/dom/HTMLDialogElement.h"
#include "mozilla/dom/HTMLDialogElementBinding.h"
+#include "mozilla/dom/HTMLUnknownElement.h"
+#include "mozilla/Preferences.h"
-NS_IMPL_NS_NEW_HTML_ELEMENT(Dialog)
+// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Dialog) with pref check
+nsGenericHTMLElement*
+NS_NewHTMLDialogElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
+ mozilla::dom::FromParser aFromParser)
+{
+ if (!mozilla::dom::HTMLDialogElement::IsDialogEnabled()) {
+ return new mozilla::dom::HTMLUnknownElement(aNodeInfo);
+ }
+
+ return new mozilla::dom::HTMLDialogElement(aNodeInfo);
+}
namespace mozilla {
namespace dom {
@@ -18,6 +30,21 @@ HTMLDialogElement::~HTMLDialogElement()
NS_IMPL_ELEMENT_CLONE(HTMLDialogElement)
+bool
+HTMLDialogElement::IsDialogEnabled()
+{
+ static bool isDialogEnabled = false;
+ static bool added = false;
+
+ if (!added) {
+ Preferences::AddBoolVarCache(&isDialogEnabled,
+ "dom.dialog_element.enabled");
+ added = true;
+ }
+
+ return isDialogEnabled;
+}
+
void
HTMLDialogElement::Close(const mozilla::dom::Optional<nsAString>& aReturnValue)
{
diff --git a/dom/html/HTMLDialogElement.h b/dom/html/HTMLDialogElement.h
index 2222cd2f7..efa319f3c 100644
--- a/dom/html/HTMLDialogElement.h
+++ b/dom/html/HTMLDialogElement.h
@@ -26,6 +26,8 @@ public:
virtual nsresult Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
+ static bool IsDialogEnabled();
+
bool Open() const { return GetBoolAttr(nsGkAtoms::open); }
void SetOpen(bool aOpen, ErrorResult& aError)
{
diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html
index 9208997be..eb09f5962 100644
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -443,7 +443,7 @@ var interfaceNamesInGlobalScope =
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLDetailsElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
- "HTMLDialogElement",
+ {name: "HTMLDialogElement", disabled: true},
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLDirectoryElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
diff --git a/dom/webidl/HTMLDialogElement.webidl b/dom/webidl/HTMLDialogElement.webidl
index f4aa8484a..b6cdbacf6 100644
--- a/dom/webidl/HTMLDialogElement.webidl
+++ b/dom/webidl/HTMLDialogElement.webidl
@@ -11,6 +11,7 @@
* and create derivative works of this document.
*/
+[Pref="dom.dialog_element.enabled"]
interface HTMLDialogElement : HTMLElement {
[SetterThrows] attribute boolean open;
attribute DOMString returnValue;
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
index 5f66438f1..ec93dd9a2 100644
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -5360,6 +5360,9 @@ pref("narrate.filter-voices", true);
pref("dom.audiochannel.mutedByDefault", false);
+// HTML <dialog> element
+pref("dom.dialog_element.enabled", false);
+
// Enable <details> and <summary> tags.
pref("dom.details_element.enabled", true);
diff --git a/testing/web-platform/meta/html/dom/interfaces.html.ini b/testing/web-platform/meta/html/dom/interfaces.html.ini
index efe92b7f8..16a03337e 100644
--- a/testing/web-platform/meta/html/dom/interfaces.html.ini
+++ b/testing/web-platform/meta/html/dom/interfaces.html.ini
@@ -1,6 +1,6 @@
[interfaces.html]
type: testharness
- prefs: [dom.forms.inputmode:true, dom.details_element.enabled:true]
+ prefs: [dom.forms.inputmode:true, dom.details_element.enabled:true, dom.dialog_element.enabled:true]
[Document interface: attribute domain]
expected: FAIL
diff --git a/testing/web-platform/meta/html/dom/reflection-misc.html.ini b/testing/web-platform/meta/html/dom/reflection-misc.html.ini
index de0bd423b..b0909cc6d 100644
--- a/testing/web-platform/meta/html/dom/reflection-misc.html.ini
+++ b/testing/web-platform/meta/html/dom/reflection-misc.html.ini
@@ -1,6 +1,6 @@
[reflection-misc.html]
type: testharness
- prefs: [dom.details_element.enabled:true]
+ prefs: [dom.details_element.enabled: true, dom.dialog_element.enabled: true]
[html.tabIndex: setAttribute() to object "3" followed by getAttribute()]
expected: FAIL
diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-close.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-close.html.ini
new file mode 100644
index 000000000..2b6e03e32
--- /dev/null
+++ b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-close.html.ini
@@ -0,0 +1,3 @@
+[dialog-close.html]
+ type: testharness
+ prefs: [dom.dialog_element.enabled:true]
diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-open.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-open.html.ini
new file mode 100644
index 000000000..e265fbece
--- /dev/null
+++ b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-open.html.ini
@@ -0,0 +1,3 @@
+[dialog-open.html]
+ type: testharness
+ prefs: [dom.dialog_element.enabled:true]
diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html.ini
index c34a9a843..eb71b8d55 100644
--- a/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html.ini
+++ b/testing/web-platform/meta/html/semantics/interactive-elements/the-dialog-element/dialog-showModal.html.ini
@@ -1,5 +1,6 @@
[dialog-showModal.html]
type: testharness
+ prefs: [dom.dialog_element.enabled:true]
[dialog element: showModal()]
expected: FAIL
diff --git a/testing/web-platform/meta/html/semantics/interfaces.html.ini b/testing/web-platform/meta/html/semantics/interfaces.html.ini
index a1e94455e..23f55fbe4 100644
--- a/testing/web-platform/meta/html/semantics/interfaces.html.ini
+++ b/testing/web-platform/meta/html/semantics/interfaces.html.ini
@@ -1,6 +1,6 @@
[interfaces.html]
type: testharness
- prefs: [dom.details_element.enabled:true]
+ prefs: [dom.details_element.enabled: true, dom.dialog_element.enabled: true]
[Interfaces for image]
expected: FAIL