Skip to content

Determine the nuances of aliasing chrome and browser #532

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

Closed
patrickkettner opened this issue Jan 30, 2024 · 7 comments · Fixed by #546
Closed

Determine the nuances of aliasing chrome and browser #532

patrickkettner opened this issue Jan 30, 2024 · 7 comments · Fixed by #546
Labels
discussion Needs further discussion inconsistency Inconsistent behavior across browsers

Comments

@patrickkettner
Copy link
Contributor

Now that #508 has been merged (🎉), our team began discussing the specifics on how to alias chrome to browser. It turns out, what we want to do is different from everyone, but also everyone is different from everyone.

In Firefox, chrome and browser appear to be clones of the same object. So the values are the same, but updating one does not change another.

browser.foo = 123
console.log(browser.foo)
123
console.log(chrome.foo)
undefined

In Safari, chrome and browser appear to be a direct alias to one another

browser.foo = 123
console.log(browser.foo)
123
console.log(chrome.foo)
123

What Chrome wants to do is make chrome and browser separate objects, but make the various properties of each object a direct alias.

So in the above example, the Firefox behavior would be matched

browser.foo = 123
console.log(browser.foo)
123
console.log(chrome.foo)
undefined

But modifying a specific property or value inside of chrome or browser would update the other.

browser.runtime.PlatformArch.ARM = 123
console.log(browser.runtime.PlatformArch.ARM)
123
console.log(chrome.runtime.PlatformArch.ARM)
123

The reason why we like this option is the mix of ease of implementation from aliasing, while also allowing us to sluff off APIs we do not want to carry forward into browser.

@xeenon xeenon added inconsistency Inconsistent behavior across browsers discussion Needs further discussion and removed needs-triage labels Jan 30, 2024
@xeenon
Copy link
Collaborator

xeenon commented Jan 31, 2024

I see the benefit of having separate namespace objects for each, while sharing everything else internally. However, that would be technically tricky for Safari/WebKit to support. In practice, we don't anticipate the need to have them be separate for us, so we will likely keep our implantation as-is (direct aliases of one another, described above).

@patrickkettner What APIs do you plan to "sluff off" of browser?

@tophf
Copy link

tophf commented Feb 1, 2024

to sluff off APIs we do not want to carry forward into browser.

This implies browser is the successor of chrome and not an alias, which doesn't seem conceptually justified. Edit: although removing junk like csi and loadTimes would indeed make sense as the next comment says.

@hanguokai
Copy link
Member

Screenshot 2024-02-01 at 17 10 00

The reason why we like this option is the mix of ease of implementation from aliasing, while also allowing us to sluff off APIs we do not want to carry forward into browser.

chrome has some non-extension properties, like chrome.loadTimes. This approach allows Chrome to keep chrome for some private APIs, and browser only contains extension-related APIs. IMO, from a practical perspective, whether chrome === browser should not have much impact on developers.

@patrickkettner
Copy link
Contributor Author

@xeenon
> What APIs do you plan to "sluff off" of browser?
I don't have a definitive list, but I would imagine things like loadTimes or csi, that are not Chrome specific (thanks @hanguokai!).

@patrickkettner
Copy link
Contributor Author

During the call outlined in #537, I believe that the following was agreed on

  • chrome.* needs to continue to exists for backcompat with existing extensions in all browsers
  • There should be consistency between browsers with how chrome and browser are aliased
  • deep changes to one, should reflect on the other (e.g. chrome.runtime.foo = "bar" should result in browser.runtime.foo also being "bar"
  • Whether or not chrome.foo = "bar" would automatically make browser.foo === "bar" is left up to the user agent to decide. (With our proposal, this would be false. My understanding was that Firefox was fine with changing to match behavior, but Safari was not interested in changing their strict aliasing as they didn't have anything on chrome they didn't also want on browser)

@oliverdunk @zombie @xeenon @Rob--W is the above true?

@xeenon
Copy link
Collaborator

xeenon commented Feb 2, 2024

Sounds good.

@oliverdunk
Copy link
Member

Sounds good to me.

patrickkettner added a commit to patrickkettner/webextensions that referenced this issue Feb 14, 2024
xeenon pushed a commit that referenced this issue Nov 7, 2024
* update window.browser spec per #532

Co-authored-by: Rob Wu <[email protected]>
zombie added a commit to zombie/webextensions that referenced this issue Apr 16, 2025
* Publish minutes of 2023-05-25 meeting

* Publish minutes of 2023-06-08 meeting

* Publish minutes of 2023-06-22 meeting

* Update chair and editor information

* Update charter.md

Co-authored-by: J. Ryan Stinnett <[email protected]>

* Publish minutes of 2023-07-06 meeting

* Add ReadingList API proposal

* Update affiliations in charter

Modify the Chair and Editor affiliations to match the format described in the [W3C Manual of Style](https://www.w3.org/Guide/manual-of-style/#affs).

* Update URL parameter description in all dictionaries

* Add emoji & calendar link

* Publish minutes of 2023-07-20 meeting

* Create persistence-of-states.md

Add a memo for w3c#424

* Publish minutes of 2023-08-03 meeting

* Update reading_list.md

Updates the schema to reflect the current state of implementation on the readingList api

* Publish minutes of 2023-08-17 meeting

* Update reading_list.md

Updated description for url properties with a brief description with what urls are allowed in the reading list.

Changes OnEntryWillBeRemoved -> OnEntryRemoved

* Remove supportsPromises from the events

* Publish minutes of 2023-08-31 meeting

* Publish minutes of 2023-09-11 TPAC meeting

* Publish minutes of 2023-09-12 TPAC meeting

* Publish minutes of 2023-09-14 meeting

* Publish minutes of 2023-09-28 meeting

* Publish minutes of extra TPAC 2023 meetings

* Publish minutes of 2023-10-12 meeting

* Publish minutes of 2023-10-26 meeting

* Typo fix

* Update table with persistence of APIs

* Fix action.set in MV2

* Publish minutes of 2023-11-09 meeting

* Add sections from TPAC 2023 draft

During TPAC 2023 we held a breakout session to discuss what content we should include in the specification draft. That content was captured in [this google doc][1]. This commit migrates the draft spec outline in that document to our spec file.

[1]: https://docs.google.com/document/d/1q9hQgwTVvyujEhvr52ALeTtuYxyzFhQPfRwPg_hBXlI/edit

* Publish minutes of 2023-11-23 meeting

* action.onUserSettingsChanged proposal

* Publish minutes of 2023-12-07 meeting

* Update index.bs

Co-authored-by: Oliver Dunk <[email protected]>

* Update index.bs

Co-authored-by: Oliver Dunk <[email protected]>

* Change event to use addListener() and removeListener()

* Publish minutes of 2024-01-04 meeting

* Publish minutes of 2024-01-18 meeting

* onUserSettingsChanged returns only the items changed

* update bikeshed build to support multiple bikeshed files

* update window.browser spec

* Publish minutes of 2024-02-01 meeting

* Add content scripts section in specification

* Update .pr-preview.json

update pr-preview config to point to correct location of the specification

* Publish minutes of 2024-02-15 meeting

* Publish minutes of 2024-02-29 meeting

* Add proposal processes (w3c#543)

* Add proposal processes

Add a new proposal process for API changes. This includes a doc describing
the process and a template from which proposals may be made.

* Update the proposal process with feedback from Rob and Timothy.

---------

Co-authored-by: Devlin Cronin <[email protected]>

* Add proposals/README.md

Add a new README file for the proposals subdirectory detailing the
contents of the directory and linking to the new proposal process.

* Update window.browser spec status

* Update Simeon's affiliation

* 2024 time zone switch (PST -> PDT)

* Publish minutes of 2024-03-14 meeting

* Browser-specific needs-triage labels (w3c#562)

* Update labeler.yml

Replace the general "needs-triage" label with browser-specific versions of the needs-triage label.

* Update .github/labeler.yml

* Update .github/labeler.yml

* Update .github/labeler.yml

* Update .github/labeler.yml

Co-authored-by: Rob Wu <[email protected]>

---------

Co-authored-by: Rob Wu <[email protected]>

* Add permissions.requestSiteAccess() API proposal (w3c#529)

* Add permissions.requestSiteAccess() API proposal

* Update existing workaround to be more browser inclusive

* Update proposal based on comment threads

- Update Background section to take into account different browser's behavior
- Update Other Alternatives Considered section to explain in better detailed why Chrome is not supportive of declarative urls

* Add url option parameter and return value

Proposal has been updated so it can fit every browsers model by adding a url option parameter, with this requirements:
- In Chrome, we can require tab ID or document ID, but not `url`.
- In Safari, they can require `url`, but not `tabId` or `documentId`.
- If both are provided, they'll both be respected.

It also adds a method to remove the request and specifies when the methods resolve

* Change title

* Address comments after 02/29 WECG meeting

- Change name to `permissions.addSiteAccessRequest()`
- Fix API comments

* Small typos in proposal

* Add inactive tab behavior

* Apply suggestions from code review

Co-authored-by: Rob Wu <[email protected]>

* Update 'Other alternatives considered' with url pattern usage

---------

Co-authored-by: EmiliaPaz <[email protected]>
Co-authored-by: Rob Wu <[email protected]>

* Add userScripts.execute() API proposal (w3c#540)

* Add userScripts.execute() API proposal

* Apply suggestions from code review

Addressed @Rob--W comments:
  - Add errors property to InjectionResult
  - Nits

Co-authored-by: Rob Wu <[email protected]>

* Minor typos: add commas and remove backticks on browser

---------

Co-authored-by: EmiliaPaz <[email protected]>
Co-authored-by: Rob Wu <[email protected]>

* Indicate some implementors allow JSON comments in manifest.json

* Fix heading levels in specification.

We were using ## as the top level heading but this does not match
the expectation of bikeshed.

* Add guidance on the review expectations of proposals

As we discussed at the in-person WECG meet-up, we should add
expectations around review practices. This PR adds documentation
for those practices.

* Add references to proposing API changes in CONTRIBUTING.md

* Publish minutes of 2024-03-28 meeting

* Address Simeon's comments

* Expand the API proposal to include a "behavior" section

The behavior of certain APIs may not be immediately clear from the
API schema. Add a separate section for "behavior" to allow authors
to specify notes related to the behavior of the API if they are non-
obvious.

* Publish minutes of 2024-04-11 meeting

* Provide guidance on developer feedback in the proposal process

Expand the proposal process to indicate that developer feedback is
desirable and a core part of the proposal process. Merge managers
should ensure developer feedback is carefully considered before
merging proposals.

* Add reference to Code of Conduct in proposal_process.md

* Add ARTIFACT_NAME to w3c/spec-prod invocation

Adds the ARTIFACT_NAME input value to avoid an issue where
conflicting artifacts were added and the workflow would fail.

* Publish minutes of 2024-03-18 - 2024-03-20 meetings in San Diego

* Publish minutes of 2024-04-25 meeting

* Proposal: Multiple user script worlds (w3c#560)

* Proposal: Multiple user script worlds

This adds a new API proposal for supporting multiple user script worlds,
allowing user script managers to better isolate individual user scripts
when multiple may be injected on a given site.

This proposal follows the new API proposal process.

* Address Rob's and Timothy's feedback

* Update diff styling

* Collapse code sections since diffing makes it clear

* Expand API for better world management

Expand the proposal to include:
- Two new functions, `removeWorld()` and `getWorldConfigurations()`.
- Notes about how the worlds behave when injecting.
- Notes on world persistence and world limits.

* Address Rob's latest comments

* Address more review comments

* Fix trailing parenthesis

* Publish minutes of 2024-05-09 meeting

* dark-mode: Add a proposal for dark mode extension icons (w3c#585)

Co-authored-by: Rob Wu <[email protected]>
Co-authored-by: Oliver Dunk <[email protected]>
Co-authored-by: carlosjeurissen <[email protected]>
Co-authored-by: Timothy Hatcher <[email protected]>
Co-authored-by: Simeon Vincent <[email protected]>

* Add proposal for manifest key trial_tokens

* feedback

* feedback

* typos

* Valid json and consistent use of color_scheme

* Use a plural array type like `"permissions"` for simplicity

* Publish minutes of 2024-05-23 meeting

* revise contexMenus persistent state for Firefox and Chrome

* Publish minutes of 2024-06-06 meeting

* Publish minutes of 2024-06-20 meeting

* Add getKeys() proposal

* Fix warning about Node version in triage workflow

* Fix a warning about Node version in deploy workflow

* Update SIDE_PANEL in runtime.getContexts() proposal

Addresses the feedback in w3c#498.

* Update proposals/storage-get-keys.md

Co-authored-by: Rob Wu <[email protected]>

* Update proposals/storage-get-keys.md

Co-authored-by: Rob Wu <[email protected]>

* Update proposals/storage-get-keys.md

Co-authored-by: Rob Wu <[email protected]>

* Update proposals/runtime_get_contexts.md

Co-authored-by: Rob Wu <[email protected]>

* Fix URL in spec

* Publish minutes of 2024-07-04 meeting

* Publish minutes of 2024-07-18 meeting

* Publish minutes of 2024-08-01 meeting

* Publish minutes of 2024-08-15 meeting

* Add developer tools contexts in runtime.getContexts() proposal

* Update link

* Document frameId

* Mention the fields which do not need special handling

* Publish minutes of 2024-08-29 meeting

* Proposal: add hasCrossSiteAncestor value to partitionKey in Cookies API (w3c#581)

Co-authored-by: Rob Wu <[email protected]>
Co-authored-by: Oliver Dunk <[email protected]>
Co-authored-by: bvandersloot-mozilla <[email protected]>

* Publish minutes of 2024-09-12 meeting

* Address feedback

* Clarify behavior of omitting RegisteredUserScript.worldId

* Add type definitions for methods on RegisteredUserScript

* Clarify how userScripts methods are affected

* Publish minutes of 2024-09-26 meeting

* Update minute export tool to support rendered code

Until now, code formatting required backticks in the source document.
But Google Docs can also contain inline code (greenish text) or code
blocks, via Markdown mode (Tools > Preferences > "Enable Markdown").
Previously, this was converted to plain text. With the updated tool,
inline code is wrapped in single backticks, and code blocks are
wrapped in triple backticks.

This also adds h4 support because a recent meeting used h4 headings.

* Publish minutes of 2024-09-23 - 2024-09-27 TPAC meetings

* Fix typo

* Use "may" for behavior of non-wildcard path in match_origin_as_fallback

* Use document rather than frame in inejct a content script algorithm

* Publish minutes of 2024-10-10 meeting

* update window.browser spec per w3c#532 (w3c#546)

* update window.browser spec per w3c#532

Co-authored-by: Rob Wu <[email protected]>

* GetPartitionKey updates (w3c#712)

Co-authored-by: Rob Wu <[email protected]>
Co-authored-by: Oliver Dunk <[email protected]>
Co-authored-by: Heiko Theißen <[email protected]>
Co-authored-by: bvandersloot-mozilla <[email protected]>

* Publish minutes of 2024-11-07 meeting

* Address feedback

* Publish minutes of 2024-11-21 meeting

* Rename addSiteAccessRequest to addHostAccessRequest.

This follows discussion in the last meeting:

w3c#529 (comment)

* Add proposal for runtime.onEnabled and runtime.onExtensionLoaded events

* Add "reload" reason

* Rename event arguments

* Publish minutes of 2024-12-05 meeting

* Rename 'started' load reason to 'startup'

* Publish minutes of 2024-12-19 meeting

* Add hasListener() to event interface

* Fixup 2024-12-19 minutes

* Clarify behavior of userScripts API

- Use empty string instead of unspecified/null as the default worldId,
  following w3c#565 (comment)

- Declare "js" property as optional with remark that it is required in
  "register", to enable `userScripts.update()` without requiring "js".

- Expand on RegisteredUserScript validation, notably on validating
  matches+includeGlobs after an update.

- Update `resetWorldConfiguration()` signature to match Chrome's and
  Firefox's actual implementation: `worldId` is optional.

- Create a new section "World Configurations" and specify world
  configuration behavior more precisely. In particular, clarify fallback
  behavior, following
  w3c#565 (comment)

- Mention Firefox's optional-only "userScripts" permission design.

- Add `worldId` to userScripts.execute proposal.

* Update userScripts.execute() to receive multiple js soruces

Updated as discussed in w3c#477 (comment)

* Address feedback on matching about: frames

* Publish minutes of 2025-01-16 meeting

* Remove a confusing example and add information about split mode incognito contexts

* Use precursor origin terminology in determine URL algorithm

* Apply suggestions from code review

Co-authored-by: Timothy Hatcher <[email protected]>

* Publish minutes of 2025-01-30 meeting

* Clarify repeated firing in split mode incognito contexts

Co-authored-by: Rob Wu <[email protected]>

* Use latest Ubuntu version for GitHub deploy workflow (w3c#757)

Our deploy workflow was failing because it was using an older version of
Ubuntu (which in turn had an older version of Python). Update our YML
configuration to use the latest version.

I considered pinning to a newer version but this matches both our other
workflows and the w3c/spec-prod repo [1] so seems like a better choice.

[1] https://github.com/w3c/spec-prod/blob/main/.github/workflows/docs.yml

* Specification for loading extensions in WebDriver Classic

* Apply suggestions from code review

Co-authored-by: Rob Wu <[email protected]>

* Fix indentation and references

* Publish minutes of 2025-02-13 meeting

* Additional formatting fixes.

* Update specification for loading web extensions in WebDriver Classic

As specified in the BiDi spec, the resource for "path" and "archivePath" should be held in
parameters["path"] and "base64" should be in parameters["value"].

https://www.w3.org/TR/webdriver-bidi/#command-webExtension-install

* Add webdriver-classic.bs to the specs published on GitHub Pages

* Fix HTML validation errors in webdriver-classic.bs

See https://github.com/w3c/webextensions/actions/runs/13446680991/job/37573446021

* Address feedback from Devlin

* Publish minutes of 2025-02-27 meeting

* Publish minutes of 2025-03-13 meeting

* IconVariants: Correct spelling and describe some fallback behavior

* Proposal: i18n-system-languages (w3c#569)

* Add getOSLanguage proposal

* Update proposals/i18n-getOSLanguage.md

Co-authored-by: rdcronin <[email protected]>

* Update proposals/i18n-getOSLanguage.md

Co-authored-by: rdcronin <[email protected]>

* Update workaround description

* Add back Sponsoring Browser with TBD

* Add Bugzilla bug to related issues

* Add Author GitHub link

* Add bcp47 link

* Rephrase objective

* Rename IETF tags to BCP47 language tags

* Remove > from title

* Replace chromium source reference with a permalink

* Update proposals/i18n-getOSLanguage.md

Co-authored-by: Addison Phillips <[email protected]>

* Update proposal to include both getPreferredSystemLanguages and getSystemUILanguage

* Rename proposal file to better reflect the proposal

* Fix proposal title

* Update proposals/i18n-system-languages.md

Co-authored-by: Pavel Djundik <[email protected]>

* Update proposals/i18n-system-languages.md

Co-authored-by: Addison Phillips <[email protected]>

* Clarify the type of list returned by getPreferredSystemLanguages

* Rewrite sentences to use locale instead of language when it makes sense

* Add purest form use-case

* Update proposals/i18n-system-languages.md

Co-authored-by: Simeon Vincent <[email protected]>

* Clarify additional subtags on getSystemUILanguage

* Update getSystemUILanguage to be async

* Clarify getPreferredSystemLanguages callback parameter

* Clarify getPreferredSystemLanguages would not insert less specific locale tags

* Remove additional subtags note on getSystemUILanguage

* Update proposals/i18n-system-languages.md

Co-authored-by: Rob Wu <[email protected]>

* Update proposals/i18n-system-languages.md

Co-authored-by: Rob Wu <[email protected]>

* Update proposals/i18n-system-languages.md

Co-authored-by: Rob Wu <[email protected]>

* Fix sync > async. Address language > locale

---------

Co-authored-by: rdcronin <[email protected]>
Co-authored-by: Addison Phillips <[email protected]>
Co-authored-by: Pavel Djundik <[email protected]>
Co-authored-by: Simeon Vincent <[email protected]>
Co-authored-by: Rob Wu <[email protected]>

* fixup webdriver-classic: drop "type" from li

Markup validation fails due to:

> The “type” attribute on the “li” element is obsolete. Use CSS instead.

The `<ol>` that this `<li>` is part of already has
`list-style-type:lower-latin`, which means that the `type='a'` attribute
can be dropped without replacement.

* Publish minutes of 2025-03-27 meeting

---------

Co-authored-by: Rob Wu <[email protected]>
Co-authored-by: Simeon Vincent <[email protected]>
Co-authored-by: Simeon Vincent <[email protected]>
Co-authored-by: J. Ryan Stinnett <[email protected]>
Co-authored-by: dljames <[email protected]>
Co-authored-by: Darryl James <[email protected]>
Co-authored-by: Jackie(Guokai) Han <[email protected]>
Co-authored-by: Oliver Dunk <[email protected]>
Co-authored-by: EmiliaPaz <[email protected]>
Co-authored-by: Emilia Paz <[email protected]>
Co-authored-by: Patrick Kettner <[email protected]>
Co-authored-by: rdcronin <[email protected]>
Co-authored-by: Devlin Cronin <[email protected]>
Co-authored-by: Solomon Kinard <[email protected]>
Co-authored-by: Oliver Dunk <[email protected]>
Co-authored-by: carlosjeurissen <[email protected]>
Co-authored-by: Timothy Hatcher <[email protected]>
Co-authored-by: Anton Bershanskiy <[email protected]>
Co-authored-by: Mukul P <[email protected]>
Co-authored-by: Daniel Jacobs <[email protected]>
Co-authored-by: Luke Warlow <[email protected]>
Co-authored-by: Sohail Rajdev <[email protected]>
Co-authored-by: Aaron Selya <[email protected]>
Co-authored-by: bvandersloot-mozilla <[email protected]>
Co-authored-by: Heiko Theißen <[email protected]>
Co-authored-by: Sohail Rajdev <[email protected]>
Co-authored-by: Kiara Rose <[email protected]>
Co-authored-by: Timothy Hatcher <[email protected]>
Co-authored-by: Sam Sneddon <[email protected]>
Co-authored-by: kiaraarose <[email protected]>
Co-authored-by: Addison Phillips <[email protected]>
Co-authored-by: Pavel Djundik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Needs further discussion inconsistency Inconsistent behavior across browsers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants