Closed Bug 968861 Opened 12 years ago Closed 2 years ago

No referer header when the page is reloaded after modifying window.location.hash or history.pushState

Categories

(Core :: DOM: Navigation, defect)

27 Branch
x86_64
macOS
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: jan, Unassigned)

References

Details

(Whiteboard: needs spec check)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36 Steps to reproduce: 1. open e.g. http://www.w3schools.com 2. open firebug, click net tab 3. click e.g. Learn HTML (http://www.w3schools.com/html/default.asp) 4. see the first request (default.asp) -> Referer: http://www.w3schools.com/ 5. reload the page 6. see the first request (default.asp) -> Referer: http://www.w3schools.com/ 7. switch to console tab of the firebug window 8. run window.location.hash = 'sc=1'; 9. reload the page 10. see the first request (defualt.asp) -> no referer header Actual results: No referer header is found in the request http header if the history has been changed by window.location.hash or by history.pushState and the page was then reloaded. Expected results: The same referer header as before the script was run should be present.
Hardware: x86 → x86_64
Component: Untriaged → General
Product: Firefox → Core
Summary: No referer header after the page is reloaded → No referer header when the page is reloaded after modifying window.location.hash or history.pushState
Needs spec check to see what happens here. I'm a bit surprised we resend the old referrer on reload..
Component: General → Document Navigation
Whiteboard: needs spec check
But chances are, we don't copy over the referrer URI to the new SHEntry. Again, the question is what the spec says here.
The spec is http://www.w3.org/html/wg/drafts/html/master/dom.html#dom-document-referrer http://www.w3.org/html/wg/drafts/html/master/dom.html#the-document%27s-referrer Neither provides sufficient info. However, this seems a valid bug to me. > But chances are, we don't copy over the referrer URI to the new SHEntry. That's right. When LoadURI() is called and the request is simple hash change, docshell go into the short-circuited root so as to skip network things. In that case, the request channel is nullptr. http://mxr.mozilla.org/mozilla-central/source/docshell/base/nsDocShell.cpp?force=1#9365 > 9365 OnNewURI(aURI, nullptr, owner, mLoadType, true, true, true); AddToSessionHistory() will tries to set the referrer from the (null) channel, then it clears the referrer. http://mxr.mozilla.org/mozilla-central/source/docshell/base/nsDocShell.cpp#11086 > 11086 entry->SetReferrerURI(referrerURI);
Blocks: 761152
Status: UNCONFIRMED → NEW
Ever confirmed: true

Will it be fixed?

Peter, Anny, if you're redesigning session history anyway...

In particular, nsDocShell::AddToSessionHistory only puts referrer info on the new entry if aChannel is not null. But nsDocShell::UpdateURLAndHistory passes null for the channel. So presumably it should copy the referrer state manually. That's for the pushState case. The location.hash case would need something similar.

See Also: → 266554, 1324860
Severity: normal → S3

This has been fixed in bug 761152 and bug 1750706

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
No longer blocks: 761152
Depends on: 1750706, 761152
See Also: 1324860
You need to log in before you can comment on or make changes to this bug.