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

update window.browser spec per #532 #546

Merged
merged 7 commits into from
Nov 7, 2024
Merged
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions specification/window.browser.bs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,40 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
it MUST be used only for WebExtension related functionality.
</section>

<section>
For backwards compatibility with older versions of WebExtensions that used
<code>chrome</code> as a global identifier for WebExtension related methods,
a UA MAY define a global <code>chrome</code> object that includes all
properties of {{browser}}.
{{browser}} and <code>chrome</code> MAY be direct aliases of each other.
When {{browser}} and <code>chrome</code> are distinct objects, each initial
property of {{browser}} SHOULD be defined on the <code>chrome</code> object,
and each property descriptor on the <code>chrome</code> object SHOULD return
the same value as the corresponding property on the {{browser}} object.

<div class="example" id="example-1">
Here's an example of the expected alias behavior
<pre><code class="lang-js">
// When `chrome` and `browser` are not direct aliases,
// modifying one top level values will not change the other:

globalThis.browser.FAKE = true
patrickkettner marked this conversation as resolved.
Show resolved Hide resolved
console.log(globalThis.chrome.FAKE);
// ^ undefined when chrome and browser are not direct aliases.
// ^ may be true if browser === chrome.

// Individual properties are aliased, so updating a known property
// directly changes the matching property on the other
globalThis.browser.runtime.FAKE = 123

console.log(globalThis.chrome.runtime.FAKE);
// 123
</code></pre>

</div>


</section>

<pre class="idl">
partial interface Window {
Expand Down
Loading