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

Open
wants to merge 41 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
41 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
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
191 changes: 190 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 interact with not installed 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,187 @@ 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 browser.

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

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

The <dfn export for=commands>webExtension.install</dfn> command installs a web extension for the browser.

<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 |entry| be a [=directory entry=] representing the directory with that |path|.

<dt>|type| is the string "<code>archivePath</code>"
<dd>
1. Let |archive path| be |extension data spec|["<code>path</code>"].
1. Perform implementation defined steps to read |bytes| from a file located at |archive path|.
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. Let |entry| be the result of [=trying=] to [=extract a zip archive=] given |bytes|.

</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. 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.

<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 browser has no web extension with an 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 browser. If this fails, return [=error=] with [=error code=] [=unknown error=].
chrmod marked this conversation as resolved.
Show resolved Hide resolved

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