Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add content scripts section in specification #542
base: main
Are you sure you want to change the base?
Add content scripts section in specification #542
Changes from 1 commit
ce2aca0
f5e9623
b7963a9
fe65789
d059857
1963f22
5d5c86d
9cb7e89
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we (browsers) have different criteria for match_about_blank?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description here is too vague.
match_about_blank
was designed forabout:blank
andabout:srcdoc
.If you're looking for clarity, see https://stackoverflow.com/questions/41408936/can-anyone-explain-that-what-is-the-use-of-match-about-blank-in-chrome-extensi, where I previously posted an answer that describes why
match_about_blank
exists and what it does.Other documentation:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rob--W, could you take another look? I've made some tweaks although it's unclear to me what was too vague.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Rob--W @rdcronin Would you be able to take a look at this one and confirm if it is accurate? This was my best understanding based on bugs and documentation in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd rephrase this.
(The issue with the current language is that:
a] it doesn't specify what the "non-opaque" origin is or where it comes from
b] it doesn't always use the origin of the parent; it uses the initiator (or "precursor"))
If the URL of a document has a specified scheme**, the user agent will fall back to the origin of the initiator instead. This is commonly, but not always, the parent or embedding frame.
** In chrome, these schemes are data:, about:, filesystem:, and blob:. Is that the same in other browsers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tagging @Rob--W and @xeenon to request feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oliverdunk The semantics have extensively been discussed on Chromium's issue tracker where I and Devlin discussed the API design. If you're interested, the start of the discussion is at https://issues.chromium.org/issues/40443085#comment48. The design that is close to what we have now was sketched in https://issues.chromium.org/issues/40443085#comment61 , with the final name (
match_origin_as_fallback
) at https://issues.chromium.org/issues/40443085#comment67. Devlin summarized the discussion at https://issues.chromium.org/issues/40443085#comment71Upon reviewing the proposed texts here, I think that there is some confusion on terminology. The current text mentions blob URLs as an opaque origin, but that is not the case.
Relevant to content script matching is the URL of the document (which can have an origin component) and the origin of the document (as a security principal). There may not always be an obvious relation between the two:
blob:
and (Chrome-only)filesystem:
(e.g.blob:https://example.com/UUID
).about:blank
andabout:srcdoc
), but still have a non-opaque origin: commonly the opener of the frame or window is another http(s) URL. Or even any number ofabout:blank
/srcdoc
documents where the first was initially opened by a http(s) origin.<iframe sandbox>
orsandbox
directive in theContent-Security-Policy
. A content script can usewindow.origin
to see whether the origin is opaque, as it would serialize to"null"
.<iframe sandbox="allow-scripts" src="https://example.com">
data:-URL
or toabout:blank
. Sincedata:
-URLmatches
for all URLs ANDmatch_about_blank: true
to run scripts in top-level about:blank. This is not documented anywhere though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks both, writing the description for these two keys has taken by far the most time in this PR. I've given it another attempt and would appreciate any feedback.
As a general note, concepts like the precursor origin and security principal don't appear to be defined in any other specifications. It seems like they are more informal terms used often in implementations and by implementors. With that in mind, I've tried to describe them as best as possible without talking about them by name.
A few additional notes:
match_about_blank
describing the Firefox behavior for top-level about:blank pages.match_origin_as_fallback
is set. This is the behavior today in Chrome. Interestingly, we don't have any restrictions oninclude_globs
orexclude_globs
. This feels like an omission to me and I wonder if we should specify something.Clearly there's a lot of detail here so please let me know if I've missed anything or it could be clearer.