@@ -52,6 +52,40 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
52
52
it MUST be used only for WebExtension related functionality.
53
53
</section>
54
54
55
+ <section>
56
+ For backwards compatibility with older versions of WebExtensions that used
57
+ <code> chrome</code> as a global identifier for WebExtension related methods,
58
+ a UA MAY define a global <code> chrome</code> object that includes all
59
+ properties of {{browser}} .
60
+ {{browser}} and <code> chrome</code> MAY be direct aliases of each other.
61
+ When {{browser}} and <code> chrome</code> are distinct objects, each initial
62
+ property of {{browser}} SHOULD be defined on the <code> chrome</code> object,
63
+ and each property descriptor on the <code> chrome</code> object SHOULD return
64
+ the same value as the corresponding property on the {{browser}} object.
65
+
66
+ <div class="example" id="example-1">
67
+ Here's an example of the expected alias behavior
68
+ <pre><code class="lang-js">
69
+ // When `chrome` and `browser` are not direct aliases,
70
+ // modifying one top level values will not change the other:
71
+
72
+ globalThis.browser.FAKE = true
73
+ console.log(globalThis.chrome.FAKE);
74
+ // ^ undefined when chrome and browser are not direct aliases.
75
+ // ^ may be true if browser === chrome.
76
+
77
+ // Individual properties are aliased, so updating a known property
78
+ // directly changes the matching property on the other
79
+ globalThis.browser.runtime.FAKE = 123
80
+
81
+ console.log(globalThis.chrome.runtime.FAKE);
82
+ // 123
83
+ </code></pre>
84
+
85
+ </div>
86
+
87
+
88
+ </section>
55
89
56
90
<pre class="idl">
57
91
partial interface Window {
0 commit comments