From 3612f45a90779a8d79936149d2598a7ab4973372 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 9 Jul 2021 21:18:36 +0000 Subject: [PATCH 01/18] [network] Stop treating http and https as different for encoding schemes. There is no reason to treat available encoding schemes for these protocols differently. --- modules/libpref/init/all.js | 2 - netwerk/protocol/http/HttpBaseChannel.cpp | 11 ++--- netwerk/protocol/http/nsHttpHandler.cpp | 51 +++++------------------ netwerk/protocol/http/nsHttpHandler.h | 9 ++-- 4 files changed, 18 insertions(+), 55 deletions(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 8baae8ed2a..d2e34fb4ff 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1463,9 +1463,7 @@ pref("network.http.redirection-limit", 20); // Enable http compression: comment this out in case of problems with 1.1 // NOTE: support for "compress" has been disabled per bug 196406. // NOTE: separate values with comma+space (", "): see bug 576033 -// NOTE: there is currently no reason except evangelism for https to not use brotli for http pref("network.http.accept-encoding", "gzip, deflate, br"); -pref("network.http.accept-encoding.secure", "gzip, deflate, br"); pref("network.http.pipelining" , true); pref("network.http.pipelining.ssl" , false); // disable pipelining over SSL diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index f7040a4b4c..877915acb5 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -171,10 +171,7 @@ HttpBaseChannel::Init(nsIURI *aURI, int32_t port = -1; bool isHTTPS = false; - nsresult rv = mURI->SchemeIs("https", &isHTTPS); - if (NS_FAILED(rv)) return rv; - - rv = mURI->GetAsciiHost(host); + nsresult rv = mURI->GetAsciiHost(host); if (NS_FAILED(rv)) return rv; // Reject the URL if it doesn't specify a host @@ -201,7 +198,7 @@ HttpBaseChannel::Init(nsIURI *aURI, rv = mRequestHead.SetHeader(nsHttp::Host, hostLine); if (NS_FAILED(rv)) return rv; - rv = gHttpHandler->AddStandardRequestHeaders(&mRequestHead, isHTTPS, aContentPolicyType); + rv = gHttpHandler->AddStandardRequestHeaders(&mRequestHead, aContentPolicyType); if (NS_FAILED(rv)) return rv; nsAutoCString type; @@ -975,9 +972,7 @@ HttpBaseChannel::DoApplyContentConversions(nsIStreamListener* aNextListener, break; } - bool isHTTPS = false; - mURI->SchemeIs("https", &isHTTPS); - if (gHttpHandler->IsAcceptableEncoding(val, isHTTPS)) { + if (gHttpHandler->IsAcceptableEncoding(val)) { nsCOMPtr serv; rv = gHttpHandler->GetStreamConverterService(getter_AddRefs(serv)); diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 30f5703a52..b103ac66ad 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -446,7 +446,6 @@ nsHttpHandler::InitConnectionMgr() nsresult nsHttpHandler::AddStandardRequestHeaders(nsHttpRequestHead *request, - bool isSecure, nsContentPolicyType aContentPolicyType) { nsresult rv; @@ -493,15 +492,9 @@ nsHttpHandler::AddStandardRequestHeaders(nsHttpRequestHead *request, } // Add the "Accept-Encoding" header - if (isSecure) { - rv = request->SetHeader(nsHttp::Accept_Encoding, mHttpsAcceptEncodings, - false, - nsHttpHeaderArray::eVarietyRequestDefault); - } else { - rv = request->SetHeader(nsHttp::Accept_Encoding, mHttpAcceptEncodings, - false, - nsHttpHeaderArray::eVarietyRequestDefault); - } + rv = request->SetHeader(nsHttp::Accept_Encoding, mAcceptEncodings, + false, + nsHttpHeaderArray::eVarietyRequestDefault); if (NS_FAILED(rv)) return rv; // add the "Send Hint" header @@ -535,19 +528,15 @@ nsHttpHandler::AddConnectionHeader(nsHttpRequestHead *request, } bool -nsHttpHandler::IsAcceptableEncoding(const char *enc, bool isSecure) +nsHttpHandler::IsAcceptableEncoding(const char *enc) { if (!enc) return false; // we used to accept x-foo anytime foo was acceptable, but that's just // continuing bad behavior.. so limit it to known x-* patterns - bool rv; - if (isSecure) { - rv = nsHttp::FindToken(mHttpsAcceptEncodings.get(), enc, HTTP_LWS ",") != nullptr; - } else { - rv = nsHttp::FindToken(mHttpAcceptEncodings.get(), enc, HTTP_LWS ",") != nullptr; - } + bool rv = nsHttp::FindToken(mAcceptEncodings.get(), enc, HTTP_LWS ",") != nullptr; + // gzip and deflate are inherently acceptable in modern HTTP - always // process them if a stream converter can also be found. if (!rv && @@ -555,8 +544,8 @@ nsHttpHandler::IsAcceptableEncoding(const char *enc, bool isSecure) !PL_strcasecmp(enc, "x-gzip") || !PL_strcasecmp(enc, "x-deflate"))) { rv = true; } - LOG(("nsHttpHandler::IsAceptableEncoding %s https=%d %d\n", - enc, isSecure, rv)); + LOG(("nsHttpHandler::IsAceptableEncoding %s %d\n", + enc, rv)); return rv; } @@ -1275,16 +1264,7 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) rv = prefs->GetCharPref(HTTP_PREF("accept-encoding"), getter_Copies(acceptEncodings)); if (NS_SUCCEEDED(rv)) { - SetAcceptEncodings(acceptEncodings, false); - } - } - - if (PREF_CHANGED(HTTP_PREF("accept-encoding.secure"))) { - nsXPIDLCString acceptEncodings; - rv = prefs->GetCharPref(HTTP_PREF("accept-encoding.secure"), - getter_Copies(acceptEncodings)); - if (NS_SUCCEEDED(rv)) { - SetAcceptEncodings(acceptEncodings, true); + SetAcceptEncodings(acceptEncodings); } } @@ -1910,18 +1890,9 @@ nsHttpHandler::SetAccept(const char *aAccept, AcceptType aType) } nsresult -nsHttpHandler::SetAcceptEncodings(const char *aAcceptEncodings, bool isSecure) +nsHttpHandler::SetAcceptEncodings(const char *aAcceptEncodings) { - if (isSecure) { - mHttpsAcceptEncodings = aAcceptEncodings; - } else { - // use legacy list if a secure override is not specified - mHttpAcceptEncodings = aAcceptEncodings; - if (mHttpsAcceptEncodings.IsEmpty()) { - mHttpsAcceptEncodings = aAcceptEncodings; - } - } - + mAcceptEncodings = aAcceptEncodings; return NS_OK; } diff --git a/netwerk/protocol/http/nsHttpHandler.h b/netwerk/protocol/http/nsHttpHandler.h index 4f632e0784..c3f6290095 100644 --- a/netwerk/protocol/http/nsHttpHandler.h +++ b/netwerk/protocol/http/nsHttpHandler.h @@ -79,10 +79,10 @@ public: nsHttpHandler(); nsresult Init(); - nsresult AddStandardRequestHeaders(nsHttpRequestHead *, bool isSecure, nsContentPolicyType aContentPolicyType); + nsresult AddStandardRequestHeaders(nsHttpRequestHead *, nsContentPolicyType aContentPolicyType); nsresult AddConnectionHeader(nsHttpRequestHead *, uint32_t capabilities); - bool IsAcceptableEncoding(const char *encoding, bool isSecure); + bool IsAcceptableEncoding(const char *encoding); const nsAFlatCString &UserAgent(); @@ -398,7 +398,7 @@ private: nsresult SetAccept(const char *, AcceptType aType); nsresult SetAcceptLanguages(); - nsresult SetAcceptEncodings(const char *, bool mIsSecure); + nsresult SetAcceptEncodings(const char *); nsresult InitConnectionMgr(); @@ -476,8 +476,7 @@ private: nsCString mAcceptStyle; nsCString mAcceptDefault; nsCString mAcceptLanguages; - nsCString mHttpAcceptEncodings; - nsCString mHttpsAcceptEncodings; + nsCString mAcceptEncodings; nsXPIDLCString mDefaultSocketType; From 22651c52beff373c42e8d4059436f37eff54cd13 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Mon, 12 Jul 2021 02:50:57 +0000 Subject: [PATCH 02/18] Issue #1757 - Follow-up: Remove some stray WPT leftovers. These were re-introduced when reverting the
element pref changes. --- .../interactive-elements/the-details-element/details.html.ini | 3 --- .../the-details-element/toggleEvent.html.ini | 3 --- 2 files changed, 6 deletions(-) delete mode 100644 testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/details.html.ini delete mode 100644 testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/toggleEvent.html.ini diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/details.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/details.html.ini deleted file mode 100644 index 6ffca742cc..0000000000 --- a/testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/details.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[details.html] - type: testharness - prefs: [dom.details_element.enabled:true] diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/toggleEvent.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/toggleEvent.html.ini deleted file mode 100644 index 335ffd5b3a..0000000000 --- a/testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/toggleEvent.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[toggleEvent.html] - type: testharness - prefs: [dom.details_element.enabled:true] From d751dbe1a43fb004d45ab7b5a1d407ce795e0835 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Mon, 12 Jul 2021 02:54:51 +0000 Subject: [PATCH 03/18] Issue #1792 - Part 1: Remove superfluous check for abstract ancestors. This removes some restrictions on whether an interface that implements QueryInterface can have a non-abstract ancestor. This restriction was put in place back when we automatically added QueryInterface to all rootmost non-abstract interfaces (~Pale Moon 24). At the time, we needed to make sure it did NOT end up on EventTarget, because back then WebIDL quickstubs would replace the QI implementation on non-WebIDL EventTargets with the WebIDL one, which would not work for them. Since then, we have removed WebIDL quickstubs and we now explicitly list which interfaces get QueryInterface, so this check is no longer needed. --- dom/bindings/Codegen.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index c9a5e9f419..42ce94fcb4 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -2321,22 +2321,11 @@ class MethodDefiner(PropertyDefiner): if len(signatures) > 1 or len(signatures[0][1]) > 1 or not argTypeIsIID(signatures[0][1][0]): raise TypeError("There should be only one queryInterface method with 1 argument of type IID") - # Make sure to not stick QueryInterface on abstract interfaces that - # have hasXPConnectImpls (like EventTarget). So only put it on - # interfaces that are concrete and all of whose ancestors are abstract. - def allAncestorsAbstract(iface): - if not iface.parent: - return True - desc = self.descriptor.getDescriptor(iface.parent.identifier.name) - if desc.concrete: - return False - return allAncestorsAbstract(iface.parent) + # Make sure to not stick QueryInterface on abstract interfaces. if (not self.descriptor.interface.hasInterfacePrototypeObject() or - not self.descriptor.concrete or - not allAncestorsAbstract(self.descriptor.interface)): + not self.descriptor.concrete): raise TypeError("QueryInterface is only supported on " - "interfaces that are concrete and all " - "of whose ancestors are abstract: " + + "interfaces that are concrete: " + self.descriptor.name) condition = "WantsQueryInterface<%s>::Enabled" % descriptor.nativeType self.regular.append({ From dd06472de7bc49c2b48f7438b1eb21a64f891486 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Mon, 12 Jul 2021 02:56:48 +0000 Subject: [PATCH 04/18] Issue #1792 - Part 2: Move GetParentObject() to EventTarget.h for re-use. --- dom/events/DOMEventTargetHelper.h | 5 +---- dom/events/EventTarget.h | 6 ++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dom/events/DOMEventTargetHelper.h b/dom/events/DOMEventTargetHelper.h index 63f3598048..9a1938078d 100644 --- a/dom/events/DOMEventTargetHelper.h +++ b/dom/events/DOMEventTargetHelper.h @@ -146,10 +146,7 @@ public: void BindToOwner(nsPIDOMWindowInner* aOwner); void BindToOwner(DOMEventTargetHelper* aOther); virtual void DisconnectFromOwner(); - nsIGlobalObject* GetParentObject() const - { - return GetOwnerGlobal(); - } + using EventTarget::GetParentObject; virtual nsIGlobalObject* GetOwnerGlobal() const override { nsCOMPtr parentObject = do_QueryReferent(mParentObject); diff --git a/dom/events/EventTarget.h b/dom/events/EventTarget.h index c64296993b..9e5d1e7653 100644 --- a/dom/events/EventTarget.h +++ b/dom/events/EventTarget.h @@ -26,6 +26,7 @@ class Event; class EventListener; class EventListenerOptionsOrBoolean; class EventHandlerNonNull; +class GlobalObject; template struct Nullable; @@ -55,6 +56,11 @@ public: ErrorResult& aRv); bool DispatchEvent(JSContext* aCx, Event& aEvent, ErrorResult& aRv); + nsIGlobalObject* GetParentObject() const + { + return GetOwnerGlobal(); + } + // Note, this takes the type in onfoo form! EventHandlerNonNull* GetEventHandler(const nsAString& aType) { From 6e0c05056ba247b1d4d2d25078952882243aeb56 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Mon, 12 Jul 2021 03:04:29 +0000 Subject: [PATCH 05/18] Issue #1792 - Part 3: Add ConstructibleEventTarget helper class. Of course it couldn't be trivial :P wrapObject is a pure virtual function which prevents an abstract constructor from being used. So, we need to extend DOMEventTargetHelper (applicable acronym: DETH :D) with a wrapObject implementation - in a derivative class is the clearest way to do this, as opposed to making DETH more complex. --- dom/events/ConstructibleEventTarget.cpp | 20 +++++++++++++++ dom/events/ConstructibleEventTarget.h | 34 +++++++++++++++++++++++++ dom/events/moz.build | 2 ++ 3 files changed, 56 insertions(+) create mode 100644 dom/events/ConstructibleEventTarget.cpp create mode 100644 dom/events/ConstructibleEventTarget.h diff --git a/dom/events/ConstructibleEventTarget.cpp b/dom/events/ConstructibleEventTarget.cpp new file mode 100644 index 0000000000..8e768f7a61 --- /dev/null +++ b/dom/events/ConstructibleEventTarget.cpp @@ -0,0 +1,20 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/ConstructibleEventTarget.h" +#include "mozilla/dom/EventTargetBinding.h" + +namespace mozilla { +namespace dom { + +JSObject* +ConstructibleEventTarget::WrapObject(JSContext* cx, JS::Handle aGivenProto) +{ + return EventTargetBinding::Wrap(cx, this, aGivenProto); +} + +} // namespace dom +} // namespace mozilla + diff --git a/dom/events/ConstructibleEventTarget.h b/dom/events/ConstructibleEventTarget.h new file mode 100644 index 0000000000..18f60d556c --- /dev/null +++ b/dom/events/ConstructibleEventTarget.h @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_ConstructibleEventTarget_h_ +#define mozilla_dom_ConstructibleEventTarget_h_ + +#include "mozilla/DOMEventTargetHelper.h" +#include "js/RootingAPI.h" + +namespace mozilla { +namespace dom { + +class ConstructibleEventTarget : public DOMEventTargetHelper +{ +public: + // We're not worrying about ISupports and Cycle Collection here just for a wrapper function. + // This does mean that ConstructibleEventTarget will show up in CC and refcount logs as a + // DOMEventTargetHelper, but that's OK. + + explicit ConstructibleEventTarget(nsIGlobalObject* aGlobalObject) + : DOMEventTargetHelper(aGlobalObject) + { + } + + virtual JSObject* WrapObject(JSContext* cx, + JS::Handle aGivenProto) override; +}; + +} // namespace dom +} // namespace mozilla + +#endif // mozilla_dom_ConstructibleEventTarget_h_ diff --git a/dom/events/moz.build b/dom/events/moz.build index c5fd750146..d651167bd9 100644 --- a/dom/events/moz.build +++ b/dom/events/moz.build @@ -40,6 +40,7 @@ EXPORTS.mozilla.dom += [ 'ClipboardEvent.h', 'CommandEvent.h', 'CompositionEvent.h', + 'ConstructibleEventTarget.h', 'CustomEvent.h', 'DataContainerEvent.h', 'DataTransfer.h', @@ -80,6 +81,7 @@ SOURCES += [ 'ClipboardEvent.cpp', 'CommandEvent.cpp', 'CompositionEvent.cpp', + 'ConstructibleEventTarget.cpp', 'ContentEventHandler.cpp', 'CustomEvent.cpp', 'DataContainerEvent.cpp', From 467e117fd9a84eed06096063ba3df7db48a29651 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Mon, 12 Jul 2021 03:06:58 +0000 Subject: [PATCH 06/18] Issue #1792 - Part 4: Implement constructors for the EventTarget interface. --- dom/bindings/Bindings.conf | 1 - dom/events/EventTarget.cpp | 15 +++++++++++++++ dom/events/EventTarget.h | 2 ++ dom/webidl/EventTarget.webidl | 3 ++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index ddd32a4940..3ba753affd 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -298,7 +298,6 @@ DOMInterfaces = { # We can also get rid of the UnwrapArg bits in # the dom QueryInterface (in BindingUtils.cpp) at that point. 'hasXPConnectImpls': True, - 'concrete': False, 'jsImplParent': 'mozilla::DOMEventTargetHelper', 'implicitJSContext': [ 'dispatchEvent' ] }, diff --git a/dom/events/EventTarget.cpp b/dom/events/EventTarget.cpp index cf69dcb859..5f9228c21c 100644 --- a/dom/events/EventTarget.cpp +++ b/dom/events/EventTarget.cpp @@ -7,11 +7,26 @@ #include "mozilla/dom/Event.h" #include "mozilla/dom/EventTarget.h" #include "mozilla/dom/EventTargetBinding.h" +#include "mozilla/dom/ConstructibleEventTarget.h" +#include "nsIGlobalObject.h" #include "nsThreadUtils.h" namespace mozilla { namespace dom { +/* static */ +already_AddRefed +EventTarget::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) +{ + nsCOMPtr global = do_QueryInterface(aGlobal.GetAsSupports()); + if (!global) { + aRv.Throw(NS_ERROR_UNEXPECTED); + return nullptr; + } + RefPtr target = new ConstructibleEventTarget(global); + return target.forget(); +} + void EventTarget::RemoveEventListener(const nsAString& aType, EventListener* aListener, diff --git a/dom/events/EventTarget.h b/dom/events/EventTarget.h index 9e5d1e7653..251600dfb9 100644 --- a/dom/events/EventTarget.h +++ b/dom/events/EventTarget.h @@ -42,6 +42,8 @@ public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_EVENTTARGET_IID) // WebIDL API + static already_AddRefed Constructor(const GlobalObject& aGlobal, + ErrorResult& aRv); using nsIDOMEventTarget::AddEventListener; using nsIDOMEventTarget::RemoveEventListener; using nsIDOMEventTarget::DispatchEvent; diff --git a/dom/webidl/EventTarget.webidl b/dom/webidl/EventTarget.webidl index 9e8a267ff4..123fac4785 100644 --- a/dom/webidl/EventTarget.webidl +++ b/dom/webidl/EventTarget.webidl @@ -23,7 +23,8 @@ dictionary AddEventListenerOptions : EventListenerOptions { boolean once = false; }; -[Exposed=(Window,Worker,WorkerDebugger,System)] +[Constructor, + Exposed=(Window,Worker,WorkerDebugger,System)] interface EventTarget { /* Passing null for wantsUntrusted means "default behavior", which differs in content and chrome. In content that default boolean From 86aec314751f8251f76cb3b75f8b81eef5c065b7 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Mon, 12 Jul 2021 12:57:39 -0400 Subject: [PATCH 07/18] Issue #1793 - Add a border-bottom to toolbox Follow-up to e8be661944c730cb3b702cd7f7d97e0860eb9132 --- toolkit/themes/windows/global/toolbar.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/toolkit/themes/windows/global/toolbar.css b/toolkit/themes/windows/global/toolbar.css index 97310e1aeb..0a6eb943a0 100644 --- a/toolkit/themes/windows/global/toolbar.css +++ b/toolkit/themes/windows/global/toolbar.css @@ -23,6 +23,12 @@ toolbox { so don't use the widget toolbox styling and fallback to -moz-Dialog's color which by default should be a non-blinding rgb(240, 240, 240) */ -moz-appearance: none; + + /* Since we are overriding the style we want to provide the bottom border + that is normally drawn by look&feel. + However, local application styling may also provide it on adjacent + widgets as a border-top. Those will need to omit it on Windows 10. */ + border-bottom: 1px solid ThreeDShadow; } } From 895afe00e1e8b8a39599c308115ce7d1644ad94b Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Mon, 12 Jul 2021 12:58:30 -0400 Subject: [PATCH 08/18] Issue #1793 - Add a border-bottom to treecols header --- toolkit/themes/windows/global/tree.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/toolkit/themes/windows/global/tree.css b/toolkit/themes/windows/global/tree.css index 1300968248..ee176296b2 100644 --- a/toolkit/themes/windows/global/tree.css +++ b/toolkit/themes/windows/global/tree.css @@ -198,6 +198,14 @@ treechildren::-moz-tree-cell-text(progressmeter) { /* ::::: tree columns ::::: */ +@media (-moz-os-version: windows-win10) and (-moz-windows-theme: aero) { + treecols { + /* Windows 10's "aero" msstyle does not provide a complete style for + the treecols header so we need to provide a bottom border */ + border-bottom: 1px solid ThreeDLightShadow; + } +} + treecol, treecolpicker { -moz-appearance: treeheadercell; From b4e51a85402431cb176c9b1600a1386c25ab0a1d Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Mon, 12 Jul 2021 13:00:51 -0400 Subject: [PATCH 09/18] Issue #1793 - Only use proper Aero Styling in the Toolkit Error Console on Windows 7 --- toolkit/themes/windows/global/console/console.css | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/toolkit/themes/windows/global/console/console.css b/toolkit/themes/windows/global/console/console.css index d918fb73c8..4fb3fab706 100644 --- a/toolkit/themes/windows/global/console/console.css +++ b/toolkit/themes/windows/global/console/console.css @@ -208,11 +208,13 @@ toolbar#ToolbarMode .toolbarbutton-text { } %ifdef XP_WIN -#ToolbarMode { - -moz-appearance: -moz-win-browsertabbar-toolbox; -} +@media not (-moz-os-version: windows-win10) { + #ToolbarMode { + -moz-appearance: -moz-win-browsertabbar-toolbox; + } -#ToolbarEval { - -moz-appearance: toolbox; + #ToolbarEval { + -moz-appearance: toolbox; + } } %endif From ccb3ecdc95b25c7afbc221ab77655d46d1afc2f5 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Mon, 12 Jul 2021 13:01:17 -0400 Subject: [PATCH 10/18] Issue #1793 - Only use Glass on the Toolkit Download Manager on Windows 7 --- toolkit/themes/windows/mozapps/downloads/downloads.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/themes/windows/mozapps/downloads/downloads.css b/toolkit/themes/windows/mozapps/downloads/downloads.css index 202ec016fe..3f1bcbec31 100644 --- a/toolkit/themes/windows/mozapps/downloads/downloads.css +++ b/toolkit/themes/windows/mozapps/downloads/downloads.css @@ -111,7 +111,7 @@ richlistitem[type="download"] .dateTime { margin-top: 3px; } -@media (-moz-windows-compositor) { +@media (-moz-windows-compositor) and (-moz-os-version: windows-win7) { #downloadManager { -moz-appearance: -moz-win-glass; background: transparent; From 0a4289707062fe5736c9d8127f15c1b0930b08cc Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 14 Jul 2021 01:51:13 +0000 Subject: [PATCH 11/18] [network] Stop blocking 10080 Port 10080 is shared by too many devices and services that do need http(s) access, so this port should not be blacklisted by default. --- netwerk/base/nsIOService.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index d04b3cef12..ffe3ab2ace 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -165,7 +165,7 @@ int16_t gBadPortList[] = { 6667, // Standard IRC [Apple addition] 6668, // Alternate IRC [Apple addition] 6669, // Alternate IRC [Apple addition] - 10080,// Amanda + // 10080,// (Amanda) too many collisions with other services, disabled for now. 0, // Sentinel value: This MUST be zero }; From 43f7d3e27ae28d52a8ace80c0c3ccb8ddd1c694c Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 14 Jul 2021 13:20:09 +0000 Subject: [PATCH 12/18] [network] Add some sanity checks to deserialized nsStandardURLs Note: C++ lambda expressions are actually useful for once. --- netwerk/base/nsStandardURL.cpp | 57 ++++++++++++++++++++++++-- netwerk/base/nsStandardURL.h | 3 ++ netwerk/test/gtest/TestStandardURL.cpp | 51 +++++++++++++++++++++++ 3 files changed, 108 insertions(+), 3 deletions(-) diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp index 1866c10379..3d77093004 100644 --- a/netwerk/base/nsStandardURL.cpp +++ b/netwerk/base/nsStandardURL.cpp @@ -315,6 +315,46 @@ DumpLeakedURLs::~DumpLeakedURLs() } #endif +bool nsStandardURL::IsValid() { + auto checkSegment = [&](const nsStandardURL::URLSegment& aSeg) { + // Bad value + if (NS_WARN_IF(aSeg.mLen < -1)) { + return false; + } + if (aSeg.mLen == -1) { + return true; + } + + // Position outside of string + if (NS_WARN_IF(aSeg.mPos + aSeg.mLen > mSpec.Length())) { + return false; + } + + // Overflow + if (NS_WARN_IF(aSeg.mPos + aSeg.mLen < aSeg.mPos)) { + return false; + } + + return true; + }; + + bool allSegmentsValid = checkSegment(mScheme) && checkSegment(mAuthority) && + checkSegment(mUsername) && checkSegment(mPassword) && + checkSegment(mHost) && checkSegment(mPath) && + checkSegment(mFilepath) && checkSegment(mDirectory) && + checkSegment(mBasename) && checkSegment(mExtension) && + checkSegment(mQuery) && checkSegment(mRef); + if (!allSegmentsValid) { + return false; + } + + if (mScheme.mPos != 0) { + return false; + } + + return true; +} + void nsStandardURL::InitGlobalObjects() { @@ -2752,8 +2792,8 @@ nsStandardURL::SetFilePath(const nsACString &input) mSpec.Cut(mPath.mPos + 1, mFilepath.mLen - 1); // left shift query, and ref ShiftFromQuery(1 - mFilepath.mLen); - // One character for '/', and if we have a query or ref we add their - // length and one extra for each '?' or '#' characters + // One character for '/', and if we have a query or ref we add their + // length and one extra for each '?' or '#' characters mPath.mLen = 1 + (mQuery.mLen >= 0 ? (mQuery.mLen + 1) : 0) + (mRef.mLen >= 0 ? (mRef.mLen + 1) : 0); // these contain only a '/' @@ -3518,6 +3558,10 @@ nsStandardURL::Deserialize(const URIParams& aParams) return false; } + // If we exit early, make sure to clear the URL so we don't fail the sanity + // check in the destructor + auto clearOnExit = MakeScopeExit([&] { Clear(); }); + const StandardURLParams& params = aParams.get_StandardURLParams(); mURLType = params.urlType(); @@ -3565,7 +3609,7 @@ nsStandardURL::Deserialize(const URIParams& aParams) mSupportsFileURL = params.supportsFileURL(); mHostEncoding = params.hostEncoding(); - // Some sanity checks + // Some segment sanity checks NS_ENSURE_TRUE(mScheme.mPos == 0, false); NS_ENSURE_TRUE(mScheme.mLen > 0, false); // Make sure scheme is followed by :// (3 characters) @@ -3577,6 +3621,13 @@ nsStandardURL::Deserialize(const URIParams& aParams) NS_ENSURE_TRUE(mQuery.mLen == -1 || mSpec.CharAt(mQuery.mPos - 1) == '?', false); NS_ENSURE_TRUE(mRef.mLen == -1 || mSpec.CharAt(mRef.mPos - 1) == '#', false); + // Sanity-check the result + if (!IsValid()) { + return false; + } + + clearOnExit.release(); + // mSpecEncoding and mHostA are just caches that can be recovered as needed. return true; } diff --git a/netwerk/base/nsStandardURL.h b/netwerk/base/nsStandardURL.h index eba85528c7..580e1ff262 100644 --- a/netwerk/base/nsStandardURL.h +++ b/netwerk/base/nsStandardURL.h @@ -253,6 +253,9 @@ private: void FindHostLimit(nsACString::const_iterator& aStart, nsACString::const_iterator& aEnd); + // Checks if the URL has a valid representation. + bool IsValid(); + // mSpec contains the normalized version of the URL spec (UTF-8 encoded). nsCString mSpec; int32_t mDefaultPort; diff --git a/netwerk/test/gtest/TestStandardURL.cpp b/netwerk/test/gtest/TestStandardURL.cpp index a013f351cf..44133efcbb 100644 --- a/netwerk/test/gtest/TestStandardURL.cpp +++ b/netwerk/test/gtest/TestStandardURL.cpp @@ -9,6 +9,10 @@ #include "nsComponentManagerUtils.h" #include "nsIIPCSerializableURI.h" #include "mozilla/ipc/URIUtils.h" +#include "mozilla/Unused.h" +#include "nsSerializationHelper.h" +#include "mozilla/Base64.h" +#include "nsEscape.h" TEST(TestStandardURL, Simple) { nsCOMPtr url( do_CreateInstance(NS_STANDARDURL_CONTRACTID) ); @@ -83,3 +87,50 @@ TEST(TestStandardURL, Deserialize_Bug1392739) nsCOMPtr url = do_CreateInstance(NS_STANDARDURL_CID); ASSERT_EQ(url->Deserialize(params), false); } + +TEST(TestStandardURL, CorruptSerialization) +{ + auto spec = "http://user:pass@example.com/path/to/file.ext?query#hash"_ns; + + nsCOMPtr uri; + nsresult rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID) + .SetSpec(spec) + .Finalize(uri); + ASSERT_EQ(rv, NS_OK); + + nsAutoCString serialization; + nsCOMPtr serializable = do_QueryInterface(uri); + ASSERT_TRUE(serializable); + + // Check that the URL is normally serializable. + ASSERT_EQ(NS_OK, NS_SerializeToString(serializable, serialization)); + nsCOMPtr deserializedObject; + ASSERT_EQ(NS_OK, NS_DeserializeObject(serialization, + getter_AddRefs(deserializedObject))); + + nsAutoCString canonicalBin; + Unused << Base64Decode(serialization, canonicalBin); + +// The spec serialization begins at byte 49 +// If the implementation of nsStandardURL::Write changes, this test will need +// to be adjusted. +#define SPEC_OFFSET 49 + + ASSERT_EQ(Substring(canonicalBin, SPEC_OFFSET, 7), "http://"_ns); + + nsAutoCString corruptedBin = canonicalBin; + // change mScheme.mPos + corruptedBin.BeginWriting()[SPEC_OFFSET + spec.Length()] = 1; + Unused << Base64Encode(corruptedBin, serialization); + ASSERT_EQ( + NS_ERROR_MALFORMED_URI, + NS_DeserializeObject(serialization, getter_AddRefs(deserializedObject))); + + corruptedBin = canonicalBin; + // change mScheme.mLen + corruptedBin.BeginWriting()[SPEC_OFFSET + spec.Length() + 4] = 127; + Unused << Base64Encode(corruptedBin, serialization); + ASSERT_EQ( + NS_ERROR_MALFORMED_URI, + NS_DeserializeObject(serialization, getter_AddRefs(deserializedObject))); +} \ No newline at end of file From 6b11c3f299da3cb5d450dcacfafd9db2a2e5793d Mon Sep 17 00:00:00 2001 From: Valentin Gosu Date: Wed, 14 Jul 2021 13:27:14 +0000 Subject: [PATCH 13/18] [network] Make CacheIOThread::ThreadFunc hold reference to thread. --- netwerk/cache2/CacheIOThread.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/netwerk/cache2/CacheIOThread.cpp b/netwerk/cache2/CacheIOThread.cpp index c686c0f8d0..fe0a4ddb05 100644 --- a/netwerk/cache2/CacheIOThread.cpp +++ b/netwerk/cache2/CacheIOThread.cpp @@ -215,12 +215,22 @@ nsresult CacheIOThread::Init() mBlockingIOWatcher = MakeUnique(); } + // Increase the reference count while spawning a new thread. + // If PR_CreateThread succeeds, we will forget this reference and the thread + // will be responsible to release it when it completes. + RefPtr self = this; + mThread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, this, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 128 * 1024); if (!mThread) { return NS_ERROR_FAILURE; } + + // IMPORTANT: The thread now owns this reference, so it's important that we + // leak it here, otherwise we'll end up with a bad refcount. + // See the dont_AddRef in ThreadFunc(). + Unused << self.forget().take(); return NS_OK; } @@ -382,7 +392,9 @@ void CacheIOThread::ThreadFunc(void* aClosure) { PR_SetCurrentThreadName("Cache2 I/O"); mozilla::IOInterposer::RegisterCurrentThread(); - CacheIOThread* thread = static_cast(aClosure); + // We hold on to this reference for the duration of the thread. + RefPtr thread = + dont_AddRef(static_cast(aClosure)); thread->ThreadFunc(); mozilla::IOInterposer::UnregisterCurrentThread(); } From d3f293ec094f7b004a3bbe0922b5dd32b5c50fdd Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 14 Jul 2021 13:51:11 +0000 Subject: [PATCH 14/18] [ANGLE] Cherry-pick upstream fix --- gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp index d27a8d53af..332db77e92 100644 --- a/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp +++ b/gfx/angle/src/libANGLE/renderer/d3d/d3d11/Image11.cpp @@ -205,6 +205,7 @@ bool Image11::redefine(GLenum target, GLenum internalformat, const gl::Extents & { if (mWidth != size.width || mHeight != size.height || + mDepth != size.depth || mInternalFormat != internalformat || forceRelease) { From bfac131dc2e8dfade761f19e47bbb62d2062d178 Mon Sep 17 00:00:00 2001 From: Dana Keeler Date: Wed, 14 Jul 2021 14:42:24 +0000 Subject: [PATCH 15/18] [NSPR] Lock access to PRCallOnceType members in PR_CallOnce* for thread safety. Cherry-picked upstream fix from 4.31 --- nsprpub/pr/src/misc/prinit.c | 46 +++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/nsprpub/pr/src/misc/prinit.c b/nsprpub/pr/src/misc/prinit.c index 5ac99fe588..a952ad6554 100644 --- a/nsprpub/pr/src/misc/prinit.c +++ b/nsprpub/pr/src/misc/prinit.c @@ -771,10 +771,15 @@ PR_IMPLEMENT(PRStatus) PR_CallOnce( _PR_ImplicitInitialization(); } - if (!once->initialized) { + PR_Lock(mod_init.ml); + PRIntn initialized = once->initialized; + PRStatus status = once->status; + PR_Unlock(mod_init.ml); + if (!initialized) { if (PR_ATOMIC_SET(&once->inProgress, 1) == 0) { - once->status = (*func)(); + status = (*func)(); PR_Lock(mod_init.ml); + once->status = status; once->initialized = 1; PR_NotifyAllCondVar(mod_init.cv); PR_Unlock(mod_init.ml); @@ -783,14 +788,18 @@ PR_IMPLEMENT(PRStatus) PR_CallOnce( while (!once->initialized) { PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT); } + status = once->status; PR_Unlock(mod_init.ml); + if (PR_SUCCESS != status) { + PR_SetError(PR_CALL_ONCE_ERROR, 0); + } } - } else { - if (PR_SUCCESS != once->status) { - PR_SetError(PR_CALL_ONCE_ERROR, 0); - } + return status; } - return once->status; + if (PR_SUCCESS != status) { + PR_SetError(PR_CALL_ONCE_ERROR, 0); + } + return status; } PR_IMPLEMENT(PRStatus) PR_CallOnceWithArg( @@ -802,10 +811,15 @@ PR_IMPLEMENT(PRStatus) PR_CallOnceWithArg( _PR_ImplicitInitialization(); } - if (!once->initialized) { + PR_Lock(mod_init.ml); + PRIntn initialized = once->initialized; + PRStatus status = once->status; + PR_Unlock(mod_init.ml); + if (!initialized) { if (PR_ATOMIC_SET(&once->inProgress, 1) == 0) { - once->status = (*func)(arg); + status = (*func)(arg); PR_Lock(mod_init.ml); + once->status = status; once->initialized = 1; PR_NotifyAllCondVar(mod_init.cv); PR_Unlock(mod_init.ml); @@ -814,14 +828,18 @@ PR_IMPLEMENT(PRStatus) PR_CallOnceWithArg( while (!once->initialized) { PR_WaitCondVar(mod_init.cv, PR_INTERVAL_NO_TIMEOUT); } + status = once->status; PR_Unlock(mod_init.ml); + if (PR_SUCCESS != status) { + PR_SetError(PR_CALL_ONCE_ERROR, 0); + } } - } else { - if (PR_SUCCESS != once->status) { - PR_SetError(PR_CALL_ONCE_ERROR, 0); - } + return status; } - return once->status; + if (PR_SUCCESS != status) { + PR_SetError(PR_CALL_ONCE_ERROR, 0); + } + return status; } PRBool _PR_Obsolete(const char *obsolete, const char *preferred) From fc40ca5ac1ce70a4a729a58df13d63def42fca3f Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 14 Jul 2021 15:15:14 +0000 Subject: [PATCH 16/18] [gfx] Hard-block old mesa/nouveau versions --- widget/GfxInfoX11.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/widget/GfxInfoX11.cpp b/widget/GfxInfoX11.cpp index 05a2cab1a1..af374dc44a 100644 --- a/widget/GfxInfoX11.cpp +++ b/widget/GfxInfoX11.cpp @@ -359,7 +359,11 @@ GfxInfo::GetFeatureStatusImpl(int32_t aFeature, aSuggestedDriverVersion.AssignLiteral("Mesa 8.1"); } } - + else if (mIsNouveau && version(mMajorVersion, mMinorVersion) < version(11,0)) { + *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; + aFailureId = "FEATURE_FAILURE_OLD_NOUVEAU"; + aSuggestedDriverVersion.AssignLiteral("Mesa 11.0"); + } } else if (mIsNVIDIA) { if (version(mMajorVersion, mMinorVersion, mRevisionVersion) < version(257,21)) { *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DRIVER_VERSION; From 17a32c4f3f8206d258b39c13bc7e89b671ae38a3 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Mon, 12 Jul 2021 13:09:00 -0400 Subject: [PATCH 17/18] [Basilisk] Issue MoonchildProductions/UXP#1793 - Override the global style for Windows 10 that adds a bottom border to the toolbox widget The local application style already provides this. --- application/basilisk/themes/windows/browser.css | 7 +++++++ application/basilisk/themes/windows/places/organizer.css | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/application/basilisk/themes/windows/browser.css b/application/basilisk/themes/windows/browser.css index ee537a4b66..8ce4e4a620 100644 --- a/application/basilisk/themes/windows/browser.css +++ b/application/basilisk/themes/windows/browser.css @@ -123,6 +123,13 @@ toolbar:-moz-lwtheme { border-top: none; } +@media (-moz-os-version: windows-win10) and (-moz-windows-theme: aero) { + #navigator-toolbox { + /* Override the global style for Windows 10 that adds a bottom border */ + border-bottom: none; + }; +} + #navigator-toolbox::after { content: ""; display: -moz-box; diff --git a/application/basilisk/themes/windows/places/organizer.css b/application/basilisk/themes/windows/places/organizer.css index 4de603b9f3..263286d556 100644 --- a/application/basilisk/themes/windows/places/organizer.css +++ b/application/basilisk/themes/windows/places/organizer.css @@ -193,6 +193,13 @@ } } +@media (-moz-os-version: windows-win10) and (-moz-windows-theme: aero) { + #placesToolbox { + /* Override the global style for Windows 10 that adds a bottom border */ + border-bottom: none; + } +} + @media (-moz-windows-default-theme) and (-moz-os-version: windows-vista), (-moz-windows-default-theme) and (-moz-os-version: windows-win7) { #placesView, From a668e99abde5761d3dc355b697052567fcb93390 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Mon, 12 Jul 2021 13:08:22 -0400 Subject: [PATCH 18/18] [Pale-Moon] Issue MoonchildProductions/UXP#1793 - Override the global style for Windows 10 that adds a bottom border to the toolbox widget The local application style already provides this. --- application/palemoon/themes/windows/browser.css | 7 +++++++ application/palemoon/themes/windows/places/organizer.css | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/application/palemoon/themes/windows/browser.css b/application/palemoon/themes/windows/browser.css index 6bfb7b9c8d..d2bf31c071 100644 --- a/application/palemoon/themes/windows/browser.css +++ b/application/palemoon/themes/windows/browser.css @@ -91,6 +91,13 @@ border-top: none; } +@media (-moz-os-version: windows-win10) and (-moz-windows-theme: aero) { + #navigator-toolbox { + /* Override the global style for Windows 10 that adds a bottom border */ + border-bottom: none; + }; +} + #navigator-toolbox::after { content: ""; display: -moz-box; diff --git a/application/palemoon/themes/windows/places/organizer.css b/application/palemoon/themes/windows/places/organizer.css index 0a947c2ac0..53c30cfb90 100644 --- a/application/palemoon/themes/windows/places/organizer.css +++ b/application/palemoon/themes/windows/places/organizer.css @@ -214,6 +214,13 @@ } } +@media (-moz-os-version: windows-win10) and (-moz-windows-theme: aero) { + #placesToolbox { + /* Override the global style for Windows 10 that adds a bottom border */ + border-bottom: none; + } +} + @media (-moz-windows-default-theme) and (-moz-os-version: windows-vista), (-moz-windows-default-theme) and (-moz-os-version: windows-win7) { #placesView,