summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2020-01-07 09:10:56 -0500
committerGaming4JC <g4jc@hyperbola.info>2020-01-07 18:33:23 -0500
commitfaba3194ec7c9526bd912e7eef50cfb1fe656fd9 (patch)
tree9d0f870d382acab08d48996d2e47d0c0db0fff21 /dom
parent9c3ba221663d405e27572ef89f362816687d6fe4 (diff)
downloaduxp-faba3194ec7c9526bd912e7eef50cfb1fe656fd9.tar.gz
Bug 1322938 - Put <dialog> element behind preference.
Tag mcp-graveyard/UXP#1343
Diffstat (limited to 'dom')
-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
4 files changed, 32 insertions, 2 deletions
diff --git a/dom/html/HTMLDialogElement.cpp b/dom/html/HTMLDialogElement.cpp
index 1f65b602f2..48666628e5 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 2222cd2f7c..efa319f3ca 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 9208997be2..eb09f5962a 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 f4aa8484ab..b6cdbacf68 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;