Bug 162149

Summary: Rename SecurityOrigin::canRequest to SecurityOrigin::shouldTreatAsSameOrigin
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebCore Misc.Assignee: youenn fablet <youennf>
Status: NEW    
Severity: Normal CC: achristensen, ap, beidson, darin, mitz, sam, wilander
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
shoudTreatAsSameOrigin renaming beidson: review-

youenn fablet
Reported 2016-09-19 07:16:06 PDT
This will better match the use of SecurityOrigin::canRequest.
Attachments
Patch (24.99 KB, patch)
2016-09-19 07:29 PDT, youenn fablet
no flags
Patch (24.26 KB, patch)
2016-09-19 07:45 PDT, youenn fablet
no flags
shoudTreatAsSameOrigin renaming (24.43 KB, patch)
2016-09-19 23:14 PDT, youenn fablet
beidson: review-
youenn fablet
Comment 1 2016-09-19 07:29:11 PDT
youenn fablet
Comment 2 2016-09-19 07:45:10 PDT
Alexey Proskuryakov
Comment 3 2016-09-19 16:54:41 PDT
Comment on attachment 289229 [details] Patch SecurityOrigin::canRequest returns true in many cases other than same origin URL, so it can't be called isSameOrigin.
Alexey Proskuryakov
Comment 4 2016-09-19 16:55:17 PDT
Perhaps "shouldBeTreatedAsSameOrigin" or something else would be a good name.
youenn fablet
Comment 5 2016-09-19 23:14:21 PDT
Created attachment 289327 [details] shoudTreatAsSameOrigin renaming
youenn fablet
Comment 6 2016-09-19 23:16:07 PDT
(In reply to comment #4) > Perhaps "shouldBeTreatedAsSameOrigin" or something else would be a good name. OK. How about shouldTreatAsSameOrigin?
Alexey Proskuryakov
Comment 7 2016-09-20 09:56:58 PDT
This is a member function of SecurityOrigin, and saying origin-> shouldTreatAsSameOrigin(...) seems confusing - the origin doesn't "treat" the URL passed. There is a large number of options, all the way to making this a non-member function. Discussing on webkit-dev wouldn't be a bad idea I think.
youenn fablet
Comment 8 2016-09-21 00:34:58 PDT
(In reply to comment #7) > This is a member function of SecurityOrigin, and saying origin-> > shouldTreatAsSameOrigin(...) seems confusing - the origin doesn't "treat" > the URL passed. Before the patch, the code could be read as: can the security origin request that URL ? With the patch, it read as: should the security origin treat as same origin the URL? > There is a large number of options, all the way to making this a non-member > function. Discussing on webkit-dev wouldn't be a bad idea I think. Let's start with this bug entry and we will seek webkit-dev if needed.
Darin Adler
Comment 9 2016-09-21 11:50:55 PDT
What language is used in the relevant standards and specifications for this concept? Could you point me at some of the key passages in the standards so I can see what kind of wording they use and how consistent our internal terminology is with that?
youenn fablet
Comment 10 2016-09-21 12:17:30 PDT
HTML spec is using CORS-same-origin and CORS-cross-origin terms. This allows handling canvas tainting, script error message filtering, css rule set access from JS... See https://html.spec.whatwg.org/#fetching-resources for a definition of those terms. The definition refers to fetch spec. In fetch spec, https://fetch.spec.whatwg.org/#main-fetch is interesting, in particular step 11 when doing "request's current url's origin is request's origin". That is what canRequest is really all about. When looking at the place where canRequest is used (cf. the patch), this matches pretty well this same question: is it the same origin (not CORS-same-origin)? Ideally, after refactoring is done, I would like code to check the HTML CORS-same-origin/CORS-cross-origin information on CachedResource directly, since a CachedResource is origin-specific. This should remove several uses of canRequest.
youenn fablet
Comment 11 2016-09-22 04:32:17 PDT
Darin Adler
Comment 12 2016-09-22 11:42:26 PDT
This function is about a policy, not a check if two origins are the same. I think “should treat as same origin” is not great, because there could be many places that want to check if two origins are the same and maybe they should not use this function.
Darin Adler
Comment 13 2016-09-22 15:02:41 PDT
I am going to think about other name suggestions. A useful exercise is to look at the different call sites and try to think about what words you would use to explain the check to a person. Maybe that will end up being "should treat as same origin", but maybe not.
youenn fablet
Comment 14 2016-09-23 13:28:23 PDT
canRequest name makes it clear that we are testing an URL (an instance) against an origin (a set of URLs). We probably should keep that information. How about: bool isURLSameOrigin(const URL&, const SecurityOrigin&);
Brady Eidson
Comment 15 2018-02-14 10:34:10 PST
Comment on attachment 289327 [details] shoudTreatAsSameOrigin renaming Patches that have been up for review since 2016 are almost certainly too stale to be relevant to trunk in their current form. If this patch is still important please rebase it and post it for review again.
Note You need to log in before you can comment on or make changes to this bug.