summaryrefslogtreecommitdiff
path: root/dom
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2021-01-25 23:18:58 +0000
committerMoonchild <moonchild@palemoon.org>2021-01-25 23:18:58 +0000
commit874330d4538bd4704730d57fa35fd678c7d6fbf2 (patch)
tree3b89c8f0a55a99a90aef812e73966a9e2ba6cbb9 /dom
parent1126548deecfd736755f1e1b7e7d551b42e73780 (diff)
downloaduxp-874330d4538bd4704730d57fa35fd678c7d6fbf2.tar.gz
Issue #1719 - Make <menuitem> pref-controlled and disable by default.
Resolves #1719
Diffstat (limited to 'dom')
-rw-r--r--dom/html/HTMLMenuElement.cpp6
-rw-r--r--dom/html/HTMLMenuItemElement.cpp14
-rw-r--r--dom/html/test/browser_content_contextmenu_userinput.js3
-rw-r--r--dom/html/test/mochitest.ini2
-rw-r--r--dom/tests/mochitest/general/test_interfaces.html2
-rw-r--r--dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js1
-rw-r--r--dom/webidl/EventHandler.webidl1
-rw-r--r--dom/webidl/HTMLElement.webidl4
-rw-r--r--dom/webidl/HTMLMenuElement.webidl4
-rw-r--r--dom/webidl/HTMLMenuItemElement.webidl2
10 files changed, 25 insertions, 14 deletions
diff --git a/dom/html/HTMLMenuElement.cpp b/dom/html/HTMLMenuElement.cpp
index 6c096084ac..a099a5289e 100644
--- a/dom/html/HTMLMenuElement.cpp
+++ b/dom/html/HTMLMenuElement.cpp
@@ -137,9 +137,9 @@ HTMLMenuElement::ParseAttribute(int32_t aNamespaceID,
const nsAString& aValue,
nsAttrValue& aResult)
{
- if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::type) {
- bool success = aResult.ParseEnumValue(aValue, kMenuTypeTable,
- false);
+ if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::type &&
+ Preferences::GetBool("dom.menuitem.enabled")) {
+ bool success = aResult.ParseEnumValue(aValue, kMenuTypeTable, false);
if (success) {
mType = aResult.GetEnumValue();
} else {
diff --git a/dom/html/HTMLMenuItemElement.cpp b/dom/html/HTMLMenuItemElement.cpp
index 5c5cf8d767..6cf4eb40c2 100644
--- a/dom/html/HTMLMenuItemElement.cpp
+++ b/dom/html/HTMLMenuItemElement.cpp
@@ -7,12 +7,22 @@
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.h"
+#include "mozilla/Preferences.h"
#include "mozilla/dom/HTMLMenuItemElementBinding.h"
+#include "mozilla/dom/HTMLUnknownElement.h"
#include "nsAttrValueInlines.h"
#include "nsContentUtils.h"
-
-NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(MenuItem)
+nsGenericHTMLElement*
+NS_NewHTMLMenuItemElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
+ mozilla::dom::FromParser aFromParser) {
+ RefPtr<mozilla::dom::NodeInfo> nodeInfo(aNodeInfo);
+ if (mozilla::Preferences::GetBool("dom.menuitem.enabled")) {
+ return new mozilla::dom::HTMLMenuItemElement(nodeInfo.forget(), aFromParser);
+ } else {
+ return new mozilla::dom::HTMLUnknownElement(nodeInfo.forget());
+ }
+}
namespace mozilla {
namespace dom {
diff --git a/dom/html/test/browser_content_contextmenu_userinput.js b/dom/html/test/browser_content_contextmenu_userinput.js
index 7d0387715b..845ba718e3 100644
--- a/dom/html/test/browser_content_contextmenu_userinput.js
+++ b/dom/html/test/browser_content_contextmenu_userinput.js
@@ -4,6 +4,9 @@ const kPage = "http://example.org/browser/" +
"dom/html/test/file_content_contextmenu.html";
add_task(function* () {
+ yield SpecialPowers.pushPrefEnv({
+ set: [["dom.menuitem.enabled", true]],
+ });
yield BrowserTestUtils.withNewTab({
gBrowser,
url: kPage
diff --git a/dom/html/test/mochitest.ini b/dom/html/test/mochitest.ini
index 5c9c66e614..dcbb73840a 100644
--- a/dom/html/test/mochitest.ini
+++ b/dom/html/test/mochitest.ini
@@ -1,4 +1,6 @@
[DEFAULT]
+prefs =
+ dom.menuitem.enabled=true # only for test_bug617528.html
support-files =
347174transform.xsl
347174transformable.xml
diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html
index eb09f5962a..5eb47d1018 100644
--- a/dom/tests/mochitest/general/test_interfaces.html
+++ b/dom/tests/mochitest/general/test_interfaces.html
@@ -497,8 +497,6 @@ var interfaceNamesInGlobalScope =
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLMenuElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
- "HTMLMenuItemElement",
-// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLMetaElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLMeterElement",
diff --git a/dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js b/dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js
index 0b04971e34..c3d9a241d0 100644
--- a/dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js
+++ b/dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js
@@ -71,7 +71,6 @@
['map', 'Map'],
['mark', ''],
['menu', 'Menu'],
- ['menuitem', 'MenuItem'],
['meta', 'Meta'],
['meter', 'Meter'],
['nav', ''],
diff --git a/dom/webidl/EventHandler.webidl b/dom/webidl/EventHandler.webidl
index 484a8e95cd..e7dc4931bd 100644
--- a/dom/webidl/EventHandler.webidl
+++ b/dom/webidl/EventHandler.webidl
@@ -82,6 +82,7 @@ interface GlobalEventHandlers {
attribute EventHandler onseeked;
attribute EventHandler onseeking;
attribute EventHandler onselect;
+ [Pref="dom.menuitem.enabled"]
attribute EventHandler onshow;
//(Not implemented)attribute EventHandler onsort;
attribute EventHandler onstalled;
diff --git a/dom/webidl/HTMLElement.webidl b/dom/webidl/HTMLElement.webidl
index 815f4a3bd0..cd1fd7d6aa 100644
--- a/dom/webidl/HTMLElement.webidl
+++ b/dom/webidl/HTMLElement.webidl
@@ -49,10 +49,8 @@ interface HTMLElement : Element {
attribute DOMString contentEditable;
[Pure]
readonly attribute boolean isContentEditable;
- [Pure]
+ [Pure, Pref="dom.menuitem.enabled"]
readonly attribute HTMLMenuElement? contextMenu;
- //[SetterThrows]
- // attribute HTMLMenuElement? contextMenu;
[CEReactions, SetterThrows, Pure]
attribute boolean spellcheck;
diff --git a/dom/webidl/HTMLMenuElement.webidl b/dom/webidl/HTMLMenuElement.webidl
index 1194226c5b..dc9a78ae8a 100644
--- a/dom/webidl/HTMLMenuElement.webidl
+++ b/dom/webidl/HTMLMenuElement.webidl
@@ -17,9 +17,9 @@ interface MenuBuilder;
// http://www.whatwg.org/specs/web-apps/current-work/#the-menu-element
[HTMLConstructor]
interface HTMLMenuElement : HTMLElement {
- [CEReactions, SetterThrows]
+ [CEReactions, SetterThrows, Pref="dom.menuitem.enabled"]
attribute DOMString type;
- [CEReactions, SetterThrows]
+ [CEReactions, SetterThrows, Pref="dom.menuitem.enabled"]
attribute DOMString label;
};
diff --git a/dom/webidl/HTMLMenuItemElement.webidl b/dom/webidl/HTMLMenuItemElement.webidl
index f091045017..6005bd7d2f 100644
--- a/dom/webidl/HTMLMenuItemElement.webidl
+++ b/dom/webidl/HTMLMenuItemElement.webidl
@@ -12,7 +12,7 @@
*/
// http://www.whatwg.org/specs/web-apps/current-work/#the-menuitem-element
-[HTMLConstructor]
+[HTMLConstructor, Pref="dom.menuitem.enabled"]
interface HTMLMenuItemElement : HTMLElement {
[CEReactions, SetterThrows]
attribute DOMString type;