RESOLVED FIXED208424
Add referrerpolicy attribute support for anchors
https://bugs.webkit.org/show_bug.cgi?id=208424
Summary Add referrerpolicy attribute support for anchors
Rob Buis
Reported 2020-03-01 06:29:18 PST
Add referrerpolicy attribute support for anchors
Attachments
Patch (94.98 KB, patch)
2020-03-01 06:37 PST, Rob Buis
no flags
Patch (677.44 KB, patch)
2020-03-01 07:52 PST, Rob Buis
no flags
Patch (140.81 KB, patch)
2020-03-01 09:13 PST, Rob Buis
no flags
Patch (149.10 KB, patch)
2020-03-01 10:23 PST, Rob Buis
no flags
Patch (148.63 KB, patch)
2020-03-01 23:53 PST, Rob Buis
no flags
Patch (179.73 KB, patch)
2020-03-02 04:56 PST, youenn fablet
no flags
Rob Buis
Comment 1 2020-03-01 06:37:44 PST
Rob Buis
Comment 2 2020-03-01 07:52:51 PST
Rob Buis
Comment 3 2020-03-01 09:13:08 PST
Rob Buis
Comment 4 2020-03-01 10:23:46 PST
Darin Adler
Comment 5 2020-03-01 17:52:39 PST
Comment on attachment 392100 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=392100&action=review All these frame load request with all these default policies listed over and over again point to poor design patterns; we should figure out a way to construct these things where we don’t write so much boilerplate code. I’d say we should use a struct so we can set named properties, but FrameLoadRequest already is a bit like that. Seriously the number of places with these ridiculously long lists of arguments and policy settings is out of hand. > Source/WebCore/html/HTMLAnchorElement.cpp:497 > + ReferrerPolicy referrerPolicy = hasRel(Relation::NoReferrer) ? ReferrerPolicy::NoReferrer : this->referrerPolicy(); I’d use auto here for the variable type. No reason to repeat the name ReferrerPolicy extra times. > Source/WebCore/html/HTMLAnchorElement.cpp:622 > +void HTMLAnchorElement::setReferrerPolicyForBindings(const AtomString& value) > +{ > + setAttributeWithoutSynchronization(referrerpolicyAttr, value); > +} > + > +String HTMLAnchorElement::referrerPolicyForBindings() const > +{ > + return referrerPolicyToString(referrerPolicy()); > +} > + > +ReferrerPolicy HTMLAnchorElement::referrerPolicy() const > +{ > + if (RuntimeEnabledFeatures::sharedFeatures().referrerPolicyAttributeEnabled()) > + return parseReferrerPolicy(attributeWithoutSynchronization(referrerpolicyAttr), ReferrerPolicySource::ReferrerPolicyAttribute).valueOr(ReferrerPolicy::EmptyString); > + return ReferrerPolicy::EmptyString; > +} Would be nicer to share a little bit more code with image element, but not sure I know how to do that. > Source/WebCore/loader/FrameLoadRequest.cpp:65 > + , m_referrerPolicy { ReferrerPolicy::EmptyString } These defaults should be in the class definition instead of here. Unless there’s some reason not to do that. > Source/WebCore/loader/FrameLoadRequest.h:113 > + ReferrerPolicy m_referrerPolicy; Like here: ReferrerPolicy m_referrerPolicy { ReferrerPolicy::EmptyString }; > LayoutTests/http/tests/referrer-policy-anchor/no-referrer-when-downgrade/cross-origin-http-http-expected.txt:9 > +Tests the behavior of no-referrer-when-downgrade referrer policy when same origin. > + > +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". > + > + > +PASS referrer is expected > +PASS successfullyParsed is true > + > +TEST COMPLETE This is a frustrating style of test output. The entire text amounts to a single "PASS"; nothing about the test is visible. Even the title of the test has been copied and pasted and so does not make clear what is being tested and how this differs from other tests. The standard form writes out a value and what the expected value was. That gives the person running the test more insight into what is going on. We should put some thought into the design of the test output. Seems like the tests have pretty good coverage. Maybe a single test that covers multiple cases would be practical, too. These tests are OK, much better than not having test coverage, but the design here is not the intent of the test framework.
Rob Buis
Comment 6 2020-03-01 23:53:40 PST
Rob Buis
Comment 7 2020-03-02 02:47:21 PST
Comment on attachment 392100 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=392100&action=review >> Source/WebCore/html/HTMLAnchorElement.cpp:497 >> + ReferrerPolicy referrerPolicy = hasRel(Relation::NoReferrer) ? ReferrerPolicy::NoReferrer : this->referrerPolicy(); > > I’d use auto here for the variable type. No reason to repeat the name ReferrerPolicy extra times. Done. >> Source/WebCore/html/HTMLAnchorElement.cpp:622 >> +} > > Would be nicer to share a little bit more code with image element, but not sure I know how to do that. There are multiple places now with this code, but indeed hard to share. >> Source/WebCore/loader/FrameLoadRequest.cpp:65 >> + , m_referrerPolicy { ReferrerPolicy::EmptyString } > > These defaults should be in the class definition instead of here. Unless there’s some reason not to do that. Done. >> Source/WebCore/loader/FrameLoadRequest.h:113 >> + ReferrerPolicy m_referrerPolicy; > > Like here: > > ReferrerPolicy m_referrerPolicy { ReferrerPolicy::EmptyString }; Done. >> LayoutTests/http/tests/referrer-policy-anchor/no-referrer-when-downgrade/cross-origin-http-http-expected.txt:9 >> +TEST COMPLETE > > This is a frustrating style of test output. The entire text amounts to a single "PASS"; nothing about the test is visible. Even the title of the test has been copied and pasted and so does not make clear what is being tested and how this differs from other tests. > > The standard form writes out a value and what the expected value was. That gives the person running the test more insight into what is going on. > > We should put some thought into the design of the test output. Seems like the tests have pretty good coverage. > > Maybe a single test that covers multiple cases would be practical, too. > > These tests are OK, much better than not having test coverage, but the design here is not the intent of the test framework. Agreed, the output is not great, but at least it covers everything. Note that the real problem is that we can't import the WPT tests because of the problem illustrated here https://github.com/web-platform-tests/wpt/pull/19381.
Rob Buis
Comment 8 2020-03-02 02:48:44 PST
(In reply to Darin Adler from comment #5) > Comment on attachment 392100 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=392100&action=review > > All these frame load request with all these default policies listed over and > over again point to poor design patterns; we should figure out a way to > construct these things where we don’t write so much boilerplate code. I’d > say we should use a struct so we can set named properties, but > FrameLoadRequest already is a bit like that. Seriously the number of places > with these ridiculously long lists of arguments and policy settings is out > of hand. Agreed, it is not pretty. I am likely to touch FrameLoadRequest in the future so I will keep it in the back of my mind.
WebKit Commit Bot
Comment 9 2020-03-02 03:36:06 PST
Comment on attachment 392117 [details] Patch Clearing flags on attachment: 392117 Committed r257707: <https://trac.webkit.org/changeset/257707>
WebKit Commit Bot
Comment 10 2020-03-02 03:36:08 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 11 2020-03-02 03:37:17 PST
youenn fablet
Comment 12 2020-03-02 04:55:55 PST
Reopening to attach new patch.
youenn fablet
Comment 13 2020-03-02 04:56:00 PST
Rob Buis
Comment 14 2020-03-02 05:26:14 PST
Wrong bug?
youenn fablet
Comment 15 2020-03-02 06:19:59 PST
(In reply to Rob Buis from comment #14) > Wrong bug? Definitely....
Note You need to log in before you can comment on or make changes to this bug.