From b25688bceb91d46246a070e838eed1ddba015a82 Mon Sep 17 00:00:00 2001 From: Patrick Kettner Date: Wed, 14 Feb 2024 17:16:03 -0500 Subject: [PATCH 1/5] update window.browser spec per #532 --- specification/window.browser.bs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/specification/window.browser.bs b/specification/window.browser.bs index 3dbbe9b8..f540c767 100644 --- a/specification/window.browser.bs +++ b/specification/window.browser.bs @@ -52,6 +52,39 @@ 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 web extensions, a UA MAY + alias individual properties of {{browser}} to chrome. {{browser}} + and chrome SHOULD NOT be direct aliases. Instead, individual + subproperties SHOULD be what is alaised. Any modification of a property of + {{browser}} SHOULD be reflected on chrome, and vice versa. + +
+ Here's an example of the expected alias behavior +

+        // As `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
+
+        // Individual properies are aliased, so updating a known property
+        // directly changes the existing property on the other
+        globalThis.browser.runtime.FAKE = 123
+
+        console.log(globalThis.chrome.runtime.FAKE);
+        // 123
+      
+ +
+ + +
+ +/e +
   partial interface Window {

From c57bb2d4a862bb56cff35776d28a283de685ba54 Mon Sep 17 00:00:00 2001
From: Patrick Kettner 
Date: Wed, 21 Feb 2024 14:22:14 -0500
Subject: [PATCH 2/5] updates from review

---
 specification/window.browser.bs | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/specification/window.browser.bs b/specification/window.browser.bs
index f540c767..a9458605 100644
--- a/specification/window.browser.bs
+++ b/specification/window.browser.bs
@@ -53,11 +53,13 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
   
 
   
- For backwards compatibility with older versions of web extensions, a UA MAY - alias individual properties of {{browser}} to chrome. {{browser}} - and chrome SHOULD NOT be direct aliases. Instead, individual - subproperties SHOULD be what is alaised. Any modification of a property of - {{browser}} SHOULD be reflected on chrome, and vice versa. + For backwards compatibility with older versions of WebExtensions that used + chrome as a global identifier for WebExtension related methods, + a UA MAY alias individual properties of {{browser}} to chrome. + {{browser}} and chrome SHOULD NOT be direct aliases. Instead, + individual subproperties SHOULD be alaised. Any modification of a property + of {{browser}} SHOULD be reflected on the same subproperty of chrome, + and vice versa.
Here's an example of the expected alias behavior @@ -66,12 +68,10 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/ // modifying one top level values will not change the other globalThis.browser.FAKE = true - - console.log(globalThis.chrome.FAKE); - // undefined + console.log(globalThis.chrome.FAKE); //undefined // Individual properies are aliased, so updating a known property - // directly changes the existing property on the other + // directly changes the matching property on the other globalThis.browser.runtime.FAKE = 123 console.log(globalThis.chrome.runtime.FAKE); @@ -83,9 +83,6 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
-/e - -
   partial interface Window {
    attribute object browser;

From 1242bd72a065ba226a36ec8ae7339ebbdb8ab11f Mon Sep 17 00:00:00 2001
From: patrick kettner 
Date: Mon, 26 Feb 2024 17:49:45 -0500
Subject: [PATCH 3/5] Update specification/window.browser.bs

Co-authored-by: Rob Wu 
---
 specification/window.browser.bs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/specification/window.browser.bs b/specification/window.browser.bs
index a9458605..8b98f8de 100644
--- a/specification/window.browser.bs
+++ b/specification/window.browser.bs
@@ -70,7 +70,7 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
         globalThis.browser.FAKE = true
         console.log(globalThis.chrome.FAKE); //undefined
 
-        // Individual properies are aliased, so updating a known property
+        // Individual properties are aliased, so updating a known property
         // directly changes the matching property on the other
         globalThis.browser.runtime.FAKE = 123
 

From fb291321a00212d20bbc1293ee2741572c096f47 Mon Sep 17 00:00:00 2001
From: patrick kettner 
Date: Thu, 7 Mar 2024 09:36:40 -0500
Subject: [PATCH 4/5] Update specification/window.browser.bs

Co-authored-by: Rob Wu 
---
 specification/window.browser.bs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/specification/window.browser.bs b/specification/window.browser.bs
index 8b98f8de..0aa7db60 100644
--- a/specification/window.browser.bs
+++ b/specification/window.browser.bs
@@ -55,7 +55,8 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/
   
For backwards compatibility with older versions of WebExtensions that used chrome as a global identifier for WebExtension related methods, - a UA MAY alias individual properties of {{browser}} to chrome. + a UA MAY define a global chrome object that includes all + properties of {{browser}}. {{browser}} and chrome SHOULD NOT be direct aliases. Instead, individual subproperties SHOULD be alaised. Any modification of a property of {{browser}} SHOULD be reflected on the same subproperty of chrome, From a154385c720a4f20bcf183456f6cfddeaae099a6 Mon Sep 17 00:00:00 2001 From: patrick kettner Date: Thu, 7 Mar 2024 09:37:15 -0500 Subject: [PATCH 5/5] Update specification/window.browser.bs Co-authored-by: Rob Wu --- specification/window.browser.bs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/specification/window.browser.bs b/specification/window.browser.bs index 0aa7db60..cfc05485 100644 --- a/specification/window.browser.bs +++ b/specification/window.browser.bs @@ -57,10 +57,11 @@ spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/ 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 SHOULD NOT be direct aliases. Instead, - individual subproperties SHOULD be alaised. Any modification of a property - of {{browser}} SHOULD be reflected on the same subproperty of chrome, - and vice versa. + {{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