Open Bug 1506520 Opened 7 years ago Updated 3 years ago

Referrer policy incorrectly shown

Categories

(DevTools :: Netmonitor, defect, P3)

65 Branch
defect

Tracking

(Not tracked)

People

(Reporter: buggyz, Unassigned)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:65.0) Gecko/20100101 Firefox/65.0 Steps to reproduce: Bug #1496742 introduced displaying the referrer-policy of a website in Firefox -Nightly (Firefox 65.0a1). At https://www.bonnieradvocaten.nl we use a same-origin referrer-policy, but this is not correctly recognized for the first response (HTML). Actual results: Firefox 65 shows the referrer-policy as "no-referrer-when-downgrade". Expected results: Firefox 65 should have shown the actual referrer policy for https://www.bonnieradvocaten.nl which is referrer-policy: same-origin.
Component: Untriaged → Netmonitor
Product: Firefox → DevTools
@Heng Yeow: can you please look at this? Honza
Flags: needinfo?(E0032242)
From a note in bug 1496742 Note: If the network.http.referer.hideOnionSource is set and the referrer is .onion ended The "Referrer Policy" in devtool always shows "no-referrer-when-downgrade" which is default.

(In reply to Thomas Nguyen from comment #2)

From a note in bug 1496742
Note:
If the network.http.referer.hideOnionSource is set and the referrer is
.onion ended
The "Referrer Policy" in devtool always shows "no-referrer-when-downgrade"
which is default.

I can reproduce the bug and I have network.http.referer.hideOnionSource set to false.

@junior: do you know what's the problem here?

Honza

Flags: needinfo?(juhsu)

Added a simple debugging tests
[ReferrerPolicy.h:135] DEBUGGING STRING ==> 5 6 same-origin
[ReferrerPolicy.h:135] DEBUGGING STRING ==> 5 6 same-origin
[ReferrerPolicy.h:135] DEBUGGING STRING ==> 5 6 same-origin
[ReferrerPolicy.h:135] DEBUGGING STRING ==> 5 1 no-referrer-when-downgrade
[ReferrerPolicy.h:135] DEBUGGING STRING ==> 5 1 no-referrer-when-downgrade

And it is weird that only the first request got wrong referrer policy, the second one got it correctly.
Did we get a wrong channel?
https://searchfox.org/mozilla-central/rev/465dbfe030dfec7756b9b523029e90d48dd5ecce/devtools/server/actors/network-monitor/network-observer.js#499
devtool guys could have a better answer.

The second request

The first request

Thomas knows more about Referrer-Policy than me.

Flags: needinfo?(juhsu)

(In reply to Thomas Nguyen from comment #4)

Added a simple debugging tests
[ReferrerPolicy.h:135] DEBUGGING STRING ==> 5 6 same-origin
[ReferrerPolicy.h:135] DEBUGGING STRING ==> 5 6 same-origin
[ReferrerPolicy.h:135] DEBUGGING STRING ==> 5 6 same-origin
[ReferrerPolicy.h:135] DEBUGGING STRING ==> 5 1 no-referrer-when-downgrade
[ReferrerPolicy.h:135] DEBUGGING STRING ==> 5 1 no-referrer-when-downgrade

And it is weird that only the first request got wrong referrer policy, the second one got it correctly.
Did we get a wrong channel?
I don't see why the channel would be wrong (and only for the first case)

Can you please post your debugging test (to understand the output)

Honza

Flags: needinfo?(tnguyen)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3

diff --git a/netwerk/base/ReferrerPolicy.h b/netwerk/base/ReferrerPolicy.h
index 9cd36f0c7d7d..b044f70c2421 100644
--- a/netwerk/base/ReferrerPolicy.h
+++ b/netwerk/base/ReferrerPolicy.h
@@ -132,6 +132,7 @@ inline ReferrerPolicy AttributeReferrerPolicyFromString(
}

inline const char* ReferrerPolicyToString(ReferrerPolicy aPolicy) {

  • printf_stderr("\n[ReferrerPolicy.h:135] DEBUGGING STRING ==> %d %d %s\n\n", 5, aPolicy, kReferrerPolicyString[static_cast<uint32_t>(aPolicy)]);
    return kReferrerPolicyString[static_cast<uint32_t>(aPolicy)];
    }

If no one in your team could take a look at the moment, just assign to me. I will take a look 1-2 weeks later
Thanks

Flags: needinfo?(tnguyen)

(In reply to Thomas Nguyen from comment #9)

If no one in your team could take a look at the moment, just assign to me. I will take a look 1-2 weeks later
Done, thanks!

Honza

Assignee: nobody → tnguyen
Status: NEW → ASSIGNED

Seems like a platform issue, but would be glad to follow up if there are any JS stuff that needs help after the issue has been investigated :)

Flags: needinfo?(E0032242)

The channel was not updated the referrer policy after found "referrer-policy". That's is only for loading document case. I will decide to fix it after exposing referrer policy in channel.

(In reply to Thomas Nguyen from comment #12)

The channel was not updated the referrer policy after found "referrer-policy". That's is only for loading document case. I will decide to fix it after exposing referrer policy in channel.

The problem is, the showing referrer policy is the real (and old) referrer policy which channel used to compute referer header and sent to the network.
I don't quite sure what is going to show, channel request's referrer policy (1) or document's (or response's) referrer policy (2)?

Flags: needinfo?(odvarko)

@Christoph, can you please take a look at the question in comment #13?

Thanks,
Honza

Flags: needinfo?(odvarko) → needinfo?(ckerschb)

I am biased to keep our implementation the same (as we are observing the channel we really sent to network).

Looking at comment 0 I see the following. I see request headers and response headers:

  • Since this is the initial top-level request I assume we display the default origin policy which is 'no-referrer-when-downgrade' (since no referrer-policy has been transmitted to the user agent yet).
  • The response header includes 'same-origin' so I assume subsequent subresouce loads include the right origin policy.

I guess the right thing to do is to exclude loads of TYPE_DOCUMENT when displaying the referrer policy in the request header.

Does that sound right Thomas?

Flags: needinfo?(ckerschb) → needinfo?(tnguyen)

Per 4.1.2.6 of Fetch [1], we would set no-referrer-when-downgrade as a default policy.

[1] https://fetch.spec.whatwg.org/#main-fetch

(In reply to Junior [:junior] from comment #17)

Per 4.1.2.6 of Fetch [1], we would set no-referrer-when-downgrade as a default policy.

Oh thanks - in that case I guess there is no bug here, or am I missing something?

(In reply to Christoph Kerschbaumer [:ckerschb] from comment #18)

(In reply to Junior [:junior] from comment #17)

Per 4.1.2.6 of Fetch [1], we would set no-referrer-when-downgrade as a default policy.

Oh thanks - in that case I guess there is no bug here, or am I missing something?

Let me clarify it:

  • Given a webpage A.html with <meta name="referrer" content="origin">, then user opens a new window B.html from a link (Right click, and click Open New Window in context menu). Then the channel opening new window will get the referrer policy of document A (origin in this case).
  • Supposed that when loading B.html, we get a Referrer-Policy response = "no-referrer".
    What will happen is:
  • The first (top level) load used the old referrer policy, this should be "origin" and other loads of B.html should use new referrer policy: "no-referrer"

I understand Chrome will show "no-referrer" but it seems not reasonable. I think showing "origin" for the first load and "no-referrer" for other loads is correct behavior.

Flags: needinfo?(tnguyen)
Assignee: tnguyen → nobody
Status: ASSIGNED → NEW
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: