Skip to content

Commit

Permalink
Merge pull request #1469 from Floorp-Projects/upstream-esr128-2024101…
Browse files Browse the repository at this point in the history
…0124745

Pull upstream
  • Loading branch information
surapunoyousei authored Oct 10, 2024
2 parents ef28dfd + dc661c0 commit 55670e9
Show file tree
Hide file tree
Showing 67 changed files with 2,169 additions and 1,894 deletions.
3 changes: 3 additions & 0 deletions .hgtags
Original file line number Diff line number Diff line change
Expand Up @@ -5082,3 +5082,6 @@ b5f945290d0a97227a9de2c841b6695e40a9f7c2 FIREFOX_128_1_0esr_RELEASE
49e746f805bd2d0c6a18e9db2df6ccbac0242eae FIREFOX_128_2_0esr_BUILD1
49e746f805bd2d0c6a18e9db2df6ccbac0242eae FIREFOX_128_2_0esr_RELEASE
e2cb3d9c8cfc18acad7f77add351416dc95b67c4 FIREFOX_128_3_0esr_BUILD1
e2cb3d9c8cfc18acad7f77add351416dc95b67c4 FIREFOX_128_3_0esr_RELEASE
e0c969a3bfc0a23219384269e5b36a589c8f6cc5 FIREFOX_128_3_1esr_BUILD1
e0c969a3bfc0a23219384269e5b36a589c8f6cc5 FIREFOX_128_3_1esr_RELEASE
2 changes: 1 addition & 1 deletion CLOBBER
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more.

Merge day clobber 2024-09-02
Merge day clobber 2024-09-30
2 changes: 1 addition & 1 deletion browser/config/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
128.3.0
128.4.0
2 changes: 1 addition & 1 deletion browser/config/version_display.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11.19.0
11.19.1
2 changes: 1 addition & 1 deletion config/milestone.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
# hardcoded milestones in the tree from these two files.
#--------------------------------------------------------

128.3.0
128.4.0
22 changes: 11 additions & 11 deletions docshell/base/BrowsingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3772,17 +3772,17 @@ bool BrowsingContext::ShouldUpdateSessionHistory(uint32_t aLoadType) {
(IsForceReloadType(aLoadType) && IsSubframe()));
}

nsresult BrowsingContext::CheckLocationChangeRateLimit(CallerType aCallerType) {
nsresult BrowsingContext::CheckNavigationRateLimit(CallerType aCallerType) {
// We only rate limit non system callers
if (aCallerType == CallerType::System) {
return NS_OK;
}

// Fetch rate limiting preferences
uint32_t limitCount =
StaticPrefs::dom_navigation_locationChangeRateLimit_count();
StaticPrefs::dom_navigation_navigationRateLimit_count();
uint32_t timeSpanSeconds =
StaticPrefs::dom_navigation_locationChangeRateLimit_timespan();
StaticPrefs::dom_navigation_navigationRateLimit_timespan();

// Disable throttling if either of the preferences is set to 0.
if (limitCount == 0 || timeSpanSeconds == 0) {
Expand All @@ -3791,15 +3791,15 @@ nsresult BrowsingContext::CheckLocationChangeRateLimit(CallerType aCallerType) {

TimeDuration throttleSpan = TimeDuration::FromSeconds(timeSpanSeconds);

if (mLocationChangeRateLimitSpanStart.IsNull() ||
((TimeStamp::Now() - mLocationChangeRateLimitSpanStart) > throttleSpan)) {
if (mNavigationRateLimitSpanStart.IsNull() ||
((TimeStamp::Now() - mNavigationRateLimitSpanStart) > throttleSpan)) {
// Initial call or timespan exceeded, reset counter and timespan.
mLocationChangeRateLimitSpanStart = TimeStamp::Now();
mLocationChangeRateLimitCount = 1;
mNavigationRateLimitSpanStart = TimeStamp::Now();
mNavigationRateLimitCount = 1;
return NS_OK;
}

if (mLocationChangeRateLimitCount >= limitCount) {
if (mNavigationRateLimitCount >= limitCount) {
// Rate limit reached

Document* doc = GetDocument();
Expand All @@ -3812,14 +3812,14 @@ nsresult BrowsingContext::CheckLocationChangeRateLimit(CallerType aCallerType) {
return NS_ERROR_DOM_SECURITY_ERR;
}

mLocationChangeRateLimitCount++;
mNavigationRateLimitCount++;
return NS_OK;
}

void BrowsingContext::ResetLocationChangeRateLimit() {
void BrowsingContext::ResetNavigationRateLimit() {
// Resetting the timestamp object will cause the check function to
// init again and reset the rate limit.
mLocationChangeRateLimitSpanStart = TimeStamp();
mNavigationRateLimitSpanStart = TimeStamp();
}

void BrowsingContext::LocationCreated(dom::Location* aLocation) {
Expand Down
12 changes: 6 additions & 6 deletions docshell/base/BrowsingContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -898,13 +898,13 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {

// Checks if we reached the rate limit for calls to Location and History API.
// The rate limit is controlled by the
// "dom.navigation.locationChangeRateLimit" prefs.
// "dom.navigation.navigationRateLimit" prefs.
// Rate limit applies per BrowsingContext.
// Returns NS_OK if we are below the rate limit and increments the counter.
// Returns NS_ERROR_DOM_SECURITY_ERR if limit is reached.
nsresult CheckLocationChangeRateLimit(CallerType aCallerType);
nsresult CheckNavigationRateLimit(CallerType aCallerType);

void ResetLocationChangeRateLimit();
void ResetNavigationRateLimit();

mozilla::dom::DisplayMode DisplayMode() { return Top()->GetDisplayMode(); }

Expand Down Expand Up @@ -1432,9 +1432,9 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
nsTArray<std::function<void(uint64_t)>> mDiscardListeners;

// Counter and time span for rate limiting Location and History API calls.
// Used by CheckLocationChangeRateLimit. Do not apply cross-process.
uint32_t mLocationChangeRateLimitCount;
mozilla::TimeStamp mLocationChangeRateLimitSpanStart;
// Used by CheckNavigationRateLimit. Do not apply cross-process.
uint32_t mNavigationRateLimitCount;
mozilla::TimeStamp mNavigationRateLimitSpanStart;

mozilla::LinkedList<dom::Location> mLocations;
};
Expand Down
2 changes: 1 addition & 1 deletion docshell/shistory/ChildSHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void ChildSHistory::AsyncGo(int32_t aOffset, bool aRequireUserInteraction,
MOZ_LOG(gSHLog, LogLevel::Debug,
("ChildSHistory::AsyncGo(%d), current index = %d", aOffset,
index.value()));
nsresult rv = mBrowsingContext->CheckLocationChangeRateLimit(aCallerType);
nsresult rv = mBrowsingContext->CheckNavigationRateLimit(aCallerType);
if (NS_FAILED(rv)) {
MOZ_LOG(gSHLog, LogLevel::Debug, ("Rejected"));
aRv.Throw(rv);
Expand Down
9 changes: 5 additions & 4 deletions docshell/test/navigation/test_rate_limit_location_change.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@

async function setup() {
await SpecialPowers.pushPrefEnv({set: [
["dom.navigation.locationChangeRateLimit.count", RATE_LIMIT_COUNT],
["dom.navigation.locationChangeRateLimit.timespan", RATE_LIMIT_TIME_SPAN]]});
["dom.navigation.navigationRateLimit.count", RATE_LIMIT_COUNT],
["dom.navigation.navigationRateLimit.timespan", RATE_LIMIT_TIME_SPAN]]});
}

let inc = 0;

const rateLimitedFunctions = (win) => ({
"history.replaceState": () => win.history.replaceState(null, "test", `${win.location.href}#${inc++}`),
"history.pushState": () => win.history.pushState(null, "test", `${win.location.href}#${inc++}`),
"history.SetScrollRestoration": () => win.history.scrollRestoration = "auto",
"history.back": () => win.history.back(),
"history.forward": () => win.history.forward(),
"history.go": () => win.history.go(-1),
Expand Down Expand Up @@ -53,7 +54,7 @@
Object.entries(rateLimitedFunctions(win)).forEach(([name, fn]) => {
// Reset the rate limit for the next run.
info("Reset rate limit.");
SpecialPowers.wrap(win).browsingContext.resetLocationChangeRateLimit();
SpecialPowers.wrap(win).browsingContext.resetNavigationRateLimit();

info(`Calling ${name} ${RATE_LIMIT_COUNT} times to reach the rate limit.`);
for(let i = 0; i< RATE_LIMIT_COUNT; i++) {
Expand Down Expand Up @@ -83,7 +84,7 @@

// Cleanup
win.close();
SpecialPowers.wrap(win).browsingContext.resetLocationChangeRateLimit();
SpecialPowers.wrap(win).browsingContext.resetNavigationRateLimit();
SimpleTest.finish();
}

Expand Down
35 changes: 14 additions & 21 deletions dom/animation/AnimationTimeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,41 +40,33 @@ AnimationTimeline::~AnimationTimeline() { mAnimationOrder.clear(); }
bool AnimationTimeline::Tick(TickState& aState) {
bool needsTicks = false;

nsTArray<Animation*> animationsToRemove;

for (Animation* animation = mAnimationOrder.getFirst(); animation;
animation =
static_cast<LinkedListElement<Animation>*>(animation)->getNext()) {
AutoTArray<RefPtr<Animation>, 32> animationsToTick;
for (Animation* animation : mAnimationOrder) {
MOZ_ASSERT(mAnimations.Contains(animation),
"The sampling order list should be a subset of the hashset");
MOZ_ASSERT(!animation->IsHiddenByContentVisibility(),
"The sampling order list should not contain any animations "
"that are hidden by content-visibility");
animationsToTick.AppendElement(animation);
}

for (Animation* animation : animationsToTick) {
// Skip any animations that are longer need associated with this timeline.
if (animation->GetTimeline() != this) {
// If animation has some other timeline, it better not be also in the
// animation list of this timeline object!
MOZ_ASSERT(!animation->GetTimeline());
animationsToRemove.AppendElement(animation);
RemoveAnimation(animation);
continue;
}

needsTicks |= animation->NeedsTicks();
// Even if |animation| doesn't need future ticks, we should still
// Tick it this time around since it might just need a one-off tick in
// order to dispatch events.
// Even if |animation| doesn't need future ticks, we should still Tick it
// this time around since it might just need a one-off tick in order to
// queue events.
animation->Tick(aState);

if (!animation->NeedsTicks()) {
animationsToRemove.AppendElement(animation);
RemoveAnimation(animation);
}
}

for (Animation* animation : animationsToRemove) {
RemoveAnimation(animation);
}

return needsTicks;
}

Expand All @@ -90,11 +82,12 @@ void AnimationTimeline::NotifyAnimationUpdated(Animation& aAnimation) {
}

void AnimationTimeline::RemoveAnimation(Animation* aAnimation) {
MOZ_ASSERT(!aAnimation->GetTimeline() || aAnimation->GetTimeline() == this);
if (static_cast<LinkedListElement<Animation>*>(aAnimation)->isInList()) {
if (static_cast<LinkedListElement<Animation>*>(aAnimation)->isInList() &&
MOZ_LIKELY(!aAnimation->GetTimeline() ||
aAnimation->GetTimeline() == this)) {
static_cast<LinkedListElement<Animation>*>(aAnimation)->remove();
MOZ_ASSERT(mAnimations.Contains(aAnimation),
"The sampling order list should be a subset of the hashset");
static_cast<LinkedListElement<Animation>*>(aAnimation)->remove();
}
mAnimations.Remove(aAnimation);
}
Expand Down
8 changes: 5 additions & 3 deletions dom/animation/DocumentTimeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,12 @@ void DocumentTimeline::NotifyAnimationUpdated(Animation& aAnimation) {
}

void DocumentTimeline::TriggerAllPendingAnimationsNow() {
AutoTArray<RefPtr<Animation>, 32> animationsToTrigger;
for (Animation* animation : mAnimationOrder) {
animationsToTrigger.AppendElement(animation);
}

for (Animation* animation : animationsToTrigger) {
animation->TryTriggerNow();
}
}
Expand Down Expand Up @@ -188,9 +193,6 @@ void DocumentTimeline::WillRefresh() {
// of mDocument's PresShell.
if (nsRefreshDriver* refreshDriver = GetRefreshDriver()) {
refreshDriver->EnsureAnimationUpdate();
} else {
MOZ_ASSERT_UNREACHABLE(
"Refresh driver should still be valid at end of WillRefresh");
}
}

Expand Down
11 changes: 3 additions & 8 deletions dom/animation/ScrollTimelineAnimationTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ namespace mozilla {
NS_IMPL_CYCLE_COLLECTION(ScrollTimelineAnimationTracker, mPendingSet, mDocument)

void ScrollTimelineAnimationTracker::TriggerPendingAnimations() {
for (auto iter = mPendingSet.begin(), end = mPendingSet.end(); iter != end;
++iter) {
dom::Animation* animation = *iter;

for (RefPtr<dom::Animation>& animation :
ToTArray<AutoTArray<RefPtr<dom::Animation>, 32>>(mPendingSet)) {
MOZ_ASSERT(animation->GetTimeline() &&
!animation->GetTimeline()->IsMonotonicallyIncreasing());

// FIXME: Trigger now may not be correct because the spec says:
// If a user agent determines that animation is immediately ready, it may
// schedule the task (i.e. ResumeAt()) as a microtask such that it runs at
Expand All @@ -39,9 +36,7 @@ void ScrollTimelineAnimationTracker::TriggerPendingAnimations() {
// inactive, and this also matches the current spec definition.
continue;
}

// Note: Remove() is legitimately called once per entry during the loop.
mPendingSet.Remove(iter);
mPendingSet.Remove(animation);
}
}

Expand Down
2 changes: 1 addition & 1 deletion dom/base/Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ void Location::Reload(bool aForceget, nsIPrincipal& aSubjectPrincipal,
? CallerType::System
: CallerType::NonSystem;

nsresult rv = bc->CheckLocationChangeRateLimit(callerType);
nsresult rv = bc->CheckNavigationRateLimit(callerType);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return;
Expand Down
2 changes: 1 addition & 1 deletion dom/base/LocationBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void LocationBase::SetURI(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
? CallerType::System
: CallerType::NonSystem;

nsresult rv = bc->CheckLocationChangeRateLimit(callerType);
nsresult rv = bc->CheckNavigationRateLimit(callerType);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return;
Expand Down
16 changes: 13 additions & 3 deletions dom/base/nsHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ uint32_t nsHistory::GetLength(ErrorResult& aRv) const {
return len >= 0 ? len : 0;
}

ScrollRestoration nsHistory::GetScrollRestoration(mozilla::ErrorResult& aRv) {
ScrollRestoration nsHistory::GetScrollRestoration(mozilla::dom::CallerType aCallerType, mozilla::ErrorResult& aRv) {
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryReferent(mInnerWindow));
if (!win || !win->HasActiveDocument() || !win->GetDocShell()) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
Expand All @@ -88,13 +88,23 @@ ScrollRestoration nsHistory::GetScrollRestoration(mozilla::ErrorResult& aRv) {
}

void nsHistory::SetScrollRestoration(mozilla::dom::ScrollRestoration aMode,
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aRv) {
nsCOMPtr<nsPIDOMWindowInner> win(do_QueryReferent(mInnerWindow));
if (!win || !win->HasActiveDocument() || !win->GetDocShell()) {
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
return;
}

BrowsingContext* bc = win->GetBrowsingContext();
if (bc) {
nsresult rv = bc->CheckNavigationRateLimit(aCallerType);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return;
}
}

win->GetDocShell()->SetCurrentScrollRestorationIsManual(
aMode == mozilla::dom::ScrollRestoration::Manual);
}
Expand Down Expand Up @@ -152,7 +162,7 @@ void nsHistory::Go(int32_t aDelta, nsIPrincipal& aSubjectPrincipal,
? CallerType::System
: CallerType::NonSystem;

// AsyncGo throws if we hit the location change rate limit.
// AsyncGo throws if we hit the navigation rate limit.
session_history->AsyncGo(aDelta, /* aRequireUserInteraction = */ false,
userActivation, callerType, aRv);
}
Expand Down Expand Up @@ -237,7 +247,7 @@ void nsHistory::PushOrReplaceState(JSContext* aCx, JS::Handle<JS::Value> aData,

BrowsingContext* bc = win->GetBrowsingContext();
if (bc) {
nsresult rv = bc->CheckLocationChangeRateLimit(aCallerType);
nsresult rv = bc->CheckNavigationRateLimit(aCallerType);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return;
Expand Down
2 changes: 2 additions & 0 deletions dom/base/nsHistory.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ class nsHistory final : public nsISupports, public nsWrapperCache {

uint32_t GetLength(mozilla::ErrorResult& aRv) const;
mozilla::dom::ScrollRestoration GetScrollRestoration(
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aRv);
void SetScrollRestoration(mozilla::dom::ScrollRestoration aMode,
mozilla::dom::CallerType aCallerType,
mozilla::ErrorResult& aRv);
void GetState(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
mozilla::ErrorResult& aRv) const;
Expand Down
4 changes: 0 additions & 4 deletions dom/canvas/WebGLShaderValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,6 @@ std::unique_ptr<webgl::ShaderValidator> WebGLContext::CreateShaderValidator(
return static_cast<size_t>(bytes);
}

if (gl->IsMesa()) {
return 4 * 4 * 1024; // 4K words
}

if (kIsMacOS) {
return 128 * 1024; // 8k vec4s
}
Expand Down
2 changes: 1 addition & 1 deletion dom/chrome-webidl/BrowsingContext.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ interface BrowsingContext {
readonly attribute ChildSHistory? childSessionHistory;

// Resets the location change rate limit. Used for testing.
undefined resetLocationChangeRateLimit();
undefined resetNavigationRateLimit();

readonly attribute long childOffset;
};
Expand Down
1 change: 1 addition & 0 deletions dom/console/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Console)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mDumpFunction)
NS_IMPL_CYCLE_COLLECTION_UNLINK_WEAK_REFERENCE
tmp->Shutdown();
tmp->mArgumentStorage.clearAndFree();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END

NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Console)
Expand Down
Loading

0 comments on commit 55670e9

Please sign in to comment.