Bug 213342 - Add referrerpolicy attribute support for <link>
Summary: Add referrerpolicy attribute support for <link>
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-06-18 09:03 PDT by Rob Buis
Modified: 2020-06-24 10:49 PDT (History)
10 users (show)

See Also:


Attachments
Patch (18.92 KB, patch)
2020-06-18 09:09 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (19.69 KB, patch)
2020-06-18 12:07 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (23.59 KB, patch)
2020-06-19 04:54 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (24.32 KB, patch)
2020-06-19 04:57 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (23.37 KB, patch)
2020-06-19 06:50 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (24.32 KB, patch)
2020-06-19 07:38 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (24.35 KB, patch)
2020-06-22 08:40 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (1.21 KB, patch)
2020-06-23 13:15 PDT, Rob Buis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rob Buis 2020-06-18 09:03:07 PDT
Add referrerpolicy attribute support for <link>
Comment 1 Rob Buis 2020-06-18 09:09:12 PDT
Created attachment 402209 [details]
Patch
Comment 2 EWS Watchlist 2020-06-18 09:09:59 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 3 Rob Buis 2020-06-18 12:07:46 PDT
Created attachment 402223 [details]
Patch
Comment 4 Rob Buis 2020-06-19 04:54:30 PDT
Created attachment 402275 [details]
Patch
Comment 5 Rob Buis 2020-06-19 04:57:51 PDT
Created attachment 402276 [details]
Patch
Comment 6 Rob Buis 2020-06-19 06:50:34 PDT
Created attachment 402278 [details]
Patch
Comment 7 Rob Buis 2020-06-19 07:38:36 PDT
Created attachment 402282 [details]
Patch
Comment 8 Darin Adler 2020-06-21 13:32:23 PDT
Comment on attachment 402282 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402282&action=review

> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:290
> +            else if (match(attributeName, referrerpolicyAttr)) {
> +                m_referrerPolicy = parseReferrerPolicy(attributeValue, ReferrerPolicySource::ReferrerPolicyAttribute).valueOr(ReferrerPolicy::EmptyString);
> +                break;
> +            }

Doesn't seem necessary to include "break" here. The ones above don’t, and there is a break after the chained if/else statements. That would also allow us to omit the braces and this would fit in better with the lines above.

> Source/WebCore/loader/LinkLoader.h:57
> +    ReferrerPolicy referrerPolicy;

Should we set a default here of ReferrerPolicy::EmptyString? The other members have defaults, except for relAttribute. Generally seems good to not risk this ever being uninitialized. And maybe we can even omit this in some places if it has a default?

> LayoutTests/TestExpectations:244
> -imported/w3c/web-platform-tests/referrer-policy [ Skip ]
> +imported/w3c/web-platform-tests/referrer-policy/origin [ Skip ]

Sure could use a comment.
Comment 9 Rob Buis 2020-06-22 08:40:05 PDT
Created attachment 402478 [details]
Patch
Comment 10 Rob Buis 2020-06-22 09:56:01 PDT
Comment on attachment 402282 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402282&action=review

>> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:290
>> +            }
> 
> Doesn't seem necessary to include "break" here. The ones above don’t, and there is a break after the chained if/else statements. That would also allow us to omit the braces and this would fit in better with the lines above.

You are right, I probably had debug statement there while developing the patch and forgot to remove the break and braces. Fixed.

>> Source/WebCore/loader/LinkLoader.h:57
>> +    ReferrerPolicy referrerPolicy;
> 
> Should we set a default here of ReferrerPolicy::EmptyString? The other members have defaults, except for relAttribute. Generally seems good to not risk this ever being uninitialized. And maybe we can even omit this in some places if it has a default?

I think it gets the EmptyString value by default.

>> LayoutTests/TestExpectations:244
>> +imported/w3c/web-platform-tests/referrer-policy/origin [ Skip ]
> 
> Sure could use a comment.

Yeah I am very familiar with this problem but indeed others may not be. Fixed.
Comment 11 EWS 2020-06-22 10:20:55 PDT
Committed r263356: <https://trac.webkit.org/changeset/263356>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 402478 [details].
Comment 12 Radar WebKit Bug Importer 2020-06-22 10:21:16 PDT
<rdar://problem/64600342>
Comment 13 Darin Adler 2020-06-22 12:19:32 PDT
Comment on attachment 402282 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402282&action=review

>>> Source/WebCore/loader/LinkLoader.h:57
>>> +    ReferrerPolicy referrerPolicy;
>> 
>> Should we set a default here of ReferrerPolicy::EmptyString? The other members have defaults, except for relAttribute. Generally seems good to not risk this ever being uninitialized. And maybe we can even omit this in some places if it has a default?
> 
> I think it gets the EmptyString value by default.

I don’t think it does. As I understand it, if it’s a scalar, it won’t have a default value unless we specify one.
Comment 14 Rob Buis 2020-06-23 13:15:06 PDT
Reopening to attach new patch.
Comment 15 Rob Buis 2020-06-23 13:15:12 PDT
Created attachment 402584 [details]
Patch
Comment 16 Rob Buis 2020-06-23 14:31:48 PDT
Comment on attachment 402282 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=402282&action=review

>>> Source/WebCore/html/parser/HTMLPreloadScanner.cpp:290
>>> +            }
>> 
>> Doesn't seem necessary to include "break" here. The ones above don’t, and there is a break after the chained if/else statements. That would also allow us to omit the braces and this would fit in better with the lines above.
> 
> You are right, I probably had debug statement there while developing the patch and forgot to remove the break and braces. Fixed.

I am still not 100% sure, but initializing can do no harm, so I made the patch.
Comment 17 Darin Adler 2020-06-23 14:36:56 PDT
Comment on attachment 402584 [details]
Patch

Could also initialize relAttribute for the same reason.
Comment 18 Rob Buis 2020-06-24 00:32:17 PDT
(In reply to Darin Adler from comment #17)
> Comment on attachment 402584 [details]
> Patch
> 
> Could also initialize relAttribute for the same reason.

I believe in the relAttribute the default ctor will be called since LinkRelAttribute is non POD.
Comment 19 EWS 2020-06-24 00:38:04 PDT
Committed r263442: <https://trac.webkit.org/changeset/263442>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 402584 [details].
Comment 20 Darin Adler 2020-06-24 10:49:59 PDT
(In reply to Rob Buis from comment #18)
> I believe in the relAttribute the default ctor will be called since
> LinkRelAttribute is non POD.

Oh, OK, great.