Backed out 2 changesets (bug 1825745) for causing failures in form-requestsubmit.html CLOSED TREE

Backed out changeset eb77df0ccca6 (bug 1825745)
Backed out changeset 2ce4ceb5a39d (bug 1825745)
This commit is contained in:
Noemi Erli 2023-06-22 16:35:27 +03:00
Родитель 2902d8db20
Коммит ea5b4807dc
7 изменённых файлов: 18 добавлений и 85 удалений

Просмотреть файл

@ -971,21 +971,10 @@ bool nsDocShell::MaybeHandleSubframeHistory(
// executing an onLoad Handler,this load will not go // executing an onLoad Handler,this load will not go
// into session history. // into session history.
// XXX Why is this code in a method which deals with iframes! // XXX Why is this code in a method which deals with iframes!
if (aLoadState->IsFormSubmission()) { bool inOnLoadHandler = false;
#ifdef DEBUG GetIsExecutingOnLoadHandler(&inOnLoadHandler);
if (!mEODForCurrentDocument) { if (inOnLoadHandler) {
const MaybeDiscarded<BrowsingContext>& targetBC = aLoadState->SetLoadType(LOAD_NORMAL_REPLACE);
aLoadState->TargetBrowsingContext();
MOZ_ASSERT_IF(GetBrowsingContext() == targetBC.get(),
aLoadState->LoadType() == LOAD_NORMAL_REPLACE);
}
#endif
} else {
bool inOnLoadHandler = false;
GetIsExecutingOnLoadHandler(&inOnLoadHandler);
if (inOnLoadHandler) {
aLoadState->SetLoadType(LOAD_NORMAL_REPLACE);
}
} }
} }
return false; return false;
@ -8572,7 +8561,7 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) {
// Explicit principal because we do not want any guesses as to what the // Explicit principal because we do not want any guesses as to what the
// principal to inherit is: it should be aTriggeringPrincipal. // principal to inherit is: it should be aTriggeringPrincipal.
loadState->SetPrincipalIsExplicit(true); loadState->SetPrincipalIsExplicit(true);
loadState->SetLoadType(aLoadState->LoadType()); loadState->SetLoadType(LOAD_LINK);
loadState->SetForceAllowDataURI(aLoadState->HasInternalLoadFlags( loadState->SetForceAllowDataURI(aLoadState->HasInternalLoadFlags(
INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI)); INTERNAL_LOAD_FLAGS_FORCE_ALLOW_DATA_URI));
@ -8624,11 +8613,6 @@ nsresult nsDocShell::PerformRetargeting(nsDocShellLoadState* aLoadState) {
} }
aLoadState->SetTargetBrowsingContext(targetContext); aLoadState->SetTargetBrowsingContext(targetContext);
if (aLoadState->IsFormSubmission()) {
aLoadState->SetLoadType(
GetLoadTypeForFormSubmission(targetContext, aLoadState));
}
// //
// Transfer the load to the target BrowsingContext... Clear the window target // Transfer the load to the target BrowsingContext... Clear the window target
// name to the empty string to prevent recursive retargeting! // name to the empty string to prevent recursive retargeting!
@ -9242,20 +9226,6 @@ static bool NavigationShouldTakeFocus(nsDocShell* aDocShell,
return !Preferences::GetBool("browser.tabs.loadDivertedInBackground", false); return !Preferences::GetBool("browser.tabs.loadDivertedInBackground", false);
} }
uint32_t nsDocShell::GetLoadTypeForFormSubmission(
BrowsingContext* aTargetBC, nsDocShellLoadState* aLoadState) {
MOZ_ASSERT(aLoadState->IsFormSubmission());
// https://html.spec.whatwg.org/#form-submission-algorithm
// 22. Let historyHandling be "push".
// 23. If form document equals targetNavigable's active document, and
// form document has not yet completely loaded, then set
// historyHandling to "replace".
return GetBrowsingContext() == aTargetBC && !mEODForCurrentDocument
? LOAD_NORMAL_REPLACE
: LOAD_LINK;
}
nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState, nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
Maybe<uint32_t> aCacheKey) { Maybe<uint32_t> aCacheKey) {
MOZ_ASSERT(aLoadState, "need a load state!"); MOZ_ASSERT(aLoadState, "need a load state!");
@ -9295,8 +9265,6 @@ nsresult nsDocShell::InternalLoad(nsDocShellLoadState* aLoadState,
return PerformRetargeting(aLoadState); return PerformRetargeting(aLoadState);
} }
// This is the non-retargeting load path, we've already set the right loadtype
// for form submissions in nsDocShell::OnLinkClickSync.
if (aLoadState->TargetBrowsingContext().IsNull()) { if (aLoadState->TargetBrowsingContext().IsNull()) {
aLoadState->SetTargetBrowsingContext(GetBrowsingContext()); aLoadState->SetTargetBrowsingContext(GetBrowsingContext());
} }
@ -13116,24 +13084,11 @@ nsresult nsDocShell::OnLinkClickSync(nsIContent* aContent,
CopyUTF8toUTF16(type, typeHint); CopyUTF8toUTF16(type, typeHint);
} }
uint32_t loadType = LOAD_LINK; // Link click (or form submission) can be triggered inside an onload
if (aLoadState->IsFormSubmission()) { // handler, and we don't want to add history entry in this case.
if (aLoadState->Target().IsEmpty()) { bool inOnLoadHandler = false;
// We set the right load type here for form submissions with an empty GetIsExecutingOnLoadHandler(&inOnLoadHandler);
// target. Form submission with a non-empty target are handled in uint32_t loadType = inOnLoadHandler ? LOAD_NORMAL_REPLACE : LOAD_LINK;
// nsDocShell::PerformRetargeting after we've selected the correct target
// BC.
loadType = GetLoadTypeForFormSubmission(GetBrowsingContext(), aLoadState);
}
} else {
// Link click can be triggered inside an onload handler, and we don't want
// to add history entry in this case.
bool inOnLoadHandler = false;
GetIsExecutingOnLoadHandler(&inOnLoadHandler);
if (inOnLoadHandler) {
loadType = LOAD_NORMAL_REPLACE;
}
}
nsCOMPtr<nsIReferrerInfo> referrerInfo = nsCOMPtr<nsIReferrerInfo> referrerInfo =
elementCanHaveNoopener ? new ReferrerInfo(*aContent->AsElement()) elementCanHaveNoopener ? new ReferrerInfo(*aContent->AsElement())

Просмотреть файл

@ -710,13 +710,6 @@ class nsDocShell final : public nsDocLoader,
nsresult ScrollToAnchor(bool aCurHasRef, bool aNewHasRef, nsresult ScrollToAnchor(bool aCurHasRef, bool aNewHasRef,
nsACString& aNewHash, uint32_t aLoadType); nsACString& aNewHash, uint32_t aLoadType);
// This returns the load type for a form submission (see
// https://html.spec.whatwg.org/#form-submission-algorithm). The load type
// should be set as soon as the target BC has been determined.
uint32_t GetLoadTypeForFormSubmission(
mozilla::dom::BrowsingContext* aTargetBC,
nsDocShellLoadState* aLoadState);
private: private:
// Returns true if would have called FireOnLocationChange, // Returns true if would have called FireOnLocationChange,
// but did not because aFireOnLocationChange was false on entry. // but did not because aFireOnLocationChange was false on entry.

Просмотреть файл

@ -7,13 +7,7 @@
<form method="POST" action="file_bug1773192_3.sjs"></form> <form method="POST" action="file_bug1773192_3.sjs"></form>
<script> <script>
history.replaceState({}, "", document.referrer); history.replaceState({}, "", document.referrer);
setTimeout(() => { document.forms[0].submit();
// The test relies on this page not going into the BFCache, so that
// when we come back to it we load the URL from the replaceState
// instead.
window.blockBFCache = new RTCPeerConnection();
document.forms[0].submit();
}, 0);
</script> </script>
</body> </body>
</html> </html>

Просмотреть файл

@ -2266,20 +2266,7 @@ void nsGenericHTMLElement::Click(CallerType aCallerType) {
RefPtr<nsPresContext> context; RefPtr<nsPresContext> context;
if (doc) { if (doc) {
PresShell* presShell = doc->GetPresShell(); context = doc->GetPresContext();
if (!presShell) {
// We need the nsPresContext for dispatching the click event. In some
// rare cases we need to flush notifications to force creation of the
// nsPresContext here (for example when a script calls button.click()
// from script early during page load). We only flush the notifications
// if the PresShell hasn't been created yet, to limit the performance
// impact.
doc->FlushPendingNotifications(FlushType::EnsurePresShellInitAndFrames);
presShell = doc->GetPresShell();
}
if (presShell) {
context = presShell->GetPresContext();
}
} }
SetHandlingClick(); SetHandlingClick();

Просмотреть файл

@ -1,3 +1,5 @@
[form-requestsubmit.html] [form-requestsubmit.html]
expected: expected:
if (os == "android") and fission: [OK, TIMEOUT] if (os == "android") and fission: [OK, TIMEOUT]
[Replace before load, triggered by formElement.requestSubmit()]
expected: FAIL

Просмотреть файл

@ -1,3 +1,5 @@
[form-submit-button-click.html] [form-submit-button-click.html]
expected: expected:
if (os == "android") and fission: [OK, TIMEOUT] if (os == "android") and fission: [OK, TIMEOUT]
[Replace before load, triggered by submitButton.click()]
expected: FAIL

Просмотреть файл

@ -1,3 +1,3 @@
[form-submit.html] [form-submit.html]
expected: [Replace before load, triggered by same-document formElement.submit()]
if (os == "android") and fission: [OK, TIMEOUT] expected: FAIL