Skip to content

Commit b25688b

Browse files
update window.browser spec per w3c#532
1 parent 77e5045 commit b25688b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

specification/window.browser.bs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,39 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
5252
it MUST be used only for WebExtension related functionality.
5353
</section>
5454

55+
<section>
56+
For backwards compatibility with older versions of web extensions, a UA MAY
57+
alias individual properties of {{browser}} to <code>chrome</code>. {{browser}}
58+
and <code>chrome</code> SHOULD NOT be direct aliases. Instead, individual
59+
subproperties SHOULD be what is alaised. Any modification of a property of
60+
{{browser}} SHOULD be reflected on <code>chrome</code>, and vice versa.
61+
62+
<div class="example" id="example-1">
63+
Here's an example of the expected alias behavior
64+
<pre><code class="lang-js">
65+
// As `chrome` and `browser` are not direct aliases,
66+
// modifying one top level values will not change the other
67+
68+
globalThis.browser.FAKE = true
69+
70+
console.log(globalThis.chrome.FAKE);
71+
// undefined
72+
73+
// Individual properies are aliased, so updating a known property
74+
// directly changes the existing property on the other
75+
globalThis.browser.runtime.FAKE = 123
76+
77+
console.log(globalThis.chrome.runtime.FAKE);
78+
// 123
79+
</code></pre>
80+
81+
</div>
82+
83+
84+
</section>
85+
86+
/e
87+
5588

5689
<pre class="idl">
5790
partial interface Window {

0 commit comments

Comments
 (0)