From e62ab22ba040104afaffd106804d99052e7d9f38 Mon Sep 17 00:00:00 2001 From: patrick kettner Date: Thu, 7 Nov 2024 12:21:07 -0500 Subject: [PATCH] update window.browser spec per #532 (#546) * update window.browser spec per #532 Co-authored-by: Rob Wu --- specification/window.browser.bs | 34 +++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/specification/window.browser.bs b/specification/window.browser.bs index c97f8c80..e4610534 100644 --- a/specification/window.browser.bs +++ b/specification/window.browser.bs @@ -52,6 +52,40 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/ it MUST be used only for WebExtension related functionality. +
+ For backwards compatibility with older versions of WebExtensions that used + chrome as a global identifier for WebExtension related methods, + a UA MAY define a global chrome object that includes all + properties of {{browser}}. + {{browser}} and chrome MAY be direct aliases of each other. + When {{browser}} and chrome are distinct objects, each initial + property of {{browser}} SHOULD be defined on the chrome object, + and each property descriptor on the chrome object SHOULD return + the same value as the corresponding property on the {{browser}} object. + +
+ Here's an example of the expected alias behavior +

+        // 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
+      
+ +
+ + +
   partial interface Window {