Skip to content
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

webExtension module #778

Merged
merged 49 commits into from
Nov 29, 2024
Merged
Changes from 47 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
0fd6fcd
WebExtension installation
chrmod Sep 18, 2024
e051e81
Reorganise into Extension module
chrmod Oct 2, 2024
a541d6c
Update index.bs
chrmod Oct 8, 2024
064f4d2
Simplify expand a install path spec
chrmod Oct 8, 2024
d5d88a6
fixing InstallResult type definition
chrmod Oct 9, 2024
5f8b9d8
Rename module to WebExtensions
chrmod Oct 11, 2024
fb1ec9b
Remove Extension wrapper type
chrmod Oct 11, 2024
66d024d
Fix typo
chrmod Oct 11, 2024
4b54f21
Rename extensionId
chrmod Oct 11, 2024
59e7979
Better error handing
chrmod Oct 11, 2024
990dc7b
addressing PR comments
chrmod Oct 11, 2024
6c19ea1
Use directory-entry instead of the ExtesnionArchive
chrmod Oct 11, 2024
aef6dea
Cleanup
chrmod Oct 11, 2024
1b52bf0
Update index.bs
chrmod Oct 22, 2024
ca0a49a
Update index.bs
chrmod Oct 22, 2024
bbd1208
Update index.bs
chrmod Oct 22, 2024
25fa95c
Apply suggestions from code review
chrmod Oct 22, 2024
147928d
Apply suggestions from code review
chrmod Oct 22, 2024
20f13dd
ExtensionData type
chrmod Oct 22, 2024
7906a4c
replace switch with if set
chrmod Oct 22, 2024
9c72317
Extract extension type
chrmod Oct 22, 2024
1a8efb5
Fix naming
chrmod Oct 22, 2024
f3044c8
Define webExtensions.uninstall
chrmod Oct 22, 2024
b54f1a8
fix
chrmod Oct 22, 2024
72c5dfe
Move expand a web extension data spec to a better place
chrmod Oct 22, 2024
364257b
fix typo
chrmod Oct 22, 2024
8298905
Fix name
chrmod Oct 23, 2024
d5d20a1
Update index.bs
chrmod Oct 25, 2024
78bfd47
Remove allowPrivateBrowsing
chrmod Oct 25, 2024
fc8c6d1
Remove manifest validation
chrmod Oct 25, 2024
1b0ce83
Update index.bs
chrmod Oct 30, 2024
2813d21
Update index.bs
chrmod Oct 30, 2024
a83badb
Update index.bs
chrmod Oct 30, 2024
1916883
Apply suggestions from code review
chrmod Nov 12, 2024
afc9072
Make module name sigular
chrmod Nov 12, 2024
bca7d14
new error code for not install extension
chrmod Nov 12, 2024
e9099c2
Reorder algorithms
chrmod Nov 12, 2024
e583028
Update index.bs
chrmod Nov 13, 2024
42570bc
Use browser instead of the session
chrmod Nov 13, 2024
e683f60
Apply suggestions from code review
chrmod Nov 15, 2024
edfa91f
Define extact from zip
chrmod Nov 15, 2024
5ddb11e
Update index.bs
chrmod Nov 28, 2024
58ea10d
Apply jgraham's patch
chrmod Nov 28, 2024
97ed7ea
Replace local end with remote end
chrmod Nov 28, 2024
e7957f0
Fix base64 error handling
chrmod Nov 28, 2024
000ce14
fix path name
chrmod Nov 28, 2024
14670b5
remove patch file
chrmod Nov 28, 2024
b877da6
Update index.bs
chrmod Nov 28, 2024
0c770e2
Update index.bs
chrmod Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 198 additions & 1 deletion index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,9 @@ WebDriver BiDi extends the set of [=error codes=] from [[WEBDRIVER|WebDriver]]
with the following additional codes:

<dl>
<dt><dfn for=errors export>invalid web extension</dfn>
<dd>Tried to install an invalid web extension.

<dt><dfn for=errors export>no such client window</dfn>
<dd>Tried to interact with an unknown [=client window=].

Expand Down Expand Up @@ -630,6 +633,9 @@ with the following additional codes:
<dt><dfn for=errors export>no such user context</dfn>
<dd>Tried to reference an unknown [=user context=].

<dt><dfn for=errors export>no such web extension</dfn>
<dd>Tried to reference an unknown web extension.

<dt><dfn for=errors export>unable to close browser</dfn>
<dd>Tried to close the browser, but failed to do so.

Expand All @@ -647,6 +653,7 @@ with the following additional codes:
ErrorCode = "invalid argument" /
"invalid selector" /
"invalid session id" /
"invalid web extension" /
"move target out of bounds" /
"no such alert" /
"no such element" /
Expand All @@ -659,6 +666,7 @@ ErrorCode = "invalid argument" /
"no such script" /
"no such storage partition" /
"no such user context" /
"no such web extension" /
"session not created" /
"unable to capture screen" /
"unable to close browser" /
Expand Down Expand Up @@ -2146,7 +2154,7 @@ To <dfn>set the client window state</dfn> given |window| and |state|:

1. If |current state| is equal to |state|, return [=success=] with data null.

1. Switch on the value of |state|:
1. In the following list of conditions and associated steps, run the first set of steps for which the associated condition is true:

<dl>
<dt>"<code>fullscreen</code>"
Expand Down Expand Up @@ -11346,6 +11354,195 @@ The [=remote end steps=] given |session| and |command parameters| are:
</div>


## The webExtension Module ## {#module-webExtension}
chrmod marked this conversation as resolved.
Show resolved Hide resolved

The <dfn export for=modules>webExtension</dfn> module contains functionality for
managing and interacting with web extensions.

### Definition ### {#module-webExtension-definition}

[=remote end definition=]

<pre class="cddl remote-cddl">
WebExtensionsCommand = (
webExtension.Install,
webExtension.Uninstall
)
</pre>

[=local end definition=]

<pre class="cddl local-cddl">
WebExtensionsResult = (
webExtension.InstallResult
)
</pre>

### Types ### {#module-webExtension-types}

#### The webExtension.Extension Type #### {#type-webExtension-Extension}

<pre class="cddl remote-cddl local-cddl">
webExtension.Extension = text
</pre>

The <code>webExtension.Extension</code> type represents a web extension id within a [=remote end=].

### Commands ### {#module-webExtension-commands}

#### The webExtension.install Command #### {#command-webExtension-install}

The <dfn export for=commands>webExtension.install</dfn> command installs a web extension in the [=remote end=].

<dl>
<dt>Command Type</dt>
<dd>
<pre class="cddl remote-cddl">
webExtension.Install = (
method: "webExtension.install",
params: webExtension.InstallParameters
)

webExtension.InstallParameters = {
extensionData: webExtension.ExtensionData,
}
whimboo marked this conversation as resolved.
Show resolved Hide resolved

webExtension.ExtensionData = (
webExtension.ExtensionArchivePath /
webExtension.ExtensionBase64Encoded /
webExtension.ExtensionPath
)
whimboo marked this conversation as resolved.
Show resolved Hide resolved

webExtension.ExtensionPath = {
type: "path",
path: text,
}

webExtension.ExtensionArchivePath = {
type: "archivePath",
path: text,
}

webExtension.ExtensionBase64Encoded = {
type: "base64",
value: text,
}
</pre>
</dd>
<dt>Result Type</dt>
<dd>
<pre class="cddl local-cddl">
webExtension.InstallResult = {
extension: webExtension.Extension
}
</pre>
</dd>
</dl>

<div algorithm>
To <dfn>extract a zip archive</dfn> given |bytes|:

1. Perform implementation defined steps to decode |bytes| using the zip compression algorithm. TODO: Find a better reference for zip decoding.

1. If the previous step failed (e.g. because |bytes| did not represent valid zip-compressed data) then return [=error=] with error code [=invalid web extension=]. Otherwise let |entry| be a [=directory entry=] containing the extracted filesystem entries.

1. Return |entry|.

</div>

<div algorithm>
To <dfn>expand a web extension data spec</dfn> given |extension data spec|:
chrmod marked this conversation as resolved.
Show resolved Hide resolved

1. Let |type| be |extension data spec|["<code>type</code>"].

1. If installing a web extension using |type| isn't supported return [=error=] with [=error code=] [=unsupported operation=].

1. In the following list of conditions and associated steps, run the first set of steps for which the associated condition is true:

<dl>
<dt>|type| is the string "<code>path</code>"
<dd>
1. Let |path| be |extension data spec|["<code>path</code>"].
1. Let |locator| be a [=directory locator=] with [=file system locator/path=] |path| and [=file system locator/root=] corresponding to the root of the file system.
1. Let |entry| be [=locate an entry=] given |locator|.

<dt>|type| is the string "<code>archivePath</code>"
<dd>
1. Let |archive path| be |extension data spec|["<code>path</code>"].
1. Let |locator| be a [=file locator=] with [=file system locator/path=] |archive path| and [=file system locator/root=] corresponding to the root of the file system.
1. Let |archive entry| be [=locate an entry=] given |locator|.
1. If |archive entry| is null, return null.
1. Let |bytes| be |archive entry|'s [=file entry/binary data=].
1. Let |entry| be the result of [=trying=] to [=extract a zip archive=] given |bytes|.

<dt>|type| is the string "<code>base64</code>"
<dd>
1. Let |bytes| be [=forgiving-base64 decode=] |extension data spec|["<code>path</code>"].
1. If |bytes| is failure, return null.
1. Let |entry| be the result of [=trying=] to [=extract a zip archive=] given |bytes|.
1. If |entry| is failure, return null.
chrmod marked this conversation as resolved.
Show resolved Hide resolved

</dl>

1. Return |entry|.

</div>

<div algorithm="remote end steps for webExtension.install">
The [=remote end steps=] with |command parameters| are:

1. If installing web extensions isn't supported return [=error=] with error code [=unsupported operation=].

1. Let |extension data spec| be |command parameters|["<code>extensionData</code>"].

1. Let |extension directory entry| be the result of [=trying=] to [=expand a web extension data spec=] with |extension data spec|.

1. If extension directory entry| is null, return [=error=] with [=error code=] [=invalid web extension=].

1. Perform implementation defined steps to install a web extension from |extension directory entry|. If this fails, return [=error=] with [=error code=] [=invalid web extension=]. Otherwise let |extension id| be the unique identifier of the newly installed web extension.

1. Let |result| be a [=/map=] matching the
chrmod marked this conversation as resolved.
Show resolved Hide resolved
<code>webExtension.InstallResult</code> production with the
<code>extension</code> field set to |extension id|.

1. Return [=success=] with data |result|.

</div>


#### The webExtension.uninstall Command #### {#command-webExtension-uninstall}

The <dfn export for=commands>webExtension.uninstall</dfn> command uninstalls a web extension for the browser.
chrmod marked this conversation as resolved.
Show resolved Hide resolved

<dl>
<dt>Command Type</dt>
<dd>
<pre class="cddl remote-cddl">
webExtension.Uninstall = (
method: "webExtension.uninstall",
params: webExtension.UninstallParameters
)

webExtension.UninstallParameters = {
extension: webExtension.Extension,
}
</pre>
</dd>
</dl>

<div algorithm="remote end steps for webExtension.uninstall">
The [=remote end steps=] with |command parameters| are:

1. Let |extension| be |command parameters|["<code>extension</code>"].

1. If the [=remote end=] has no web extension with id equal to |extension|, return [=error=] with [=error code=] [=no such web extension=].

1. Perform any implementation-defined steps to remove the web extension from the [=remote end=]. If this fails, return [=error=] with [=error code=] [=unknown error=].

1. Return [=success=] with data null.

</div>

# Patches to Other Specifications # {#patches}

This specification requires some changes to external specifications to provide the necessary
Expand Down