From 74680d59a1d63e1937172908831d8b13b2c141af Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sat, 23 Jan 2021 12:42:53 +0000 Subject: [PATCH 01/12] Issue #1319 - Resolve RELEASE_OR_BETA questions in all.js - Enabled SVG transform-box property. I've tested this extensively including the bug that prevented Mozilla from shipping until 55 which does not seem to apply to us (most likely a stylo issue). Should be good to go. - Moved the getRootNode pref to a better place (no change) - Enabled inputmode property for forms. This is n/a for physical keyboards but should improve the experience for soft keyboards that can pop up various forms of input (e.g. numeric) depending on the mode indicated. According to BZ this is feature complete at our level but was problematic for Android which we don't have support for anyway. - Restricted crashing on insecure input of text to debug only. - Enabled shutting down the async OSFile worker if not used for 30 seconds to be more conscientious about resource use. - Enabled blocking of autoplay of media in the background by default, since it is a saner default to have for the OOBE and is commonly a desired setting by users (see forum). - Disabled the storage manager API by default. This fine-grained control over stored website data is already handled by various extensions and we don't have the front-end support for it. Assuming this was necessary for Mozilla due to limited access of WebExtensions to this kind of data. --- modules/libpref/init/all.js | 38 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index f88b48f44c..59295462ca 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -2886,11 +2886,8 @@ pref("svg.marker-improvements.enabled", true); // See https://svgwg.org/svg2-draft/single-page.html#types-SVGBoundingBoxOptions pref("svg.new-getBBox.enabled", false); -#ifdef RELEASE_OR_BETA -pref("svg.transform-box.enabled", false); -#else +// Is support for the transform-box property of SVG enabled? pref("svg.transform-box.enabled", true); -#endif // RELEASE_OR_BETA // Default font types and sizes by locale pref("font.default.ar", "sans-serif"); @@ -4753,11 +4750,7 @@ pref("dom.abortController.enabled", true); // Push pref("dom.push.enabled", false); - pref("dom.push.loglevel", "error"); - -pref("dom.getRootNode.enabled", false); - pref("dom.push.serverURL", "wss://push.services.mozilla.com/"); pref("dom.push.userAgentID", ""); @@ -4794,6 +4787,9 @@ pref("dom.push.http2.reset_retry_count_after_ms", 60000); pref("dom.push.http2.maxRetries", 2); pref("dom.push.http2.retryInterval", 5000); +// Whether WC getRootNode is available +pref("dom.getRootNode.enabled", false); + // WebNetworkStats pref("dom.mozNetworkStats.enabled", false); @@ -4978,13 +4974,11 @@ pref("captivedetect.maxWaitingTime", 5000); pref("captivedetect.pollingTime", 3000); pref("captivedetect.maxRetryCount", 5); -#ifdef RELEASE_OR_BETA -pref("dom.forms.inputmode", false); -#else +// Enable support for specifying inputmode for soft keyboards pref("dom.forms.inputmode", true); -#endif // InputMethods for soft keyboards in B2G +// XXX: is this still used? pref("dom.mozInputMethod.enabled", false); // Enable mapped array buffer by default. @@ -5197,8 +5191,8 @@ pref("dom.presentation.discoverable.retry_ms", 5000); pref("dom.presentation.session_transport.data_channel.enable", false); #ifdef XP_MACOSX -#if !defined(RELEASE_OR_BETA) || defined(DEBUG) -// In non-release builds we crash by default on insecure text input (when a +#if defined(DEBUG) +// In debug builds we crash by default on insecure text input (when a // password editor has focus but secure event input isn't enabled). The // following pref, when turned on, disables this behavior. See bug 1188425. pref("intl.allow-insecure-text-input", false); @@ -5410,24 +5404,18 @@ pref("media.default_volume", "1.0"); pref("media.seekToNextFrame.enabled", true); -// return the maximum number of cores that navigator.hardwareCurrency returns +// return the maximum number of cores that navigator.hardwareConcurrency returns pref("dom.maxHardwareConcurrency", 16); -// Shutdown the osfile worker if its no longer needed. -#if !defined(RELEASE_OR_BETA) +// Shutdown the async osfile worker if it's no longer needed. pref("osfile.reset_worker_delay", 30000); -#endif #if !defined(MOZ_WIDGET_ANDROID) pref("dom.webkitBlink.dirPicker.enabled", true); pref("dom.webkitBlink.filesystem.enabled", true); #endif -#ifdef NIGHTLY_BUILD pref("media.block-autoplay-until-in-foreground", true); -#else -pref("media.block-autoplay-until-in-foreground", false); -#endif #ifdef MOZ_STYLO // Is the Servo-backed style system enabled? @@ -5443,12 +5431,8 @@ pref("security.data_uri.block_toplevel_data_uri_navigations", true); // If true, all FTP subresource loads will be blocked. pref("security.block_ftp_subresources", true); -// Disable Storage api in release builds. -#ifdef NIGHTLY_BUILD -pref("dom.storageManager.enabled", true); -#else +// Disable Storage api by default. This needs specific front-end parts to be usable. pref("dom.storageManager.enabled", false); -#endif // DoS protection for HTTP Auth prompt spawning. // -1 = completely disable HTTP Auth prompting. (careful!) From a828a5f3214c760805713b3d2cc1b777069c4028 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Mon, 25 Jan 2021 23:18:58 +0000 Subject: [PATCH 02/12] Issue #1719 - Make pref-controlled and disable by default. Resolves #1719 --- dom/html/HTMLMenuElement.cpp | 6 +++--- dom/html/HTMLMenuItemElement.cpp | 14 ++++++++++++-- .../test/browser_content_contextmenu_userinput.js | 3 +++ dom/html/test/mochitest.ini | 2 ++ dom/tests/mochitest/general/test_interfaces.html | 2 -- .../webcomponents/htmlconstructor_builtin_tests.js | 1 - dom/webidl/EventHandler.webidl | 1 + dom/webidl/HTMLElement.webidl | 4 +--- dom/webidl/HTMLMenuElement.webidl | 4 ++-- dom/webidl/HTMLMenuItemElement.webidl | 2 +- layout/style/res/html.css | 6 ++++-- modules/libpref/init/all.js | 3 +++ 12 files changed, 32 insertions(+), 16 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&& aNodeInfo, + mozilla::dom::FromParser aFromParser) { + RefPtr 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 @@ -496,8 +496,6 @@ var interfaceNamesInGlobalScope = "HTMLMediaElement", // 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! diff --git a/dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js b/dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js index dd65151482..50fc351631 100644 --- a/dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js +++ b/dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js @@ -72,7 +72,6 @@ ['mark', ''], ['marquee', 'Div'], ['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; diff --git a/layout/style/res/html.css b/layout/style/res/html.css index 4f43f3134f..8593abaab7 100644 --- a/layout/style/res/html.css +++ b/layout/style/res/html.css @@ -577,8 +577,10 @@ ul, menu, dir { padding-inline-start: 40px; } -menu[type="context"] { - display: none !important; +@supports -moz-bool-pref("dom.menuitem.enabled") { + menu[type="context"] { + display: none !important; + } } ol { diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 59295462ca..bc904c7a0a 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4984,6 +4984,9 @@ pref("dom.mozInputMethod.enabled", false); // Enable mapped array buffer by default. pref("dom.mapped_arraybuffer.enabled", true); +// Whether is a thing or not. +pref("dom.menuitem.enabled", false); + #ifdef MOZ_SAFE_BROWSING // The tables used for Safebrowsing phishing and malware checks. pref("urlclassifier.malwareTable", "goog-malware-shavar,goog-unwanted-shavar,test-malware-simple,test-unwanted-simple"); From d4324dc06455306ce101841af229a151f162c3e8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Mon, 25 Jan 2021 17:19:43 -0500 Subject: [PATCH 03/12] Issue #1390 - Clean up presentation api leftovers --- dom/base/nsContentUtils.cpp | 56 ------------------------------------- dom/base/nsContentUtils.h | 6 ---- dom/base/nsFrameLoader.cpp | 16 +---------- dom/base/nsGkAtomList.h | 1 - dom/ipc/PTabContext.ipdlh | 5 ---- dom/ipc/TabChild.cpp | 5 ---- dom/ipc/TabContext.cpp | 16 ++--------- dom/ipc/TabContext.h | 20 ++----------- modules/libpref/init/all.js | 15 ---------- 9 files changed, 6 insertions(+), 134 deletions(-) diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index a347525545..107daaede6 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -9341,62 +9341,6 @@ nsContentUtils::SetScrollbarsVisibility(nsIDocShell* aDocShell, bool aVisible) } } -/* static */ void -nsContentUtils::GetPresentationURL(nsIDocShell* aDocShell, nsAString& aPresentationUrl) -{ - MOZ_ASSERT(aDocShell); - - // Simulate receiver context for web platform test - if (Preferences::GetBool("dom.presentation.testing.simulate-receiver")) { - nsCOMPtr doc; - - nsCOMPtr docShellWin = - do_QueryInterface(aDocShell->GetScriptGlobalObject()); - if (docShellWin) { - doc = docShellWin->GetExtantDoc(); - } - - if (NS_WARN_IF(!doc)) { - return; - } - - nsCOMPtr uri = doc->GetDocumentURI(); - if (NS_WARN_IF(!uri)) { - return; - } - - nsAutoCString uriStr; - uri->GetSpec(uriStr); - aPresentationUrl = NS_ConvertUTF8toUTF16(uriStr); - return; - } - - if (XRE_IsContentProcess()) { - nsCOMPtr sameTypeRoot; - aDocShell->GetSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot)); - nsCOMPtr root; - aDocShell->GetRootTreeItem(getter_AddRefs(root)); - if (sameTypeRoot.get() == root.get()) { - // presentation URL is stored in TabChild for the top most - //