Backed out 5 changesets (bug 1742865, bug 1744397) for causing wpt failures on attr-meta-http-equiv-refresh/parsing.html CLOSED TREE

Backed out changeset 7b01edc5a0e0 (bug 1744397)
Backed out changeset 41abd4b7d2c0 (bug 1744397)
Backed out changeset 634641e3a05a (bug 1744397)
Backed out changeset 6e7755177481 (bug 1744397)
Backed out changeset e9fc94b33da9 (bug 1742865)
This commit is contained in:
Norisz Fay 2021-12-14 13:25:58 +02:00
Родитель 204b961c4e
Коммит 333caceb64
24 изменённых файлов: 159 добавлений и 333 удалений

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

@ -164,7 +164,7 @@ class RefreshBlockerChild extends JSWindowActorChild {
let docShell = data.browsingContext.docShell;
let refreshURI = docShell.QueryInterface(Ci.nsIRefreshURI);
let URI = Services.io.newURI(data.URI);
refreshURI.forceRefreshURI(URI, null, data.delay);
refreshURI.forceRefreshURI(URI, null, data.delay, true);
break;
case "PreferenceChanged":

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

@ -25,7 +25,7 @@ async function attemptFakeRefresh(browser, expectRefresh) {
) {
let URI = docShell.QueryInterface(Ci.nsIWebNavigation).currentURI;
let refresher = docShell.QueryInterface(Ci.nsIRefreshURI);
refresher.refreshURI(URI, null, 0);
refresher.refreshURI(URI, null, 0, false, true);
Assert.equal(
refresher.refreshPending,

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

@ -406,6 +406,7 @@ const ErrorCodes = {
NS_ERROR_SOCIALTRACKING_URI: 0x805d002b,
NS_ERROR_SAVE_LINK_AS_TIMEOUT: 0x805d0020,
NS_ERROR_PARSED_DATA_CACHED: 0x805d0021,
NS_REFRESHURI_HEADER_FOUND: 0x5d0002,
NS_ERROR_CONTENT_BLOCKED: 0x805e0006,
NS_ERROR_CONTENT_BLOCKED_SHOW_ALT: 0x805e0007,
NS_PROPTABLE_PROP_NOT_THERE: 0x805e000a,

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

@ -3482,24 +3482,10 @@ bool BrowsingContext::IsPopupAllowed() {
return false;
}
/* static */
bool BrowsingContext::ShouldAddEntryForRefresh(
nsIURI* aCurrentURI, const SessionHistoryInfo& aInfo) {
if (aInfo.GetPostData()) {
return true;
}
bool equalsURI = false;
if (aCurrentURI) {
aCurrentURI->Equals(aInfo.GetURI(), &equalsURI);
}
return !equalsURI;
}
void BrowsingContext::SessionHistoryCommit(
const LoadingSessionHistoryInfo& aInfo, uint32_t aLoadType,
nsIURI* aCurrentURI, bool aHadActiveEntry, bool aPersist,
bool aCloneEntryChildren, bool aChannelExpired) {
bool aHadActiveEntry, bool aPersist, bool aCloneEntryChildren,
bool aChannelExpired) {
nsID changeID = {};
if (XRE_IsContentProcess()) {
RefPtr<ChildSHistory> rootSH = Top()->GetChildSessionHistory();
@ -3509,17 +3495,13 @@ void BrowsingContext::SessionHistoryCommit(
// CanonicalBrowsingContext::SessionHistoryCommit. We'll be
// incrementing the session history length if we're not replacing,
// this is a top-level load or it's not the initial load in an iframe,
// ShouldUpdateSessionHistory(loadType) returns true and it's not a
// refresh for which ShouldAddEntryForRefresh returns false.
// and ShouldUpdateSessionHistory(loadType) returns true.
// It is possible that this leads to wrong length temporarily, but
// so would not having the check for replace.
if (!LOAD_TYPE_HAS_FLAGS(
aLoadType, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY) &&
(IsTop() || aHadActiveEntry) &&
ShouldUpdateSessionHistory(aLoadType) &&
(!LOAD_TYPE_HAS_FLAGS(aLoadType,
nsIWebNavigation::LOAD_FLAGS_IS_REFRESH) ||
ShouldAddEntryForRefresh(aCurrentURI, aInfo.mInfo))) {
ShouldUpdateSessionHistory(aLoadType)) {
changeID = rootSH->AddPendingHistoryChange();
}
} else {

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

@ -791,13 +791,10 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
// context or any of its ancestors.
bool IsPopupAllowed();
// aCurrentURI is only required to be non-null if the load type contains the
// nsIWebNavigation::LOAD_FLAGS_IS_REFRESH flag and aInfo is for a refresh to
// the current URI.
void SessionHistoryCommit(const LoadingSessionHistoryInfo& aInfo,
uint32_t aLoadType, nsIURI* aCurrentURI,
bool aHadActiveEntry, bool aPersist,
bool aCloneEntryChildren, bool aChannelExpired);
uint32_t aLoadType, bool aHadActiveEntry,
bool aPersist, bool aCloneEntryChildren,
bool aChannelExpired);
// Set a new active entry on this browsing context. This is used for
// implementing history.pushState/replaceState and same document navigations.
@ -901,9 +898,6 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
return mChildSessionHistory.forget();
}
static bool ShouldAddEntryForRefresh(nsIURI* aCurrentURI,
const SessionHistoryInfo& aInfo);
private:
void Attach(bool aFromIPC, ContentParent* aOriginProcess);

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

@ -797,6 +797,7 @@ void CanonicalBrowsingContext::SessionHistoryCommit(
RemoveDynEntriesFromActiveSessionHistoryEntry();
}
}
mActiveEntry = newActiveEntry;
if (LOAD_TYPE_HAS_FLAGS(aLoadType,
nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY)) {
@ -807,16 +808,8 @@ void CanonicalBrowsingContext::SessionHistoryCommit(
// should append instead.
addEntry = index < 0;
if (!addEntry) {
shistory->ReplaceEntry(index, newActiveEntry);
shistory->ReplaceEntry(index, mActiveEntry);
}
mActiveEntry = newActiveEntry;
} else if (LOAD_TYPE_HAS_FLAGS(
aLoadType, nsIWebNavigation::LOAD_FLAGS_IS_REFRESH) &&
!ShouldAddEntryForRefresh(newActiveEntry)) {
addEntry = false;
mActiveEntry->ReplaceWith(*newActiveEntry);
} else {
mActiveEntry = newActiveEntry;
}
if (loadFromSessionHistory) {
@ -848,10 +841,7 @@ void CanonicalBrowsingContext::SessionHistoryCommit(
} else if (addEntry) {
if (mActiveEntry) {
if (LOAD_TYPE_HAS_FLAGS(
aLoadType, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY) ||
(LOAD_TYPE_HAS_FLAGS(aLoadType,
nsIWebNavigation::LOAD_FLAGS_IS_REFRESH) &&
!ShouldAddEntryForRefresh(newActiveEntry))) {
aLoadType, nsIWebNavigation::LOAD_FLAGS_REPLACE_HISTORY)) {
// FIXME We need to make sure that when we create the info we
// make a copy of the shared state.
mActiveEntry->ReplaceWith(*newActiveEntry);

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

@ -459,12 +459,6 @@ class CanonicalBrowsingContext final : public BrowsingContext {
void RemovePendingDiscard();
bool ShouldAddEntryForRefresh(const SessionHistoryEntry* aEntry) {
nsCOMPtr<nsIURI> currentURI = GetCurrentURI();
return BrowsingContext::ShouldAddEntryForRefresh(currentURI,
aEntry->Info());
}
// XXX(farre): Store a ContentParent pointer here rather than mProcessId?
// Indicates which process owns the docshell.
uint64_t mProcessId;

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

@ -20,7 +20,6 @@
#include "mozilla/AutoRestore.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/Casting.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/Components.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Encoding.h"
@ -5011,8 +5010,8 @@ void nsDocShell::SetScrollbarPreference(mozilla::ScrollbarPreference aPref) {
//*****************************************************************************
NS_IMETHODIMP
nsDocShell::RefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal,
uint32_t aDelay) {
nsDocShell::RefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal, int32_t aDelay,
bool aRepeat, bool aMetaRefresh) {
MOZ_ASSERT(!mIsBeingDestroyed);
NS_ENSURE_ARG(aURI);
@ -5041,7 +5040,7 @@ nsDocShell::RefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal,
}
nsCOMPtr<nsITimerCallback> refreshTimer =
new nsRefreshTimer(this, aURI, aPrincipal, aDelay);
new nsRefreshTimer(this, aURI, aPrincipal, aDelay, aRepeat, aMetaRefresh);
BusyFlags busyFlags = GetBusyFlags();
@ -5072,7 +5071,7 @@ nsDocShell::RefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal,
nsresult nsDocShell::ForceRefreshURIFromTimer(nsIURI* aURI,
nsIPrincipal* aPrincipal,
uint32_t aDelay,
int32_t aDelay, bool aMetaRefresh,
nsITimer* aTimer) {
MOZ_ASSERT(aTimer, "Must have a timer here");
@ -5090,12 +5089,12 @@ nsresult nsDocShell::ForceRefreshURIFromTimer(nsIURI* aURI,
}
}
return ForceRefreshURI(aURI, aPrincipal, aDelay);
return ForceRefreshURI(aURI, aPrincipal, aDelay, aMetaRefresh);
}
NS_IMETHODIMP
nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal,
uint32_t aDelay) {
int32_t aDelay, bool aMetaRefresh) {
NS_ENSURE_ARG(aURI);
RefPtr<nsDocShellLoadState> loadState = new nsDocShellLoadState(aURI);
@ -5103,7 +5102,7 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal,
loadState->SetResultPrincipalURI(aURI);
loadState->SetResultPrincipalURIIsSome(true);
loadState->SetKeepResultPrincipalURIIfSet(true);
loadState->SetIsMetaRefresh(true);
loadState->SetIsMetaRefresh(aMetaRefresh);
// Set the triggering pricipal to aPrincipal if available, or current
// document's principal otherwise.
@ -5132,7 +5131,8 @@ nsDocShell::ForceRefreshURI(nsIURI* aURI, nsIPrincipal* aPrincipal,
nsresult rv = aURI->Equals(mCurrentURI, &equalUri);
nsCOMPtr<nsIReferrerInfo> referrerInfo;
if (NS_SUCCEEDED(rv) && !equalUri && aDelay <= REFRESH_REDIRECT_TIMER) {
if (NS_SUCCEEDED(rv) && (!equalUri) && aMetaRefresh &&
aDelay <= REFRESH_REDIRECT_TIMER) {
/* It is a META refresh based redirection within the threshold time
* we have in mind (15000 ms as defined by REFRESH_REDIRECT_TIMER).
* Pass a REPLACE flag to LoadURI().
@ -5221,7 +5221,7 @@ nsresult nsDocShell::SetupRefreshURIFromHeader(nsIURI* aBaseURI,
MOZ_ASSERT(aPrincipal);
nsAutoCString uriAttrib;
CheckedInt<uint32_t> seconds(0);
int32_t seconds = 0;
bool specifiesSeconds = false;
nsACString::const_iterator iter, tokenStart, doneIterating;
@ -5236,33 +5236,24 @@ nsresult nsDocShell::SetupRefreshURIFromHeader(nsIURI* aBaseURI,
tokenStart = iter;
if (iter != doneIterating) {
if (*iter == '-') {
return NS_ERROR_FAILURE;
}
// skip leading +
if (*iter == '+') {
++iter;
}
// skip leading + and -
if (iter != doneIterating && (*iter == '-' || *iter == '+')) {
++iter;
}
// parse number
while (iter != doneIterating && (*iter >= '0' && *iter <= '9')) {
seconds = seconds * 10 + (*iter - '0');
if (!seconds.isValid()) {
return NS_ERROR_FAILURE;
}
specifiesSeconds = true;
++iter;
}
CheckedInt<uint32_t> milliSeconds(seconds * 1000);
if (!milliSeconds.isValid()) {
return NS_ERROR_FAILURE;
}
if (iter != doneIterating) {
// if we started with a '-', number is negative
if (*tokenStart == '-') {
seconds = -seconds;
}
// skip to next ';' or ','
nsACString::const_iterator iterAfterDigit = iter;
while (iter != doneIterating && !(*iter == ';' || *iter == ',')) {
@ -5408,7 +5399,45 @@ nsresult nsDocShell::SetupRefreshURIFromHeader(nsIURI* aBaseURI,
}
}
rv = RefreshURI(uri, aPrincipal, milliSeconds.value());
if (NS_SUCCEEDED(rv)) {
// Since we can't travel back in time yet, just pretend
// negative numbers do nothing at all.
if (seconds < 0) {
return NS_ERROR_FAILURE;
}
rv = RefreshURI(uri, aPrincipal, seconds * 1000, false, true);
}
}
}
return rv;
}
NS_IMETHODIMP
nsDocShell::SetupRefreshURI(nsIChannel* aChannel) {
nsresult rv;
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel, &rv));
if (NS_SUCCEEDED(rv)) {
nsAutoCString refreshHeader;
rv = httpChannel->GetResponseHeader("refresh"_ns, refreshHeader);
if (!refreshHeader.IsEmpty()) {
nsCOMPtr<nsIScriptSecurityManager> secMan =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> principal;
rv = secMan->GetChannelResultPrincipal(aChannel,
getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
SetupReferrerInfoFromChannel(aChannel);
// We have no idea what window id to use for error reporting
// here, so just pass 0.
rv = SetupRefreshURIFromHeader(mCurrentURI, principal, 0, refreshHeader);
if (NS_SUCCEEDED(rv)) {
return NS_REFRESHURI_HEADER_FOUND;
}
}
}
return rv;
@ -8911,11 +8940,8 @@ nsresult nsDocShell::HandleSameDocumentNavigation(
this, mLoadingEntry->mInfo.GetURI()->GetSpecOrDefault().get()));
bool hadActiveEntry = !!mActiveEntry;
mActiveEntry = MakeUnique<SessionHistoryInfo>(mLoadingEntry->mInfo);
// We're passing in mCurrentURI, which could be null. SessionHistoryCommit
// does require a non-null uri if this is for a refresh load of the same
// URI, but in that case mCurrentURI won't be null here.
mBrowsingContext->SessionHistoryCommit(
*mLoadingEntry, mLoadType, mCurrentURI, hadActiveEntry, true, true,
*mLoadingEntry, mLoadType, hadActiveEntry, true, true,
/* No expiration update on the same document loads*/
false);
// FIXME Need to set postdata.
@ -10740,6 +10766,14 @@ nsresult nsDocShell::ScrollToAnchor(bool aCurHasRef, bool aNewHasRef,
return NS_OK;
}
void nsDocShell::SetupReferrerInfoFromChannel(nsIChannel* aChannel) {
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel));
if (httpChannel) {
nsCOMPtr<nsIReferrerInfo> referrerInfo = httpChannel->GetReferrerInfo();
SetReferrerInfo(referrerInfo);
}
}
bool nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aPrincipalToInherit,
@ -10964,13 +10998,14 @@ bool nsDocShell::OnNewURI(nsIURI* aURI, nsIChannel* aChannel,
SetCurrentURI(aURI, aChannel, aFireOnLocationChange,
/* aIsInitialAboutBlank */ false, locationFlags);
// Make sure to store the referrer from the channel, if any
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel));
if (httpChannel) {
mReferrerInfo = httpChannel->GetReferrerInfo();
}
SetupReferrerInfoFromChannel(aChannel);
return onLocationChangeNeeded;
}
void nsDocShell::SetReferrerInfo(nsIReferrerInfo* aReferrerInfo) {
mReferrerInfo = aReferrerInfo; // This assigment addrefs
}
//*****************************************************************************
// nsDocShell: Session History
//*****************************************************************************
@ -13437,13 +13472,8 @@ void nsDocShell::MoveLoadingToActiveEntry(bool aPersist, bool aExpired) {
MOZ_ASSERT(loadingEntry);
uint32_t loadType =
mLoadType == LOAD_ERROR_PAGE ? mFailedLoadType : mLoadType;
// We're passing in mCurrentURI, which could be null. SessionHistoryCommit
// does require a non-null uri if this is for a refresh load of the same
// URI, but in that case mCurrentURI won't be null here.
mBrowsingContext->SessionHistoryCommit(*loadingEntry, loadType, mCurrentURI,
hadActiveEntry, aPersist, false,
aExpired);
mBrowsingContext->SessionHistoryCommit(
*loadingEntry, loadType, hadActiveEntry, aPersist, false, aExpired);
}
}

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

@ -288,28 +288,13 @@ class nsDocShell final : public nsDocLoader,
// subframes. It then simulates the completion of the toplevel load.
nsresult RestoreFromHistory();
/**
* Parses the passed in header string and sets up a refreshURI if a "refresh"
* header is found. If docshell is busy loading a page currently, the request
* will be queued and executed when the current page finishes loading.
*
* @param aBaseURI base URI to resolve refresh uri with.
* @param aPrincipal The triggeringPrincipal for the refresh load
* May be null, in which case the principal of current document will be
* applied.
* @param aInnerWindowID The window id to use for error reporting.
* @param aHeader The meta refresh header string.
*/
nsresult SetupRefreshURIFromHeader(nsIURI* aBaseURI, nsIPrincipal* aPrincipal,
uint64_t aInnerWindowID,
const nsACString& aHeader);
// Perform a URI load from a refresh timer. This is just like the
// ForceRefreshURI method on nsIRefreshURI, but makes sure to take
// the timer involved out of mRefreshURIList if it's there.
// aTimer must not be null.
nsresult ForceRefreshURIFromTimer(nsIURI* aURI, nsIPrincipal* aPrincipal,
uint32_t aDelay, nsITimer* aTimer);
int32_t aDelay, bool aMetaRefresh,
nsITimer* aTimer);
// We need dummy OnLocationChange in some cases to update the UI without
// updating security info.
@ -967,6 +952,8 @@ class nsDocShell final : public nsDocLoader,
nsresult Dispatch(mozilla::TaskCategory aCategory,
already_AddRefed<nsIRunnable>&& aRunnable);
void SetupReferrerInfoFromChannel(nsIChannel* aChannel);
void SetReferrerInfo(nsIReferrerInfo* aReferrerInfo);
void ReattachEditorToWindow(nsISHEntry* aSHEntry);
void ClearFrameHistory(nsISHEntry* aEntry);
// Determine if this type of load should update history.

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

@ -13,22 +13,25 @@ interface nsIURI;
[scriptable, uuid(a5e61a3c-51bd-45be-ac0c-e87b71860656)]
interface nsIRefreshURI : nsISupports {
/**
* Load a uri after waiting for aMillis milliseconds (as a result of a
* meta refresh). If the docshell is busy loading a page currently, the
* refresh request will be queued and executed when the current load
* finishes.
* Load a uri after waiting for aMillis milliseconds. If the docshell
* is busy loading a page currently, the refresh request will be
* queued and executed when the current load finishes.
*
* @param aUri The uri to refresh.
* @param aPrincipal The triggeringPrincipal for the refresh load
* May be null, in which case the principal of current document will be
* applied.
* @param aMillis The number of milliseconds to wait.
* @param aRepeat Flag to indicate if the uri is to be
* repeatedly refreshed every aMillis milliseconds.
* @param aMetaRefresh Flag to indicate if this is a Meta refresh.
*/
void refreshURI(in nsIURI aURI, in nsIPrincipal aPrincipal,
in unsigned long aMillis);
in long aMillis, in boolean aRepeat,
in boolean aMetaRefresh);
/**
* Loads a URI immediately as if it were a meta refresh.
* Loads a URI immediately as if it were a refresh.
*
* @param aURI The URI to refresh.
* @param aPrincipal The triggeringPrincipal for the refresh load
@ -36,9 +39,42 @@ interface nsIRefreshURI : nsISupports {
* applied.
* @param aMillis The number of milliseconds by which this refresh would
* be delayed if it were not being forced.
* @param aMetaRefresh Flag to indicate if this is a meta refresh.
*/
void forceRefreshURI(in nsIURI aURI, in nsIPrincipal aPrincipal,
in unsigned long aMillis);
in long aMillis, in boolean aMetaRefresh);
/**
* Checks the passed in channel to see if there is a refresh header,
* if there is, will setup a timer to refresh the uri found
* in the header. If docshell is busy loading a page currently, the
* request will be queued and executed when the current page
* finishes loading.
*
* Returns the NS_REFRESHURI_HEADER_FOUND success code if a refresh
* header was found and successfully setup.
*
* @param aChannel The channel to be parsed.
*/
void setupRefreshURI(in nsIChannel aChannel);
/**
* Parses the passed in header string and sets up a refreshURI if
* a "refresh" header is found. If docshell is busy loading a page
* currently, the request will be queued and executed when
* the current page finishes loading.
*
* @param aBaseURI base URI to resolve refresh uri with.
* @param aPrincipal The triggeringPrincipal for the refresh load
* May be null, in which case the principal of current document will be
* applied.
* @param aInnerWindowID The window id to use for error reporting.
* @param aHeader The meta refresh header string.
*/
void setupRefreshURIFromHeader(in nsIURI aBaseURI,
in nsIPrincipal principal,
in unsigned long long aInnerWindowID,
in ACString aHeader);
/**
* Cancels all timer loads.

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

@ -21,11 +21,14 @@ NS_INTERFACE_MAP_BEGIN(nsRefreshTimer)
NS_INTERFACE_MAP_END
nsRefreshTimer::nsRefreshTimer(nsDocShell* aDocShell, nsIURI* aURI,
nsIPrincipal* aPrincipal, int32_t aDelay)
nsIPrincipal* aPrincipal, int32_t aDelay,
bool aRepeat, bool aMetaRefresh)
: mDocShell(aDocShell),
mURI(aURI),
mPrincipal(aPrincipal),
mDelay(aDelay) {}
mDelay(aDelay),
mRepeat(aRepeat),
mMetaRefresh(aMetaRefresh) {}
nsRefreshTimer::~nsRefreshTimer() {}
@ -37,7 +40,8 @@ nsRefreshTimer::Notify(nsITimer* aTimer) {
// Get the delay count to determine load type
uint32_t delay = 0;
aTimer->GetDelay(&delay);
mDocShell->ForceRefreshURIFromTimer(mURI, mPrincipal, delay, aTimer);
mDocShell->ForceRefreshURIFromTimer(mURI, mPrincipal, delay, mMetaRefresh,
aTimer);
}
return NS_OK;
}

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

@ -19,7 +19,7 @@ class nsIPrincipal;
class nsRefreshTimer : public nsITimerCallback, public nsINamed {
public:
nsRefreshTimer(nsDocShell* aDocShell, nsIURI* aURI, nsIPrincipal* aPrincipal,
int32_t aDelay);
int32_t aDelay, bool aRepeat, bool aMetaRefresh);
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSITIMERCALLBACK
@ -31,6 +31,8 @@ class nsRefreshTimer : public nsITimerCallback, public nsINamed {
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIPrincipal> mPrincipal;
int32_t mDelay;
bool mRepeat;
bool mMetaRefresh;
private:
virtual ~nsRefreshTimer();

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

@ -1,65 +0,0 @@
Cu.importGlobalProperties(["URLSearchParams"]);
function handleRequest(request, response) {
if (request.queryString == "reset") {
setState("index", "0");
response.setStatusLine(request.httpVersion, 200, "Ok");
response.write("Reset");
return;
}
let refresh = "";
let index = Number(getState("index"));
// index == 0 First load, returns first meta refresh
// index == 1 Second load, caused by first meta refresh, returns second meta refresh
// index == 2 Third load, caused by second meta refresh, doesn't return a meta refresh
if (index < 2) {
let query = new URLSearchParams(request.queryString);
refresh = query.get("seconds");
if (query.get("crossorigin") == "true") {
const hosts = ["example.org", "example.com"];
let url = `${request.scheme}://${hosts[index]}${request.path}?${request.queryString}`;
refresh += `; url=${url}`;
}
refresh = `<meta http-equiv="Refresh" content="${refresh}">`;
}
setState("index", String(index + 1));
response.write(
`<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="Cache-Control" content="no-cache">
${refresh}
<script>
window.addEventListener("pageshow", () => {
window.top.opener.postMessage({
commandType: "pageShow",
commandData: {
historyLength: history.length,
inputValue: document.getElementById("input").value,
},
}, "*");
});
window.addEventListener("message", ({ data }) => {
if (data == "changeInputValue") {
document.getElementById("input").value = "1234";
window.top.opener.postMessage({
commandType: "onChangedInputValue",
}, "*");
} else if (data == "loadNext") {
location.href += "&loadnext=1";
} else if (data == "back") {
history.back();
}
});
</script>
</head>
<body>
<input type="text" id="input" value="initial"></input>
</body>
</html>`
);
}

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

@ -1,25 +0,0 @@
Cu.importGlobalProperties(["URLSearchParams"]);
function handleRequest(request, response) {
response.write(
`<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<script>
window.addEventListener("message", ({ data }) => {
if (data == "loadNext") {
location.href += "&loadnext=1";
return;
}
// Forward other messages to the frame.
document.getElementById("frame").contentWindow.postMessage(data, "*");
});
</script>
</head>
<body>
<iframe src="file_bug1742865.sjs?${request.queryString}" id="frame"></iframe>
</body>
</html>`
);
}

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

@ -125,10 +125,6 @@ support-files =
support-files =
file_bug1741132.html
skip-if = toolkit == "android" && !sessionHistoryInParent
[test_bug1742865.html]
support-files =
file_bug1742865.sjs
file_bug1742865_outer.sjs
[test_bug1743353.html]
support-files =
file_bug1743353.html

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

@ -1,103 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Auto refreshing pages shouldn't add an entry to session history</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<script>
const REFRESH_REDIRECT_TIMER = 15;
// 2 tests (same and cross origin) consisting of 2 refreshes of maximum 1 seconds
// 2 tests (same and cross origin) consisting of 2 refreshes of REFRESH_REDIRECT_TIMER seconds
// => We need (2 * 1) + (2 * 15) seconds
SimpleTest.requestLongerTimeout(3);
SimpleTest.waitForExplicitFinish();
const SJS = new URL("file_bug1742865.sjs", location.href);
const SJS_OUTER = new URL("file_bug1742865_outer.sjs", location.href);
function openWindowAndCheckRefresh(url, shouldAddToHistory) {
let resetURL = new URL(SJS);
resetURL.search = "?reset";
return fetch(resetURL).then(() => {
return new Promise((resolve) => {
let count = 0;
window.addEventListener("message", function listener({ data: { commandType, commandData = {} } }) {
if (commandType == "onChangedInputValue") {
win.postMessage("loadNext", "*");
return;
}
is(commandType, "pageShow", "Unknown command type");
let { historyLength, inputValue } = commandData;
switch (++count) {
// file_bug1742865.sjs causes 3 loads:
// * first load, returns first meta refresh
// * second load, caused by first meta refresh, returns second meta refresh
// * third load, caused by second meta refresh, doesn't return a meta refresh
case 3:
if (shouldAddToHistory) {
is(historyLength, count, "Auto-refresh should add entries to session history");
} else {
is(historyLength, 1, "Auto-refresh shouldn't add entries to session history");
}
win.postMessage("changeInputValue", "*");
break;
case 4:
win.postMessage("back", "*");
break;
case 5:
is(inputValue, "1234", "Entries for auto-refresh should be attached to session history");
removeEventListener("message", listener);
win.close();
resolve();
break;
}
});
let win = window.open(url);
});
});
}
function doTest(seconds, crossOrigin, shouldAddToHistory) {
let url = new URL(SJS);
url.searchParams.append("seconds", seconds);
url.searchParams.append("crossorigin", crossOrigin);
let urlOuter = new URL(SJS_OUTER);
urlOuter.searchParams.append("seconds", seconds);
urlOuter.searchParams.append("crossorigin", crossOrigin);
return openWindowAndCheckRefresh(url, shouldAddToHistory).then(() =>
openWindowAndCheckRefresh(urlOuter, shouldAddToHistory)
);
}
function runTest() {
const FAST = Math.min(1, REFRESH_REDIRECT_TIMER);
const SLOW = REFRESH_REDIRECT_TIMER + 1;
let tests = [
// [ time, crossOrigin, shouldAddToHistory ]
[ FAST, false, false ],
[ FAST, true, false ],
[ SLOW, false, false ],
[ SLOW, true, true ],
];
let test = Promise.resolve();
for (let [ time, crossOrigin, shouldAddToHistory ] of tests) {
test = test.then(() => doTest(time, crossOrigin, shouldAddToHistory));
}
test.then(() => SimpleTest.finish());
}
</script>
</head>
<body onload="runTest();">
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test"></pre>
</body>
</html>

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

@ -6753,15 +6753,15 @@ void Document::SetHeaderData(nsAtom* aHeaderField, const nsAString& aData) {
if (aHeaderField == nsGkAtoms::refresh && !IsStaticDocument()) {
// We get into this code before we have a script global yet, so get to our
// container via mDocumentContainer.
if (mDocumentContainer) {
if (nsCOMPtr<nsIRefreshURI> refresher = mDocumentContainer.get()) {
// Note: using mDocumentURI instead of mBaseURI here, for consistency
// (used to just use the current URI of our webnavigation, but that
// should really be the same thing). Note that this code can run
// before the current URI of the webnavigation has been updated, so we
// can't assert equality here.
mDocumentContainer->SetupRefreshURIFromHeader(
mDocumentURI, NodePrincipal(), InnerWindowID(),
NS_ConvertUTF16toUTF8(aData));
refresher->SetupRefreshURIFromHeader(mDocumentURI, NodePrincipal(),
InnerWindowID(),
NS_ConvertUTF16toUTF8(aData));
}
}

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

@ -3796,7 +3796,7 @@ NS_IMETHODIMP BrowserChild::OnProgressChange64(nsIWebProgress* aWebProgress,
NS_IMETHODIMP BrowserChild::OnRefreshAttempted(nsIWebProgress* aWebProgress,
nsIURI* aRefreshURI,
uint32_t aMillis, bool aSameURI,
int32_t aMillis, bool aSameURI,
bool* aOut) {
NS_ENSURE_ARG_POINTER(aOut);
*aOut = true;

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

@ -39,7 +39,6 @@
#include "nsIFrame.h"
#include <algorithm>
#include "nsTextNode.h"
#include "nsDocShell.h"
#include "mozilla/dom/Comment.h"
#include "mozilla/dom/ProcessingInstruction.h"
@ -220,9 +219,9 @@ nsresult txMozillaXMLOutput::endDocument(nsresult aResult) {
if (!mRefreshString.IsEmpty()) {
nsPIDOMWindowOuter* win = mDocument->GetWindow();
if (win) {
nsDocShell* docShell = nsDocShell::Cast(win->GetDocShell());
if (docShell) {
docShell->SetupRefreshURIFromHeader(
nsCOMPtr<nsIRefreshURI> refURI = do_QueryInterface(win->GetDocShell());
if (refURI) {
refURI->SetupRefreshURIFromHeader(
mDocument->GetDocBaseURI(), mDocument->NodePrincipal(),
mDocument->InnerWindowID(), mRefreshString);
}

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

@ -271,7 +271,7 @@ nsBrowserStatusFilter::OnProgressChange64(nsIWebProgress* aWebProgress,
NS_IMETHODIMP
nsBrowserStatusFilter::OnRefreshAttempted(nsIWebProgress* aWebProgress,
nsIURI* aUri, uint32_t aDelay,
nsIURI* aUri, int32_t aDelay,
bool aSameUri, bool* allowRefresh) {
nsCOMPtr<nsIWebProgressListener2> listener = do_QueryInterface(mListener);
if (!listener) {

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

@ -1408,7 +1408,7 @@ void nsDocLoader::FireOnStatusChange(nsIWebProgress* aWebProgress,
}
bool nsDocLoader::RefreshAttempted(nsIWebProgress* aWebProgress, nsIURI* aURI,
uint32_t aDelay, bool aSameURI) {
int32_t aDelay, bool aSameURI) {
/*
* Returns true if the refresh may proceed,
* false if the refresh should be blocked.

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

@ -186,7 +186,7 @@ class nsDocLoader : public nsIDocumentLoader,
nsIURI* aUri, uint32_t aFlags);
[[nodiscard]] bool RefreshAttempted(nsIWebProgress* aWebProgress,
nsIURI* aURI, uint32_t aDelay,
nsIURI* aURI, int32_t aDelay,
bool aSameURI);
// this function is overridden by the docshell, it is provided so that we

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

@ -64,6 +64,6 @@ interface nsIWebProgressListener2 : nsIWebProgressListener {
*/
boolean onRefreshAttempted(in nsIWebProgress aWebProgress,
in nsIURI aRefreshURI,
in unsigned long aMillis,
in long aMillis,
in boolean aSameURI);
};

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

@ -935,6 +935,10 @@ with modules["URILOADER"]:
# doesn't need to be reparsed from the original source.
errors["NS_ERROR_PARSED_DATA_CACHED"] = FAILURE(33)
# This success code indicates that a refresh header was found and
# successfully setup.
errors["NS_REFRESHURI_HEADER_FOUND"] = SUCCESS(2)
# =======================================================================
# 25: NS_ERROR_MODULE_CONTENT