Skip to content

Commit a6f50dc

Browse files
authored
Merge branch 'main' into main
2 parents ad47fb7 + e393c3f commit a6f50dc

File tree

3 files changed

+140
-10
lines changed

3 files changed

+140
-10
lines changed

.github/workflows/deploy.yml

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030
include:
3131
- name: specification
3232
source: ./specification/index.bs
33+
- name: webdriver-classic
34+
source: ./specification/webdriver-classic.bs
3335
- name: window-browser
3436
source: ./specification/window.browser.bs
3537

specification/index.bs

+132-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Group: WECG
77
URL: https://w3c.github.io/webextensions/specification/index.html
88
Editor: Mukul Purohit, Microsoft Corporation https://www.microsoft.com, [email protected]
99
Editor: Tomislav Jovanovic, Mozilla https://www.mozilla.org/, [email protected]
10+
Editor: Oliver Dunk, Google https://www.google.com, [email protected]
1011
Abstract: [Placeholder] Abstract.
1112
Markup Shorthands: markdown yes
1213
</pre>
@@ -27,11 +28,11 @@ An optional directory containing strings as defined in <a href="#localization">l
2728

2829
## Other files
2930

30-
An extension may also contain other files, such as those referenced in the <a href="#key-content_scripts">content_scripts</a> and <a href="#key-background">background</a> part of the <a href="#manifest">Manifest</a>.
31+
An extension may also contain other files, such as those referenced in the [[#key-content_scripts]] and [[#key-background]] parts of the [=manifest=].
3132

3233
# Manifest
3334

34-
A WebExtension must have a manifest file at its root directory.
35+
A WebExtension must have a <dfn>manifest</dfn> file at its root directory.
3536

3637
## Manifest file
3738

@@ -112,7 +113,7 @@ This key may be present.
112113

113114
### Key `content_scripts`
114115

115-
This key may be present.
116+
The <a href="#key-content_scripts">`content_scripts`</a> key is a [=list=] of items representing [=content scripts=] that should be registered.
116117

117118
### Key `content_security_policy`
118119

@@ -154,6 +155,8 @@ Filenames beginning with an underscore (`_`) are reserved for use by user agent.
154155

155156
# Isolated worlds
156157

158+
<dfn>Worlds</dfn> are isolated JavaScript contexts with access to the same underlying DOM tree but their own set of wrappers around those DOM objects. Declarations in the global scope are also isolated.
159+
157160
# Unavailable APIs
158161

159162
# The `browser` global
@@ -172,6 +175,12 @@ Issue(62): Specify localization handling.
172175

173176
# Match patterns
174177

178+
A <dfn>match pattern</dfn> is a pattern used to match URLs. They are case-insensitive.
179+
180+
# Globs
181+
182+
A <dfn>glob</dfn> can be any [=string=]. It can contain any number of wildcards where `*` can match zero or more characters and `?` matches exactly one character.
183+
175184
# Concepts
176185

177186
## Uniqueness of extension IDs
@@ -190,7 +199,78 @@ Issue(62): Specify localization handling.
190199

191200
## Content scripts
192201

193-
### Isolated worlds
202+
<dfn>Content scripts</dfn> represent a set of JS and CSS files that should be injected into matching pages loaded by the user agent. They are injected using the steps in [[#inject-a-content-script]].
203+
204+
### Key `matches`
205+
206+
A [=list=] of [=match patterns=] that are used to decide which pages the user agent injects the content script into. This key is required.
207+
208+
### Key `exclude_matches`
209+
210+
A [=list=] of [=match patterns=] that can be used to specify URLs where the content script should not run, even if the URL matches entries in [[#key-matches]] and (if specified) [[#key-include_globs]].
211+
212+
### Key `js`
213+
214+
A [=list=] of file paths, relative to the extension's package, that should be injected as scripts.
215+
216+
### Key `css`
217+
218+
A [=list=] of file paths, relative to the extension's package, that should be injected as stylesheets.
219+
220+
### Key `all_frames`
221+
222+
If `all_frames` is `true`, the content script must be injected into any subframes that match the other matching criteria for the content script. If `false`, content scripts will only be injected into top-level documents. Defaults to `false`.
223+
224+
### Key `match_about_blank`
225+
226+
If this is `true`, use the URL of the parent frame when matching a child frame whose document URL is `about:blank` or `about:srcdoc`. See also [[#determine-the-url-for-matching-a-document]]. Defaults to `false`.
227+
228+
### Key `match_origin_as_fallback`
229+
230+
If this is `true`, use fallbacks as described in [[#determine-the-url-for-matching-a-document]].
231+
232+
No path is available when the URL to match against falls back to an origin. Therefore, when set, the user agent may treat a [[#key-matches]] with a path other than `/*` as an error.
233+
234+
Defaults to `false`.
235+
236+
### Key `run_at`
237+
238+
Specifies when the content script should be injected. Valid values are defined by the {{RunAt}} enum.
239+
240+
### Key `include_globs`
241+
242+
A list of [=globs=] that a document should match. A document matches if the URL matches both the [[#key-matches]] field and the [[#key-include_globs]] field.
243+
244+
### Key `exclude_globs`
245+
246+
A [=list=] of [=globs=] that can be used to specify URLs where the content script should not run, even if the URL matches entries in [[#key-matches]] and (if specified) [[#key-include_globs]].
247+
248+
### Key `world`
249+
250+
The [=world=] any JavaScript scripts should be injected into. Defaults to `ISOLATED`. Valid values are defined by the {{ExecutionWorld}} enum.
251+
252+
### <dfn>RunAt</dfn> enum
253+
254+
<pre class="idl">
255+
enum RunAt {
256+
"document_start",
257+
"document_end",
258+
"document_idle"
259+
};
260+
</pre>
261+
262+
The {{RunAt}} enum represents when a content script should be injected.
263+
264+
### <dfn>ExecutionWorld</dfn> enum
265+
266+
<pre class="idl">
267+
enum ExecutionWorld {
268+
"ISOLATED",
269+
"MAIN"
270+
};
271+
</pre>
272+
273+
The {{ExecutionWorld}} enum represents a JavaScript [=world=].
194274

195275
## Extension pages
196276

@@ -203,3 +283,51 @@ Issue(62): Specify localization handling.
203283
## Current behavior of cookie partitioning
204284

205285
# Version number handling
286+
287+
# Algorithms
288+
289+
## Determine the URL for matching a document
290+
291+
To determine the URL to use for matching a document, given the document, `match_origin_as_fallback` and `match_about_blank`:
292+
293+
1. Let |url| be the document's URL.
294+
1. If the [=scheme=] of |url| is `http`, `https` or `file`:
295+
1. Return |url|.
296+
1. If the [=scheme=] of |url| is `blob`, `data` or `filesystem`, or if |url| is `about:blank` or `about:srcdoc`:
297+
1. If `match_origin_as_fallback` is set to `true`:
298+
1. If the document's origin is a [=tuple origin=]:
299+
1. Let |document-origin| be the <a href="https://html.spec.whatwg.org/#ascii-serialisation-of-an-origin">serialization</a> of the document's origin.
300+
1. If the [=scheme=] of |document-origin| is `http`, `https` or `file`:
301+
1. Return |document-origin|.
302+
1. Else, return null.
303+
1. Note: If not a [=tuple origin=], the document’s origin is an [=opaque origin=].
304+
1. Let |precursor-origin| be the <a href="https://html.spec.whatwg.org/#ascii-serialisation-of-an-origin">serialization</a> of the document’s precursor origin, if any.
305+
306+
Issue: "precursor origin" concept needs to be specified. It is not in the HTML spec at the moment. At least Chrome and Firefox recognize the concept, see e.g. <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1715167">https://bugzilla.mozilla.org/show_bug.cgi?id=1715167</a>.
307+
1. If the [=scheme=] of |precursor-origin| is `http`, `https` or `file`:
308+
1. Return |precursor-origin|.
309+
1. Else, return null.
310+
1. Else, if `match_about_blank` is set to `true`:
311+
1. If |url| is `about:blank` or `about:srcdoc`:
312+
1. Let |opener| be the active document of document’s [=opener browsing context=].
313+
1. If all of the following conditions are true:
314+
- |opener| is not null
315+
- |opener|’s origin is still the same as the document’s [=opener origin at creation=]
316+
- The algorithm has not been repeated for |opener| yet.
317+
318+
Then repeat the algorithm for |opener|.
319+
1. Return null.
320+
321+
## Inject a content script
322+
323+
Issue: If the same extension specifies the same script twice, what should happen? ([bug](https://crbug.com/324096753))
324+
325+
To determine if a content script should be injected in a document:
326+
327+
1. Let |url| be the result of running [[#determine-the-url-for-matching-a-document]].
328+
1. If the extension does not have access to |url|, return.
329+
1. If |url| is not matched by a match pattern in `matches`, return.
330+
1. If `include_globs` is present and |url| is not matched by any glob pattern, return.
331+
1. If |url| matches an entry in `exclude_matches` or `exclude_globs`, return.
332+
1. If this is a child frame, and `all_frames` is not `true`, return.
333+
1. Otherwise, inject the content script. This should be done based on the `run_at` setting.

specification/webdriver-classic.bs

+6-6
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ Repository: w3c/webextensions
109109
unsupported operation.
110110
<li><p>Let <var>type hint</var> be the result of getting the
111111
property "<code>type</code>" from <var>parameters</var>.
112-
<ol>
113-
<li type='a'><p> If <var>type hint</var> does not have the value of
112+
<ol style="list-style-type: lower-latin">
113+
<li><p> If <var>type hint</var> does not have the value of
114114
"path", "archivePath", or "base64", return
115115
<a href="https://w3c.github.io/webdriver/#dfn-error">error</a>
116116
with <a href="https://w3c.github.io/webdriver/#dfn-error">
117117
error code</a> invalid argument.
118-
<li type='a'><p>If the implementation does not support loading web
118+
<li><p>If the implementation does not support loading web
119119
extensions using <var>type hint</var>, return
120120
<a href="https://w3c.github.io/webdriver/#dfn-error">error</a>
121121
with <a href="https://w3c.github.io/webdriver/#dfn-error">
@@ -128,19 +128,19 @@ Repository: w3c/webextensions
128128
<a href="https://w3c.github.io/webdriver/#dfn-error">error</a>
129129
with <a href="https://w3c.github.io/webdriver/#dfn-error">
130130
error code</a> invalid argument.
131-
<li type='a'><p>If <var>type hint</var> has the value "path" and the
131+
<li><p>If <var>type hint</var> has the value "path" and the
132132
implementation supports loading a web extension given a
133133
path to it's resources, the implementation should load the
134134
extension located at the path stored in "<code>value</code>".
135-
<li type='a'><p>If <var>type hint</var> has the value "archivePath"
135+
<li><p>If <var>type hint</var> has the value "archivePath"
136136
and the implementation supports loading a web extension
137137
given a path to a ZIP of it's resources, the implementation
138138
should extract the ZIP and load the extension located at
139139
the path stored in "<code>value</code>". If this extraction
140140
fails, return <a href="https://w3c.github.io/webdriver/#dfn-error">
141141
error</a> with <a href="https://w3c.github.io/webdriver/#dfn-error">
142142
error code</a> unable to load extension.
143-
<li type='a'><p>If <var>type hint</var> has the value "base64" and the
143+
<li><p>If <var>type hint</var> has the value "base64" and the
144144
implementation supports loading a web extension given a
145145
Base64 encoded string of the ZIP representation of the
146146
extension's resources, the implementation should extract

0 commit comments

Comments
 (0)