Commit 5a089f37 authored by Kagami Sascha Rosylight's avatar Kagami Sascha Rosylight
Browse files

Bug 1680596 - Part 1: Hide <menuitem> behind a flag r=smaug

parent ae5330c6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -107,6 +107,10 @@ add_task(async function test_xul_text_link_label() {
add_task(async function test_setup_html() {
  let url = example_base + "subtst_contextmenu.html";

  await SpecialPowers.pushPrefEnv({
    set: [["dom.menuitem.enabled", true]],
  });

  await BrowserTestUtils.openNewForegroundTab(gBrowser, url);

  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function() {
+4 −0
Original line number Diff line number Diff line
@@ -5,6 +5,10 @@ const gBaseURL =
  "https://example.com/browser/browser/base/content/test/contextMenu/";

add_task(async function() {
  await SpecialPowers.pushPrefEnv({
    set: [["dom.menuitem.enabled", true]],
  });

  let tab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    gBaseURL + "subtst_contextmenu.html"
+4 −2
Original line number Diff line number Diff line
@@ -86,7 +86,8 @@ nsresult HTMLMenuElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
                                       const nsAttrValue* aOldValue,
                                       nsIPrincipal* aSubjectPrincipal,
                                       bool aNotify) {
  if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::type) {
  if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::type &&
      StaticPrefs::dom_menuitem_enabled()) {
    if (aValue) {
      mType = aValue->GetEnumValue();
    } else {
@@ -102,7 +103,8 @@ bool HTMLMenuElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
                                     const nsAString& aValue,
                                     nsIPrincipal* aMaybeScriptedPrincipal,
                                     nsAttrValue& aResult) {
  if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::type) {
  if (aNamespaceID == kNameSpaceID_None && aAttribute == nsGkAtoms::type &&
      StaticPrefs::dom_menuitem_enabled()) {
    return aResult.ParseEnumValue(aValue, kMenuTypeTable, false,
                                  kMenuDefaultType);
  }
+13 −1
Original line number Diff line number Diff line
@@ -9,10 +9,22 @@
#include "mozilla/BasicEvents.h"
#include "mozilla/EventDispatcher.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);
  auto* nim = nodeInfo->NodeInfoManager();
  MOZ_ASSERT(nim);
  if (mozilla::StaticPrefs::dom_menuitem_enabled()) {
    return new (nim)
        mozilla::dom::HTMLMenuItemElement(nodeInfo.forget(), aFromParser);
  }
  return new (nim) mozilla::dom::HTMLUnknownElement(nodeInfo.forget());
}

namespace mozilla::dom {

+3 −0
Original line number Diff line number Diff line
@@ -4,6 +4,9 @@ const kPage =
  "http://example.org/browser/" + "dom/html/test/file_content_contextmenu.html";

add_task(async function() {
  await SpecialPowers.pushPrefEnv({
    set: [["dom.menuitem.enabled", true]],
  });
  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
Loading