diff --git a/specification/index.bs b/specification/index.bs index 9b682f0a1..47fb6b875 100644 --- a/specification/index.bs +++ b/specification/index.bs @@ -9,6 +9,7 @@ Editor: Mukul Purohit, Microsoft Corporation https://www.microsoft.com, mpurohit Editor: Tomislav Jovanovic, Mozilla https://www.mozilla.org/, tjovanovic@mozilla.com Editor: Oliver Dunk, Google https://www.google.com, oliverdunk@chromium.org Abstract: [Placeholder] Abstract. +Repository: w3c/webextensions Markup Shorthands: markdown yes @@ -108,6 +109,8 @@ This key must be present if the `_locales` subdirectory is present, must be abse This key may be present. +Issue: Specify background scripts. For relevant discussion, see https://github.com/w3c/webextensions/issues/282 + ### Key `commands` This key may be present. @@ -158,15 +161,64 @@ The `trial_tokens` key is an optional [=list=] o Filenames beginning with an underscore (`_`) are reserved for use by user agent. -# Isolated worlds +# Execution contexts + +Extensions can execute JavaScript code, in any of the following execution contexts: + +* An extension context is a [=realm=] associated with an [=extension origin=]. +* A privileged extension context is an [=extension context=] with access to the full set of extension APIs available to the extension. For example, the background page or worker defined through [[#key-background]]. +* A content script context is an [=extension context=] and [=isolated world=] with limited access to a subset of extension APIs. This is the default execution environment of all [=content scripts=] of an extension. +* The [=main world=] of a web page not associated with an [=extension origin=] is not an extension context. It does not have access to any extension API, except when an extension allows so through [[#key-externally_connectable]]. + +Some extension APIs may involve the execution of JavaScript code in contexts other than what is specified above. For example, the `userScripts` API allows the creation of `USER_SCRIPT` worlds that are isolated similarly to [=isolated worlds=] but with distinct API availability. + +## Isolated worlds + +A world is a [=realm=] with its own [=global object=]. + +The main world is the [=realm=] whose [=global object=] is the +associated document's {{Window}}, in which the document's own scripts run. +This is the realm implied throughout other specifications that assume a single +realm per document. + +A document may also have a number of [=isolated worlds=], created by the user +agent to run [=content scripts=] in a [=content script context=]. + +An isolated world is a distinct [=realm=] whose [=global object=]'s +interface is {{Window}}, associated with the [=main world=]'s document. The +[=platform objects=] of this realm are distinct from their counterparts in the +[=main world=], but operate on the same underlying state. These operations +should maintain isolation across realms: no object in an [=isolated world=]'s +realm is observable from the [=main world=]. + +
+spec:html; type:dfn; for:realm; text:global object ++ +
+{
+ "webextensions-browser-global": {
+ "authors": [
+ "Patrick Kettner"
+ ],
+ "href": "https://w3c.github.io/webextensions/specification/window.browser.html",
+ "title": "window.browser",
+ "status": "CG-DRAFT",
+ "publisher": "WECG",
+ "deliveredBy": [
+ "https://www.w3.org/groups/cg/webextensions/"
+ ]
+ }
+}
+
diff --git a/specification/window.browser.bs b/specification/window.browser.bs
index e46105343..52621cb0a 100644
--- a/specification/window.browser.bs
+++ b/specification/window.browser.bs
@@ -1,6 +1,6 @@
Title: window.browser -Shortname: wecg-browser +Shortname: webextensions-browser-global Level: 1 Group: wecg Status: w3c/CG-DRAFT