Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update window.browser spec per #532 #546

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions specification/window.browser.bs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,38 @@ 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">
// As `chrome` and `browser` are not direct aliases,
// modifying one top level values will not change the other
patrickkettner marked this conversation as resolved.
Show resolved Hide resolved
Comment on lines +69 to +70
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// As `chrome` and `browser` are not direct aliases,
// modifying one top level values will not change the other
// When `chrome` and `browser` are not direct aliases,
// modifying one top level values will not change the other:

Rephrased to avoid the impression that chrome and browser couldn't be direct aliases.


globalThis.browser.FAKE = true
patrickkettner marked this conversation as resolved.
Show resolved Hide resolved
console.log(globalThis.chrome.FAKE); //undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(globalThis.chrome.FAKE); //undefined
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
Loading