From dc425fc3e89188d0b720086f06cb0d812ec34598 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Thu, 21 Dec 2023 14:04:34 +0100 Subject: [PATCH 1/9] Revert "[XPCOM] Compare return value of readlink in nsLocalFileUnix::GetNativeTarget" This reverts commit 66b07ce6991160e768b5113f8adcd0b47be58791. --- xpcom/io/nsLocalFileUnix.cpp | 70 +++++++++++++----------------------- 1 file changed, 24 insertions(+), 46 deletions(-) diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp index 1f71c70566..33c6b6bfaf 100644 --- a/xpcom/io/nsLocalFileUnix.cpp +++ b/xpcom/io/nsLocalFileUnix.cpp @@ -1699,47 +1699,6 @@ nsLocalFile::Contains(nsIFile* aInFile, bool* aResult) return NS_OK; } -static nsresult ReadLinkSafe(const nsCString& aTarget, int32_t aExpectedSize, - nsACString& aOutBuffer) { - // If we call readlink with a buffer size S it returns S, then we cannot tell - // if the buffer was big enough to hold the entire path. We allocate an - // additional byte so we can check if the buffer was large enough. - const auto allocSize = CheckedInt(aExpectedSize) + 1; - if (!allocSize.isValid()) { - return NS_ERROR_OUT_OF_MEMORY; - } - - auto result = aOutBuffer.BulkWrite(allocSize.value(), 0, false); - if (result.isErr()) { - return result.unwrapErr(); - } - - auto handle = result.unwrap(); - - while (true) { - ssize_t bytesWritten = - readlink(aTarget.get(), handle.Elements(), handle.Length()); - if (bytesWritten < 0) { - return NSRESULT_FOR_ERRNO(); - } - - // written >= 0 so it is safe to cast to size_t. - if ((size_t)bytesWritten < handle.Length()) { - // Target might have changed since the lstat call, or lstat might lie, see - // bug 1791029. - handle.Finish(bytesWritten, false); - return NS_OK; - } - - // The buffer was not large enough, so double it and try again. - auto restartResult = handle.RestartBulkWrite(handle.Length() * 2, 0, false); - if (restartResult.isErr()) { - return restartResult.unwrapErr(); - } - } -} - - NS_IMETHODIMP nsLocalFile::GetNativeTarget(nsACString& aResult) { @@ -1755,12 +1714,21 @@ nsLocalFile::GetNativeTarget(nsACString& aResult) return NS_ERROR_FILE_INVALID_PATH; } + int32_t size = (int32_t)symStat.st_size; nsAutoCString target; - nsresult rv = ReadLinkSafe(mPath, symStat.st_size, target); - if (NS_FAILED(rv)) { - return rv; + if (!target.SetLength(size, mozilla::fallible)) { + return NS_ERROR_OUT_OF_MEMORY; } + ssize_t written = readlink(mPath.get(), target.BeginWriting(), size_t(size)); + if (written < 0) { + return NSRESULT_FOR_ERRNO(); + } + // Target might have changed since the lstat call, or lstat might lie, see bug + // 1791029. + target.Truncate(written); + + nsresult rv = NS_OK; nsCOMPtr self(this); int32_t maxLinks = 40; while (true) { @@ -1798,12 +1766,22 @@ nsLocalFile::GetNativeTarget(nsACString& aResult) break; } + int32_t newSize = (int32_t)symStat.st_size; + size = newSize; nsAutoCString newTarget; - rv = ReadLinkSafe(flatRetval, symStat.st_size, newTarget); - if (NS_FAILED(rv)) { + if (!newTarget.SetLength(size, mozilla::fallible)) { + rv = NS_ERROR_OUT_OF_MEMORY; break; } + ssize_t linkLen = readlink(flatRetval.get(), newTarget.BeginWriting(), size); + if (linkLen == -1) { + rv = NSRESULT_FOR_ERRNO(); + break; + } + // Target might have changed since the lstat call, or lstat might lie, see bug + // 1791029. + newTarget.Truncate(linkLen); target = newTarget; } From 2e330af8c484b516bc948ec43ee08426ba58d8a8 Mon Sep 17 00:00:00 2001 From: Matheus Marinho Date: Thu, 28 Dec 2023 15:01:38 -0300 Subject: [PATCH 2/9] No Issue - Fix syntax in js/src/jsapi-tests/moz.build --- js/src/jsapi-tests/moz.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/jsapi-tests/moz.build b/js/src/jsapi-tests/moz.build index 1e5f43aa5a..1b8730c49d 100644 --- a/js/src/jsapi-tests/moz.build +++ b/js/src/jsapi-tests/moz.build @@ -3,7 +3,7 @@ # 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(../js-cxxflags.mozbuild) +include('../js-cxxflags.mozbuild') GeckoProgram('jsapi-tests', linkage=None) From b47cb0f6a4caa2f91cc543a389afab59d24938ec Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 29 Dec 2023 13:53:16 +0100 Subject: [PATCH 3/9] Issue #2407 - Rename full-screen-api.ignore-widgets Renames to full-screen-api.restrict-to-window and clarifies comments for its intended use. Resolves #2407. --- dom/base/nsGlobalWindow.cpp | 11 ++++++----- modules/libpref/init/all.js | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 295c498965..f264aa50d5 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -6927,11 +6927,12 @@ nsGlobalWindow::SetFullscreenInternal(FullscreenReason aReason, // gone full screen, the state trap above works. mFullScreen = aFullScreen; - // Sometimes we don't want the top-level widget to actually go fullscreen, - // for example in the B2G desktop client, we don't want the emulated screen - // dimensions to appear to increase when entering fullscreen mode; we just - // want the content to fill the entire client area of the emulator window. - if (!Preferences::GetBool("full-screen-api.ignore-widgets", false)) { + // Sometimes, users don't want the DOM to actually go fullscreen, for + // example on large monitors where it would waste screen real estate. + // When restricted by the relevant preference, we just want the content + // to fill the area of the existing window, instead, which is done by + // skipping resizing of the top-level content widget to be screen-filling. + if (!Preferences::GetBool("full-screen-api.restrict-to-window", false)) { if (MakeWidgetFullscreen(this, aReason, aFullScreen)) { // The rest of code for switching fullscreen is in nsGlobalWindow:: // FinishFullscreenChange() which will be called after sizemodechange diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 3b46c33b27..c1c50c25af 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4564,8 +4564,9 @@ pref("full-screen-api.enabled", false); pref("full-screen-api.unprefix.enabled", true); pref("full-screen-api.allow-trusted-requests-only", true); pref("full-screen-api.pointer-lock.enabled", true); -// whether to prevent the top level widget from going fullscreen -pref("full-screen-api.ignore-widgets", false); +// Whether to restrict the full-screen API to the existing window size +// If true, this effectively make fullscreen "fill window" instead. +pref("full-screen-api.restrict-to-window", false); // transition duration of fade-to-black and fade-from-black, unit: ms pref("full-screen-api.transition-duration.enter", "0 0"); From 0bcbbafa73c7769810420dce67f3242b6570ffa4 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 29 Dec 2023 22:56:38 +0100 Subject: [PATCH 4/9] No issue - Tighten default script time-outs and expose stop_slow_scripts The timings here are still slightly more lenient than the hard-coded fallback timings in code (10/20 for content/chrome respectively) but we definitely should not need very long time-outs by default on Chrome scripts anymore. Also exposes dom.always_stop_slow_scripts to about:config since we're making it also UI-configurable in Pale Moon and it just makes sense not to hide this option. --- modules/libpref/init/all.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index c1c50c25af..ecf29bef53 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -2752,8 +2752,11 @@ pref("editor.resizing.preserve_ratio", true); pref("editor.positioning.offset", 0); pref("dom.use_watchdog", true); -pref("dom.max_chrome_script_run_time", 90); -pref("dom.max_script_run_time", 20); +pref("dom.max_chrome_script_run_time", 30); +pref("dom.max_script_run_time", 15); + +// Automatically terminate non-responsive scripts if script_run_time expires. +pref("dom.always_stop_slow_scripts", false); // Stop all scripts in a compartment when the "stop script" dialog is used. pref("dom.global_stop_script", true); From 10a37ae46715200e5426aee0008a13028c10c124 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sat, 30 Dec 2023 22:16:03 -0500 Subject: [PATCH 5/9] Issue #1442 Follow-up: Fix debug assertion in JSFun Change in d5020b69bd introduced a debug build crash, this fixes the crash by properly porting the changes to an assertion as mentioned in issue #2410. --- js/src/jsfun.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp index 5255aebbfc..ec13ce3e9a 100644 --- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -2424,11 +2424,7 @@ namespace detail { JS_PUBLIC_API(void) CheckIsValidConstructible(const Value& calleev) { - JSObject* callee = &calleev.toObject(); - if (callee->is()) - MOZ_ASSERT(callee->as().isConstructor()); - else - MOZ_ASSERT(callee->constructHook() != nullptr); + MOZ_ASSERT(calleev.toObject().isConstructor()); } } // namespace detail From 644b8680b27248883f41b28068e4cabcb2b38240 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sat, 30 Dec 2023 22:18:07 -0500 Subject: [PATCH 6/9] Debug: Remove assertion for nsDOMNavigationTiming. As mentioned in issue #2410, this aggressive assertion can cause an uneeded crash during debug build runs. --- dom/base/nsDOMNavigationTiming.h | 1 - 1 file changed, 1 deletion(-) diff --git a/dom/base/nsDOMNavigationTiming.h b/dom/base/nsDOMNavigationTiming.h index 73c0a9041b..c79a3f5765 100644 --- a/dom/base/nsDOMNavigationTiming.h +++ b/dom/base/nsDOMNavigationTiming.h @@ -162,7 +162,6 @@ public: inline DOMHighResTimeStamp TimeStampToDOMHighRes(mozilla::TimeStamp aStamp) const { - MOZ_ASSERT(!aStamp.IsNull(), "The timestamp should not be null"); if (aStamp.IsNull()) { return 0; } From f3d37946be43026c4cbda607051f862aee0c8d21 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Sat, 30 Dec 2023 22:48:56 -0500 Subject: [PATCH 7/9] No issue - Allow embedded search module in HYPE_ICEDOVE project --- toolkit/components/moz.build | 1 + 1 file changed, 1 insertion(+) diff --git a/toolkit/components/moz.build b/toolkit/components/moz.build index 64af142884..3cd0e3c6fe 100644 --- a/toolkit/components/moz.build +++ b/toolkit/components/moz.build @@ -84,6 +84,7 @@ if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']: DIRS += ['filepicker'] if CONFIG['MOZ_TOOLKIT_SEARCH'] and not CONFIG['MC_BASILISK'] \ + and not CONFIG['HYPE_ICEDOVE'] \ and not CONFIG['HYPE_ICEWEASEL']: DIRS += ['search'] From 3e65ae353ab795157d25bc229a94388b4302a64a Mon Sep 17 00:00:00 2001 From: Martok Date: Sun, 31 Dec 2023 02:31:08 +0100 Subject: [PATCH 8/9] Issue #2430 - Allow network.http.spdy.chunk-size to be larger than 16K According to https://datatracker.ietf.org/doc/html/rfc7540#section-4.2 The size of a frame payload is limited by the maximum size that a receiver advertises in the SETTINGS_MAX_FRAME_SIZE setting. This setting can have any value between 2^14 (16,384) and 2^24-1 (16,777,215) octets, inclusive. --- netwerk/protocol/http/nsHttpHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index a4e481fcac..3a5ec2936c 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -1362,10 +1362,10 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) } if (PREF_CHANGED(HTTP_PREF("spdy.chunk-size"))) { - // keep this within http/2 ranges of 1 to 2^14-1 + // keep this within http/2 ranges of 1 to 2^24-1 rv = prefs->GetIntPref(HTTP_PREF("spdy.chunk-size"), &val); if (NS_SUCCEEDED(rv)) - mSpdySendingChunkSize = (uint32_t) clamped(val, 1, 0x3fff); + mSpdySendingChunkSize = (uint32_t) clamped(val, 1, 0xffffff); } // The amount of idle seconds on a spdy connection before initiating a From c451531d54bc80d8f283824e5e6de6734b8c5f95 Mon Sep 17 00:00:00 2001 From: Martok Date: Tue, 2 Jan 2024 01:20:19 +0100 Subject: [PATCH 9/9] Issue #2430 - No longer force tcp send buffer size on HTTP/2 uploads > 128KB With connection-level and stream-level flow control, it is not needed. On fast connections with large-ish BWP, this can improve upload speed by > 5x --- modules/libpref/init/all.js | 2 +- netwerk/protocol/http/Http2Stream.cpp | 3 ++- netwerk/protocol/http/nsHttpHandler.cpp | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index ecf29bef53..1f0ad89f71 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1602,7 +1602,7 @@ pref("network.http.spdy.coalesce-hostnames", true); pref("network.http.spdy.persistent-settings", false); pref("network.http.spdy.ping-threshold", 58); pref("network.http.spdy.ping-timeout", 8); -pref("network.http.spdy.send-buffer-size", 131072); +pref("network.http.spdy.send-buffer-size", 0); // 0 - Auto (managed by OS) pref("network.http.spdy.allow-push", true); pref("network.http.spdy.push-allowance", 131072); // 128KB pref("network.http.spdy.pull-allowance", 12582912); // 12MB diff --git a/netwerk/protocol/http/Http2Stream.cpp b/netwerk/protocol/http/Http2Stream.cpp index 9b8f13c2d2..79942af07d 100644 --- a/netwerk/protocol/http/Http2Stream.cpp +++ b/netwerk/protocol/http/Http2Stream.cpp @@ -788,8 +788,9 @@ Http2Stream::UpdateTransportSendEvents(uint32_t count) // the session and cap the send buffers by default at 128KB. // (10Mbit/sec @ 100ms) // + // This feature is disabled by default. uint32_t bufferSize = gHttpHandler->SpdySendBufferSize(); - if ((mTotalSent > bufferSize) && !mSetTCPSocketBuffer) { + if ((bufferSize > 0) && (mTotalSent > bufferSize) && !mSetTCPSocketBuffer) { mSetTCPSocketBuffer = 1; mSocketTransport->SetSendBufferSize(bufferSize); } diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 3a5ec2936c..4e96415105 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -1437,8 +1437,12 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) // closing the session. if (PREF_CHANGED(HTTP_PREF("spdy.send-buffer-size"))) { rv = prefs->GetIntPref(HTTP_PREF("spdy.send-buffer-size"), &val); - if (NS_SUCCEEDED(rv)) - mSpdySendBufferSize = (uint32_t) clamped(val, 1500, 0x7fffffff); + if (NS_SUCCEEDED(rv)) { + if (val != 0) + mSpdySendBufferSize = (uint32_t) clamped(val, 1500, 0x7fffffff); + else + mSpdySendBufferSize = 0; + } } // The maximum amount of time to wait for socket transport to be