Skip to content

Commit

Permalink
update window.browser spec per #532 (#546)
Browse files Browse the repository at this point in the history
* update window.browser spec per #532

Co-authored-by: Rob Wu <[email protected]>
  • Loading branch information
patrickkettner and Rob--W authored Nov 7, 2024
1 parent 0bcc7db commit e62ab22
Showing 1 changed file with 34 additions and 0 deletions.
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
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

0 comments on commit e62ab22

Please sign in to comment.