Introduction
This section is non-normative.Browser extensions are programs to extend the capabilities of web browsers. Although not standardized at first, web browsers have independently implemented a common interoperable set of extension APIs, called WebExtensions.
Modern WebExtensions are an evolution of a system originally introduced in
Chromium. In that system, any API that was added was put under the chrome
namespace. When WebExtensions were adopted outside of
Chromium, other vendors used the more neutral browser
namespace.
That browser
is now considered the canonically correct namespace
for all WebExtension APIs. Some interactions with WebExtensions (such as
external messaging from websites to background processes) necessitate
the exposure of this namespace to the web.
Given that, this document defines window.browser
as reserved for
the use of APIs designed to interact with WebExtensions. The specifics of what
APIs within window.browser
are at present intentionally undefined,
and are left up to User Agent implementation.
window.browser
API
browser
is UA defined attribute exposed on window
. When implemented,
it MUST be used only for WebExtension related functionality.
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.
// 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 {attribute object ; };
browser
Worker API
When browser
is defined on window
, it SHOULD also be exposed on ServiceWorkerGlobalScope
of origins associated with WebExtensions.
It MUST be used exclusively for WebExtension purposes, however the contents of each instance of browser
is UA defined.
partial interface ServiceWorkerGlobalScope {attribute object ; };
browser