Backed out 2 changesets (bug 1830820) for reftest failure on inline-block-slice-5.html . CLOSED TREE

Backed out changeset 941c44881781 (bug 1830820)
Backed out changeset da493ba4c9a6 (bug 1830820)
This commit is contained in:
Narcis Beleuzu 2023-08-15 18:55:44 +03:00
parent 4795be1180
commit 0c70f2a736
15 changed files with 7 additions and 424 deletions

View File

@ -1314,7 +1314,6 @@ void nsDocShell::FirePageHideShowNonRecursive(bool aShow) {
mScriptGlobal ? mScriptGlobal->GetCurrentInnerWindow() : nullptr;
if (mBrowsingContext->IsTop()) {
doc->NotifyPossibleTitleChange(false);
doc->SetLoadingOrRestoredFromBFCacheTimeStampToNow();
if (inner) {
// Now that we have found the inner window of the page restored
// from the history, we have to make sure that

View File

@ -12225,7 +12225,7 @@ void Document::SetReadyStateInternal(ReadyState aReadyState,
}
if (aUpdateTimingInformation && READYSTATE_LOADING == aReadyState) {
SetLoadingOrRestoredFromBFCacheTimeStampToNow();
mLoadingTimeStamp = TimeStamp::Now();
}
NotifyLoading(mAncestorIsLoading, mReadyState, aReadyState);
mReadyState = aReadyState;
@ -13578,9 +13578,8 @@ nsresult Document::GetStateObject(JS::MutableHandle<JS::Value> aState) {
void Document::SetNavigationTiming(nsDOMNavigationTiming* aTiming) {
mTiming = aTiming;
if (!mLoadingOrRestoredFromBFCacheTimeStamp.IsNull() && mTiming) {
mTiming->SetDOMLoadingTimeStamp(GetDocumentURI(),
mLoadingOrRestoredFromBFCacheTimeStamp);
if (!mLoadingTimeStamp.IsNull() && mTiming) {
mTiming->SetDOMLoadingTimeStamp(GetDocumentURI(), mLoadingTimeStamp);
}
// If there's already the DocumentTimeline instance, tell it since the

View File

@ -1045,13 +1045,6 @@ class Document : public nsINode,
void SetLoadedAsData(bool aLoadedAsData, bool aConsiderForMemoryReporting);
TimeStamp GetLoadingOrRestoredFromBFCacheTimeStamp() const {
return mLoadingOrRestoredFromBFCacheTimeStamp;
}
void SetLoadingOrRestoredFromBFCacheTimeStampToNow() {
mLoadingOrRestoredFromBFCacheTimeStamp = TimeStamp::Now();
}
/**
* Normally we assert if a runnable labeled with one DocGroup touches data
* from another DocGroup. Calling IgnoreDocGroupMismatches() on a document
@ -5122,9 +5115,8 @@ class Document : public nsINode,
RefPtr<nsDOMNavigationTiming> mTiming;
// Recorded time of change to 'loading' state
// or time of the page gets restored from BFCache.
TimeStamp mLoadingOrRestoredFromBFCacheTimeStamp;
// Recorded time of change to 'loading' state.
TimeStamp mLoadingTimeStamp;
// Decided to use nsTObserverArray because it allows us to
// remove candidates while iterating them and this is what

View File

@ -105,6 +105,3 @@ support-files =
file_browser_refresh_iframe.sjs
[browser_page_load_event_telemetry.js]
[browser_xml_toggle.js]
[browser_user_input_handling_delay.js]
[browser_user_input_handling_delay_bfcache.js]
[browser_user_input_handling_delay_aboutblank.js]

View File

@ -1,82 +0,0 @@
/* -*- Mode: JavaScript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
async function test_user_input_handling_delay_helper(prefs) {
await SpecialPowers.pushPrefEnv({
set: prefs,
});
const tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
`data:text/html,<body></body>`
);
let canHandleInput = false;
let mouseDownPromise = BrowserTestUtils.waitForContentEvent(
tab.linkedBrowser,
"mousedown"
).then(function () {
Assert.ok(
canHandleInput,
"This promise should be resolved after the 5 seconds mark has passed"
);
});
for (let i = 0; i < 10; ++i) {
await BrowserTestUtils.synthesizeMouseAtPoint(
10,
10,
{ type: "mousedown" },
tab.linkedBrowser
);
}
// Wait for roughly 5 seconds to give chances for the
// above mousedown event to be handled.
await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
for (let i = 0; i < 300; ++i) {
await new Promise(r => {
content.requestAnimationFrame(r);
});
}
});
// If any user input events were handled in the above 5 seconds
// the mouseDownPromise would be resolved with canHandleInput = false,
// so that the test would fail.
canHandleInput = true;
// Ensure the events can be handled eventually
await BrowserTestUtils.synthesizeMouseAtPoint(
10,
10,
{ type: "mousedown" },
tab.linkedBrowser
);
await mouseDownPromise;
BrowserTestUtils.removeTab(tab);
}
add_task(async function test_MinRAF() {
const prefs = [
["dom.input_events.security.minNumTicks", 100],
["dom.input_events.security.minTimeElapsedInMS", 0],
["dom.input_events.security.isUserInputHandlingDelayTest", true],
];
await test_user_input_handling_delay_helper(prefs);
});
add_task(async function test_MinElapsedTime() {
const prefs = [
["dom.input_events.security.minNumTicks", 0],
["dom.input_events.security.minTimeElapsedInMS", 5000],
["dom.input_events.security.isUserInputHandlingDelayTest", true],
];
await test_user_input_handling_delay_helper(prefs);
});

View File

@ -1,58 +0,0 @@
/* -*- Mode: JavaScript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
async function test_user_input_handling_delay_aboutblank_helper(prefs) {
await SpecialPowers.pushPrefEnv({
set: prefs,
});
let newTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, "about:blank");
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
// Open about:blank
content.window.open();
});
const tab = await newTabOpened;
let mouseDownPromise = BrowserTestUtils.waitForContentEvent(
tab.linkedBrowser,
"mousedown"
).then(function () {
Assert.ok(true, "about:blank can handle user input events anytime");
});
// Now gBrowser.selectedBrowser is the newly opened about:blank
await BrowserTestUtils.synthesizeMouseAtPoint(
10,
10,
{ type: "mousedown" },
tab.linkedBrowser
);
await mouseDownPromise;
BrowserTestUtils.removeTab(tab);
}
add_task(async function test_MinRAF_aboutblank() {
const prefs = [
["dom.input_events.security.minNumTicks", 100],
["dom.input_events.security.minTimeElapsedInMS", 0],
["dom.input_events.security.isUserInputHandlingDelayTest", true],
];
await test_user_input_handling_delay_aboutblank_helper(prefs);
});
add_task(async function test_MinElapsedTime_aboutblank() {
const prefs = [
["dom.input_events.security.minNumTicks", 0],
["dom.input_events.security.minTimeElapsedInMS", 5000],
["dom.input_events.security.isUserInputHandlingDelayTest", true],
];
await test_user_input_handling_delay_aboutblank_helper(prefs);
});

View File

@ -1,107 +0,0 @@
/* -*- Mode: JavaScript; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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/. */
async function test_user_input_handling_delay_BFCache_helper(prefs) {
await SpecialPowers.pushPrefEnv({
set: prefs,
});
const tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
`data:text/html,<body></body>`,
true
);
let switchAwayPromise = BrowserTestUtils.browserLoaded(
browser,
false,
"about:blank"
);
// Navigate away to make the page enters BFCache
await SpecialPowers.spawn(tab.linkedBrowser, [], () => {
content.location = "about:blank";
});
await switchAwayPromise;
// Navigate back to restore the page from BFCache
let pageShownPromise = BrowserTestUtils.waitForContentEvent(
tab.linkedBrowser,
"pageshow",
true
);
await SpecialPowers.spawn(tab.linkedBrowser, [], () => {
content.history.back();
});
await pageShownPromise;
let canHandleInput = false;
let mouseDownPromise = BrowserTestUtils.waitForContentEvent(
tab.linkedBrowser,
"mousedown"
).then(function () {
Assert.ok(
canHandleInput,
"This promise should be resolved after the 5 seconds mark has passed"
);
});
// Ensure the events are discarded initially
for (let i = 0; i < 10; ++i) {
await BrowserTestUtils.synthesizeMouseAtPoint(
10,
10,
{ type: "mousedown" },
tab.linkedBrowser
);
}
// Wait for roughly 5 seconds to give chances for the
// above mousedown event to be handled.
await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
for (let i = 0; i < 300; ++i) {
await new Promise(r => {
content.requestAnimationFrame(r);
});
}
});
// If any user input events were handled in the above 5 seconds
// the mouseDownPromise would be resolved with canHandleInput = false,
// so that the test would fail.
canHandleInput = true;
// Ensure the events can be handled eventually
await BrowserTestUtils.synthesizeMouseAtPoint(
10,
10,
{ type: "mousedown" },
tab.linkedBrowser
);
await mouseDownPromise;
BrowserTestUtils.removeTab(tab);
}
add_task(async function test_MinRAF_BFCache() {
const prefs = [
["dom.input_events.security.minNumTicks", 100],
["dom.input_events.security.minTimeElapsedInMS", 0],
["dom.input_events.security.isUserInputHandlingDelayTest", true],
];
await test_user_input_handling_delay_BFCache_helper(prefs);
});
add_task(async function test_MinElapsedTime_BFCache() {
const prefs = [
["dom.input_events.security.minNumTicks", 0],
["dom.input_events.security.minTimeElapsedInMS", 5000],
["dom.input_events.security.isUserInputHandlingDelayTest", true],
];
await test_user_input_handling_delay_BFCache_helper(prefs);
});

View File

@ -1983,27 +1983,6 @@ bool PresShell::SimpleResizeReflow(nscoord aWidth, nscoord aHeight) {
return true;
}
bool PresShell::CanHandleUserInputEvents(WidgetGUIEvent* aGUIEvent) {
if (XRE_IsParentProcess()) {
return true;
}
if (aGUIEvent->mFlags.mIsSynthesizedForTests &&
!StaticPrefs::dom_input_events_security_isUserInputHandlingDelayTest()) {
return true;
}
if (!aGUIEvent->IsUserAction()) {
return true;
}
if (nsPresContext* rootPresContext = mPresContext->GetRootPresContext()) {
return rootPresContext->UserInputEventsAllowed();
}
return true;
}
void PresShell::AddResizeEventFlushObserverIfNeeded() {
if (!mIsDestroying && !mResizeEventPending &&
MOZ_LIKELY(!mDocument->GetBFCacheEntry())) {
@ -6901,17 +6880,6 @@ nsresult PresShell::HandleEvent(nsIFrame* aFrameForPresShell,
aGUIEvent->AsMouseEvent()->mReason == WidgetMouseEvent::eSynthesized) {
return NS_OK;
}
// Here we are granting some delays to ensure that user input events are
// created while the page content may not be visible to the user are not
// processed.
// The main purpose of this is to avoid user inputs are handled in the
// new document where as the user inputs were originally targeting some
// content in the old document.
if (!CanHandleUserInputEvents(aGUIEvent)) {
return NS_OK;
}
EventHandler eventHandler(*this);
return eventHandler.HandleEvent(aFrameForPresShell, aGUIEvent,
aDontRetargetEvents, aEventStatus);
@ -9334,10 +9302,6 @@ void PresShell::Freeze(bool aIncludeSubDocuments) {
if (presContext->RefreshDriver()->GetPresContext() == presContext) {
presContext->RefreshDriver()->Freeze();
}
if (nsPresContext* rootPresContext = presContext->GetRootPresContext()) {
rootPresContext->ResetUserInputEventsAllowed();
}
}
mFrozen = true;
@ -9396,16 +9360,6 @@ void PresShell::Thaw(bool aIncludeSubDocuments) {
UpdateImageLockingState();
UnsuppressPainting();
// In case the above UnsuppressPainting call didn't start the
// refresh driver, we manually start the refresh driver to
// ensure nsPresContext::MaybeIncreaseMeasuredTicksSinceLoading
// can be called for user input events handling.
if (presContext && presContext->IsRoot()) {
if (!presContext->RefreshDriver()->HasPendingTick()) {
presContext->RefreshDriver()->InitializeTimer();
}
}
}
//--------------------------------------------------------

View File

@ -385,8 +385,6 @@ class PresShell final : public nsStubDocumentObserver,
*/
bool SimpleResizeReflow(nscoord aWidth, nscoord aHeight);
bool CanHandleUserInputEvents(WidgetGUIEvent* aGUIEvent);
public:
/**
* Updates pending layout, assuming reasonable (up-to-date, or mid-update for

View File

@ -252,7 +252,6 @@ nsPresContext::nsPresContext(dom::Document* aDocument, nsPresContextType aType)
// mImageAnimationMode is initialised below, in constructor body
mImageAnimationModePref(imgIContainer::kNormalAnimMode),
mType(aType),
mMeasuredTicksSinceLoading(0),
mInflationDisabledForShrinkWrap(false),
mInteractionTimeEnabled(true),
mHasPendingInterrupt(false),
@ -285,7 +284,6 @@ nsPresContext::nsPresContext(dom::Document* aDocument, nsPresContextType aType)
mHadFirstContentfulPaint(false),
mHadNonTickContentfulPaint(false),
mHadContentfulPaintComposite(false),
mUserInputEventsAllowed(false),
#ifdef DEBUG
mInitialized(false),
#endif
@ -1237,69 +1235,6 @@ nsRootPresContext* nsPresContext::GetRootPresContext() const {
return pc->IsRoot() ? static_cast<nsRootPresContext*>(pc) : nullptr;
}
bool nsPresContext::UserInputEventsAllowed() {
MOZ_ASSERT(IsRoot());
if (mUserInputEventsAllowed) {
return true;
}
// Special document
if (Document()->IsInitialDocument()) {
return true;
}
if (mMeasuredTicksSinceLoading <
StaticPrefs::dom_input_events_security_minNumTicks()) {
return false;
}
if (!StaticPrefs::dom_input_events_security_minTimeElapsedInMS()) {
return true;
}
dom::Document* doc = Document();
MOZ_ASSERT_IF(StaticPrefs::dom_input_events_security_minNumTicks(),
doc->GetReadyStateEnum() >= Document::READYSTATE_LOADING);
TimeStamp loadingOrRestoredFromBFCacheTime =
doc->GetLoadingOrRestoredFromBFCacheTimeStamp();
MOZ_ASSERT(!loadingOrRestoredFromBFCacheTime.IsNull());
TimeDuration elapsed = TimeStamp::Now() - loadingOrRestoredFromBFCacheTime;
if (elapsed.ToMilliseconds() >=
StaticPrefs::dom_input_events_security_minTimeElapsedInMS()) {
mUserInputEventsAllowed = true;
return true;
}
return false;
}
void nsPresContext::MaybeIncreaseMeasuredTicksSinceLoading() {
MOZ_ASSERT(IsRoot());
if (mMeasuredTicksSinceLoading >=
StaticPrefs::dom_input_events_security_minNumTicks()) {
return;
}
// We consider READYSTATE_LOADING is the point when the page
// becomes interactive
if (Document()->GetReadyStateEnum() >= Document::READYSTATE_LOADING ||
Document()->IsInitialDocument()) {
++mMeasuredTicksSinceLoading;
}
if (mMeasuredTicksSinceLoading <
StaticPrefs::dom_input_events_security_minNumTicks()) {
// Here we are forcing refresh driver to run because we can't always
// guarantee refresh driver will run enough times to meet the minNumTicks
// requirement. i.e. about:blank.
if (!RefreshDriver()->HasPendingTick()) {
RefreshDriver()->InitializeTimer();
}
}
}
// Helper function for setting Anim Mode on image
static void SetImgAnimModeOnImgReq(imgIRequest* aImgReq, uint16_t aMode) {
if (aImgReq) {

View File

@ -257,7 +257,7 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
*/
nsRootPresContext* GetRootPresContext() const;
virtual bool IsRoot() const { return false; }
virtual bool IsRoot() { return false; }
mozilla::dom::Document* Document() const {
#ifdef DEBUG
@ -512,16 +512,6 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
nsDeviceContext* DeviceContext() const { return mDeviceContext; }
mozilla::EventStateManager* EventStateManager() { return mEventManager; }
bool UserInputEventsAllowed();
void MaybeIncreaseMeasuredTicksSinceLoading();
void ResetUserInputEventsAllowed() {
MOZ_ASSERT(IsRoot());
mMeasuredTicksSinceLoading = 0;
mUserInputEventsAllowed = false;
}
// Get the text zoom factor in use.
float TextZoom() const { return mTextZoom; }
@ -1283,8 +1273,6 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
nsPresContextType mType;
uint32_t mMeasuredTicksSinceLoading;
public:
// The following are public member variables so that we can use them
// with mozilla::AutoToggle or mozilla::AutoRestore.
@ -1354,7 +1342,6 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
// Has NotifyDidPaintForSubtree been called for a contentful paint?
unsigned mHadContentfulPaintComposite : 1;
unsigned mUserInputEventsAllowed : 1;
#ifdef DEBUG
unsigned mInitialized : 1;
#endif
@ -1387,7 +1374,7 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr {
class nsRootPresContext final : public nsPresContext {
public:
nsRootPresContext(mozilla::dom::Document* aDocument, nsPresContextType aType);
virtual bool IsRoot() const override { return true; }
virtual bool IsRoot() override { return true; }
/**
* Add a runnable that will get called before the next paint. They will get

View File

@ -2149,12 +2149,6 @@ void nsRefreshDriver::FlushAutoFocusDocuments() {
}
}
void nsRefreshDriver::MaybeIncreaseMeasuredTicksSinceLoading() {
if (mPresContext && mPresContext->IsRoot()) {
mPresContext->MaybeIncreaseMeasuredTicksSinceLoading();
}
}
void nsRefreshDriver::CancelFlushAutoFocus(Document* aDocument) {
mAutoFocusFlushDocuments.RemoveElement(aDocument);
}
@ -2599,7 +2593,6 @@ void nsRefreshDriver::Tick(VsyncId aId, TimeStamp aNowTime,
DispatchAnimationEvents();
RunFullscreenSteps();
RunFrameRequestCallbacks(aNowTime);
MaybeIncreaseMeasuredTicksSinceLoading();
if (mPresContext && mPresContext->GetPresShell()) {
AutoTArray<PresShell*, 16> observers;

View File

@ -486,7 +486,6 @@ class nsRefreshDriver final : public mozilla::layers::TransactionIdAllocator,
void RunFrameRequestCallbacks(mozilla::TimeStamp aNowTime);
void UpdateIntersectionObservations(mozilla::TimeStamp aNowTime);
void UpdateRelevancyOfContentVisibilityAutoFrames();
void MaybeIncreaseMeasuredTicksSinceLoading();
enum class IsExtraTick {
No,

View File

@ -2812,27 +2812,6 @@
value: false
mirror: always
# The minimum number of ticks after page navigation
# that need to occur before user input events are allowed to be handled.
- name: dom.input_events.security.minNumTicks
type: uint32_t
value: 3
mirror: always
# The minimum elapsed time (in milliseconds) after page navigation
# for user input events are allowed to be handled.
- name: dom.input_events.security.minTimeElapsedInMS
type: uint32_t
value: 100
mirror: always
# By default user input handling delay is disabled (mostly) for testing ,
# this is used for forcefully enable it for certain tests.
- name: dom.input_events.security.isUserInputHandlingDelayTest
type: bool
value: false
mirror: always
# The maximum time (milliseconds) we reserve for handling input events in each
# frame.
- name: dom.input_event_queue.duration.max

View File

@ -6,5 +6,3 @@
/* globals user_pref */
// ensure webrender is set (and we don't need MOZ_WEBRENDER env variable)
user_pref("gfx.webrender.all", true);
user_pref("dom.input_events.security.minNumTicks", 0);
user_pref("dom.input_events.security.minTimeElapsedInMS", 0);