Bug 968273 - On reload load from the original uri, so that all redirects are reloader.r=mayhemer

This commit is contained in:
Dragana Damjanovic 2016-06-01 11:57:52 +02:00
Родитель 75d9ae197b
Коммит 87fd6ae3a9
18 изменённых файлов: 102 добавлений и 116 удалений

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

@ -145,10 +145,6 @@ var SessionHistoryInternal = {
entry.originalURI = shEntry.originalURI.spec;
}
if (shEntry.loadReplace) {
entry.loadReplace = shEntry.loadReplace;
}
if (shEntry.srcdocData)
entry.srcdocData = shEntry.srcdocData;
@ -315,9 +311,6 @@ var SessionHistoryInternal = {
if (entry.originalURI) {
shEntry.originalURI = Utils.makeURI(entry.originalURI);
}
if (entry.loadReplace) {
shEntry.loadReplace = entry.loadReplace;
}
if (entry.isSrcdocEntry)
shEntry.srcdocData = entry.srcdocData;
if (entry.baseURI)

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

@ -1254,7 +1254,6 @@ nsDocShell::LoadURI(nsIURI* aURI,
nsCOMPtr<nsIURI> referrer;
nsCOMPtr<nsIURI> originalURI;
bool loadReplace = false;
nsCOMPtr<nsIInputStream> postStream;
nsCOMPtr<nsIInputStream> headersStream;
nsCOMPtr<nsISupports> owner;
@ -1282,7 +1281,6 @@ nsDocShell::LoadURI(nsIURI* aURI,
if (aLoadInfo) {
aLoadInfo->GetReferrer(getter_AddRefs(referrer));
aLoadInfo->GetOriginalURI(getter_AddRefs(originalURI));
aLoadInfo->GetLoadReplace(&loadReplace);
nsDocShellInfoLoadType lt = nsIDocShellLoadInfo::loadNormal;
aLoadInfo->GetLoadType(&lt);
// Get the appropriate loadType from nsIDocShellLoadInfo type
@ -1542,7 +1540,6 @@ nsDocShell::LoadURI(nsIURI* aURI,
return InternalLoad(aURI,
originalURI,
loadReplace,
referrer,
referrerPolicy,
owner,
@ -5299,7 +5296,7 @@ nsDocShell::LoadErrorPage(nsIURI* aURI, const char16_t* aURL,
rv = NS_NewURI(getter_AddRefs(errorPageURI), errorPageUrl);
NS_ENSURE_SUCCESS(rv, rv);
return InternalLoad(errorPageURI, nullptr, false, nullptr,
return InternalLoad(errorPageURI, nullptr, nullptr,
mozilla::net::RP_Default,
nullptr, INTERNAL_LOAD_FLAGS_INHERIT_OWNER, nullptr,
nullptr, NullString(), nullptr, nullptr, LOAD_ERROR_PAGE,
@ -5351,7 +5348,6 @@ nsDocShell::Reload(uint32_t aReloadFlags)
nsAutoString contentTypeHint;
nsCOMPtr<nsIURI> baseURI;
nsCOMPtr<nsIURI> originalURI;
bool loadReplace = false;
if (doc) {
principal = doc->NodePrincipal();
doc->GetContentType(contentTypeHint);
@ -5363,9 +5359,6 @@ nsDocShell::Reload(uint32_t aReloadFlags)
}
nsCOMPtr<nsIChannel> chan = doc->GetChannel();
if (chan) {
uint32_t loadFlags;
chan->GetLoadFlags(&loadFlags);
loadReplace = loadFlags & nsIChannel::LOAD_REPLACE;
nsCOMPtr<nsIHttpChannel> httpChan(do_QueryInterface(chan));
if (httpChan) {
httpChan->GetOriginalURI(getter_AddRefs(originalURI));
@ -5375,7 +5368,6 @@ nsDocShell::Reload(uint32_t aReloadFlags)
rv = InternalLoad(mCurrentURI,
originalURI,
loadReplace,
mReferrerURI,
mReferrerPolicy,
principal,
@ -9519,7 +9511,7 @@ class InternalLoadEvent : public Runnable
{
public:
InternalLoadEvent(nsDocShell* aDocShell, nsIURI* aURI,
nsIURI* aOriginalURI, bool aLoadReplace,
nsIURI* aOriginalURI,
nsIURI* aReferrer, uint32_t aReferrerPolicy,
nsISupports* aOwner, uint32_t aFlags,
const char* aTypeHint, nsIInputStream* aPostData,
@ -9531,7 +9523,6 @@ public:
, mDocShell(aDocShell)
, mURI(aURI)
, mOriginalURI(aOriginalURI)
, mLoadReplace(aLoadReplace)
, mReferrer(aReferrer)
, mReferrerPolicy(aReferrerPolicy)
, mOwner(aOwner)
@ -9554,7 +9545,6 @@ public:
Run()
{
return mDocShell->InternalLoad(mURI, mOriginalURI,
mLoadReplace,
mReferrer,
mReferrerPolicy,
mOwner, mFlags,
@ -9574,7 +9564,6 @@ private:
RefPtr<nsDocShell> mDocShell;
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mOriginalURI;
bool mLoadReplace;
nsCOMPtr<nsIURI> mReferrer;
uint32_t mReferrerPolicy;
nsCOMPtr<nsISupports> mOwner;
@ -9641,7 +9630,6 @@ nsDocShell::IsAboutNewtab(nsIURI* aURI)
NS_IMETHODIMP
nsDocShell::InternalLoad(nsIURI* aURI,
nsIURI* aOriginalURI,
bool aLoadReplace,
nsIURI* aReferrer,
uint32_t aReferrerPolicy,
nsISupports* aOwner,
@ -9905,7 +9893,6 @@ nsDocShell::InternalLoad(nsIURI* aURI,
if (NS_SUCCEEDED(rv) && targetDocShell) {
rv = targetDocShell->InternalLoad(aURI,
aOriginalURI,
aLoadReplace,
aReferrer,
aReferrerPolicy,
owner,
@ -9986,7 +9973,7 @@ nsDocShell::InternalLoad(nsIURI* aURI,
// Do this asynchronously
nsCOMPtr<nsIRunnable> ev =
new InternalLoadEvent(this, aURI, aOriginalURI, aLoadReplace,
new InternalLoadEvent(this, aURI, aOriginalURI,
aReferrer, aReferrerPolicy, aOwner, aFlags,
aTypeHint, aPostData, aHeadersData,
aLoadType, aSHEntry, aFirstParty, aSrcdoc,
@ -10503,7 +10490,10 @@ nsDocShell::InternalLoad(nsIURI* aURI,
nsINetworkPredictor::PREDICT_LOAD, this, nullptr);
nsCOMPtr<nsIRequest> req;
rv = DoURILoad(aURI, aOriginalURI, aLoadReplace, aReferrer,
// At this point we will open a new channel to load data. If aOriginalURI
// is present, we load aOriginalURI instead of aURI because we want to load
// all redirects again.
rv = DoURILoad(aOriginalURI ? aOriginalURI : aURI, aReferrer,
!(aFlags & INTERNAL_LOAD_FLAGS_DONT_SEND_REFERRER),
aReferrerPolicy,
owner, aTypeHint, aFileName, aPostData, aHeadersData,
@ -10580,8 +10570,6 @@ nsDocShell::GetInheritedPrincipal(bool aConsiderCurrentDocument)
nsresult
nsDocShell::DoURILoad(nsIURI* aURI,
nsIURI* aOriginalURI,
bool aLoadReplace,
nsIURI* aReferrerURI,
bool aSendReferrer,
uint32_t aReferrerPolicy,
@ -10854,17 +10842,7 @@ nsDocShell::DoURILoad(nsIURI* aURI,
NS_ADDREF(*aRequest = channel);
}
if (aOriginalURI) {
channel->SetOriginalURI(aOriginalURI);
if (aLoadReplace) {
uint32_t loadFlags;
channel->GetLoadFlags(&loadFlags);
NS_ENSURE_SUCCESS(rv, rv);
channel->SetLoadFlags(loadFlags | nsIChannel::LOAD_REPLACE);
}
} else {
channel->SetOriginalURI(aURI);
}
channel->SetOriginalURI(aURI);
if (aTypeHint && *aTypeHint) {
channel->SetContentType(nsDependentCString(aTypeHint));
@ -11001,8 +10979,8 @@ nsDocShell::DoURILoad(nsIURI* aURI,
httpChannel->SetReferrerWithPolicy(aReferrerURI, aReferrerPolicy);
}
// set Content-Signature enforcing bit if aOriginalURI == about:newtab
if (aOriginalURI && httpChannel) {
if (IsAboutNewtab(aOriginalURI)) {
if (httpChannel) {
if (IsAboutNewtab(aURI)) {
nsCOMPtr<nsILoadInfo> loadInfo = httpChannel->GetLoadInfo();
if (loadInfo) {
loadInfo->SetVerifySignedContent(true);
@ -11866,7 +11844,6 @@ nsDocShell::AddState(JS::Handle<JS::Value> aData, const nsAString& aTitle,
newSHEntry = mOSHE;
newSHEntry->SetURI(newURI);
newSHEntry->SetOriginalURI(newURI);
newSHEntry->SetLoadReplace(false);
}
// Step 4: Modify new/original session history entry and clear its POST
@ -12077,7 +12054,6 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
// Get the post data & referrer
nsCOMPtr<nsIInputStream> inputStream;
nsCOMPtr<nsIURI> originalURI;
bool loadReplace = false;
nsCOMPtr<nsIURI> referrerURI;
uint32_t referrerPolicy = mozilla::net::RP_Default;
nsCOMPtr<nsISupports> cacheKey;
@ -12108,7 +12084,6 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
httpChannel->GetOriginalURI(getter_AddRefs(originalURI));
uint32_t loadFlags;
aChannel->GetLoadFlags(&loadFlags);
loadReplace = loadFlags & nsIChannel::LOAD_REPLACE;
httpChannel->GetReferrer(getter_AddRefs(referrerURI));
httpChannel->GetReferrerPolicy(&referrerPolicy);
@ -12152,7 +12127,6 @@ nsDocShell::AddToSessionHistory(nsIURI* aURI, nsIChannel* aChannel,
mDynamicallyCreated);
entry->SetOriginalURI(originalURI);
entry->SetLoadReplace(loadReplace);
entry->SetReferrerURI(referrerURI);
entry->SetReferrerPolicy(referrerPolicy);
nsCOMPtr<nsIInputStreamChannel> inStrmChan = do_QueryInterface(aChannel);
@ -12252,7 +12226,6 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsIURI> originalURI;
bool loadReplace = false;
nsCOMPtr<nsIInputStream> postData;
nsCOMPtr<nsIURI> referrerURI;
uint32_t referrerPolicy;
@ -12264,8 +12237,6 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
NS_ENSURE_SUCCESS(aEntry->GetURI(getter_AddRefs(uri)), NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(aEntry->GetOriginalURI(getter_AddRefs(originalURI)),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(aEntry->GetLoadReplace(&loadReplace),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(aEntry->GetReferrerURI(getter_AddRefs(referrerURI)),
NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(aEntry->GetReferrerPolicy(&referrerPolicy),
@ -12346,7 +12317,6 @@ nsDocShell::LoadHistoryEntry(nsISHEntry* aEntry, uint32_t aLoadType)
// first created. bug 947716 has been created to address this issue.
rv = InternalLoad(uri,
originalURI,
loadReplace,
referrerURI,
referrerPolicy,
owner,
@ -13848,7 +13818,6 @@ nsDocShell::OnLinkClickSync(nsIContent* aContent,
nsresult rv = InternalLoad(clonedURI, // New URI
nullptr, // Original URI
false, // LoadReplace
referer, // Referer URI
refererPolicy, // Referer policy
aContent->NodePrincipal(), // Owner is our node's

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

@ -353,12 +353,7 @@ protected:
// not have an owner on the channel should just pass null.
// If aSrcdoc is not void, the load will be considered as a srcdoc load,
// and the contents of aSrcdoc will be loaded instead of aURI.
// aOriginalURI will be set as the originalURI on the channel that does the
// load. If aOriginalURI is null, aURI will be set as the originalURI.
// If aLoadReplace is true, OLOAD_REPLACE flag will be set to the nsIChannel.
nsresult DoURILoad(nsIURI* aURI,
nsIURI* aOriginalURI,
bool aLoadReplace,
nsIURI* aReferrer,
bool aSendReferrer,
uint32_t aReferrerPolicy,

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

@ -12,8 +12,7 @@
#include "mozilla/net/ReferrerPolicy.h"
nsDocShellLoadInfo::nsDocShellLoadInfo()
: mLoadReplace(false)
, mInheritOwner(false)
: mInheritOwner(false)
, mOwnerIsExplicit(false)
, mSendReferrer(true)
, mReferrerPolicy(mozilla::net::RP_Default)
@ -68,20 +67,6 @@ nsDocShellLoadInfo::SetOriginalURI(nsIURI* aOriginalURI)
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetLoadReplace(bool* aLoadReplace)
{
*aLoadReplace = mLoadReplace;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::SetLoadReplace(bool aLoadReplace)
{
mLoadReplace = aLoadReplace;
return NS_OK;
}
NS_IMETHODIMP
nsDocShellLoadInfo::GetOwner(nsISupports** aOwner)
{

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

@ -34,7 +34,6 @@ protected:
nsCOMPtr<nsIURI> mReferrer;
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsISupports> mOwner;
bool mLoadReplace;
bool mInheritOwner;
bool mOwnerIsExplicit;
bool mSendReferrer;

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

@ -125,12 +125,11 @@ interface nsIDocShell : nsIDocShellTreeItem
* of an nsIDocShellLoadInfo object...
*
* @param aURI - The URI to load.
* @param aOriginalURI - The URI to set as the originalURI on the channel
* that does the load. If null, aURI will be set as
* the originalURI.
* @param aLoadReplace - If set LOAD_REPLACE flag will be set on the
* channel. aOriginalURI is null, this argument is
* ignored.
* @param aOriginalURI - If aOriginalURI is present and this function ends
* up actually loading data from network or cache,
* but not from bfcache, (e.g. in case of a reload)
* aOriginalURI will be loaded instead of aURI.
* Thereby we will load all redirects again.
* @param aReferrer - Referring URI
* @param aReferrerPolicy - Referrer policy
* @param aOwner - Owner (security principal)
@ -158,7 +157,6 @@ interface nsIDocShell : nsIDocShellTreeItem
*/
[noscript]void internalLoad(in nsIURI aURI,
in nsIURI aOriginalURI,
in boolean aLoadReplace,
in nsIURI aReferrer,
in unsigned long aReferrerPolicy,
in nsISupports aOwner,

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

@ -30,11 +30,6 @@ interface nsIDocShellLoadInfo : nsISupports
*/
attribute nsIURI originalURI;
/**
* loadReplace flag to be passed to nsIDocShell.internalLoad.
*/
attribute boolean loadReplace;
/** The owner of the load, that is, the entity responsible for
* causing the load to occur. This should be a nsIPrincipal typically.
*/

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

@ -47,11 +47,6 @@ interface nsISHEntry : nsISupports
*/
attribute nsIURI originalURI;
/**
* This flag remembers whether channel has LOAD_REPLACE set.
*/
attribute boolean loadReplace;
/**
* A readonly property that returns the title
* of the current entry. The object returned

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

@ -24,7 +24,6 @@ static uint32_t gEntryID = 0;
nsSHEntry::nsSHEntry()
: mShared(new nsSHEntryShared())
, mLoadReplace(false)
, mReferrerPolicy(mozilla::net::RP_Default)
, mLoadType(0)
, mID(gEntryID++)
@ -41,7 +40,6 @@ nsSHEntry::nsSHEntry(const nsSHEntry& aOther)
: mShared(aOther.mShared)
, mURI(aOther.mURI)
, mOriginalURI(aOther.mOriginalURI)
, mLoadReplace(aOther.mLoadReplace)
, mReferrerURI(aOther.mReferrerURI)
, mReferrerPolicy(aOther.mReferrerPolicy)
, mTitle(aOther.mTitle)
@ -137,20 +135,6 @@ nsSHEntry::SetOriginalURI(nsIURI* aOriginalURI)
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetLoadReplace(bool* aLoadReplace)
{
*aLoadReplace = mLoadReplace;
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::SetLoadReplace(bool aLoadReplace)
{
mLoadReplace = aLoadReplace;
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetReferrerURI(nsIURI** aReferrerURI)
{

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

@ -50,7 +50,6 @@ private:
// See nsSHEntry.idl for comments on these members.
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mOriginalURI;
bool mLoadReplace;
nsCOMPtr<nsIURI> mReferrerURI;
uint32_t mReferrerPolicy;
nsString mTitle;

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

@ -1767,10 +1767,6 @@ nsSHistory::InitiateLoad(nsISHEntry* aFrameEntry, nsIDocShell* aFrameDS,
aFrameEntry->GetOriginalURI(getter_AddRefs(originalURI));
loadInfo->SetOriginalURI(originalURI);
bool loadReplace;
aFrameEntry->GetLoadReplace(&loadReplace);
loadInfo->SetLoadReplace(loadReplace);
nsCOMPtr<nsIURI> nextURI;
aFrameEntry->GetURI(getter_AddRefs(nextURI));
// Time to initiate a document load

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

@ -0,0 +1 @@
<html><body>This is bug968273_new.html.</body></html>

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

@ -0,0 +1 @@
<html><body>This document is redirected to bug968273_new.html.</body></html>

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

@ -0,0 +1,2 @@
HTTP 302 Moved Temporarily
Location: bug968273_new.html

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

@ -0,0 +1,42 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=968273
If a load has redirects, reloading the page will load the page starting with the original
URI and do the redirects again.
-->
<head>
<title>Test for Bug 968273</title>
<script>
var SimpleTest = opener.SimpleTest;
var ok = opener.ok;
var is = opener.is;
var doOneReload = true;
function onLoadCheckFrame() {
ok(frames[0].performance, 'Window.performance should be defined');
ok(frames[0].performance.navigation, 'Window.performance.navigation should be defined');
// do this with a timeout to see the visuals of the navigations.
setTimeout("checkFrame();", 200);
}
function checkFrame() {
is(frames[0].performance.navigation.redirectCount, 1, "Expected rediect");
if (doOneReload == true) {
doOneReload = false;
// do a reload and check that a redirect is preformed again.
frames[0].location.reload();
} else {
SimpleTest.finish();
}
}
</script>
</head>
<body>
<div id="frames">
<iframe name="child0" onload="onLoadCheckFrame();" src="bug968273_redirect.html"></iframe>
</div>
</body>
</html>

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

@ -11,6 +11,9 @@ support-files =
bug668513_redirect.html
bug668513_redirect.html^headers^
bug691547_frame.html
bug968273_new.html
bug968273_redirect.html
bug968273_redirect.html^headers^
file_anchor_scroll_after_document_open.html
file_bug385434_1.html
file_bug385434_2.html
@ -32,6 +35,7 @@ support-files =
file_bug680257.html
file_bug703855.html
file_bug728939.html
file_bug968273.html
file_pushState_after_document_open.html
historyframes.html
@ -108,3 +112,5 @@ support-files = file_framedhistoryframes.html
skip-if = (buildapp == 'b2g' && toolkit != 'gonk') #Bug 931116, b2g desktop specific, initial triage
[test_bug1121701.html]
skip-if = (buildapp == 'b2g' || buildapp == 'mulet')
[test_bug968273.html]
skip-if = toolkit == 'android' # The same reason test_bug668513.html is disabled. performance.redirectcount check false on load but it is correct on reload.

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

@ -0,0 +1,34 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=968273
If a load has redirects, reloading the page will load the page starting with the original
URI and do the redirects again.
-->
<head>
<title>Test for Bug 968273</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=968273">Mozilla Bug 968273</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type='application/javascript'>
if (navigator.platform.startsWith("Linux")) {
SimpleTest.expectAssertions(0, 1);
}
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("We need do this with a timeout to see the visuals of" +
" the performance.navigation");
window.open("file_bug968273.html");
</script>
</pre>
</body>
</html>

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

@ -1035,10 +1035,6 @@ SessionStore.prototype = {
entry.originalURI = aEntry.originalURI.spec;
}
if (aEntry.loadReplace) {
entry.loadReplace = aEntry.loadReplace;
}
if (aEntry.contentType) {
entry.contentType = aEntry.contentType;
}
@ -1127,10 +1123,6 @@ SessionStore.prototype = {
shEntry.originalURI = Services.io.newURI(aEntry.originalURI, null, null);
}
if (aEntry.loadReplace) {
shEntry.loadReplace = aEntry.loadReplace;
}
if (aEntry.cacheKey) {
let cacheKey = Cc["@mozilla.org/supports-PRUint32;1"].createInstance(Ci.nsISupportsPRUint32);
cacheKey.data = aEntry.cacheKey;