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

Fix globals, part 1: indexedDB #32040

Merged
merged 6 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 4 additions & 5 deletions files/en-us/_redirects.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8643,8 +8643,8 @@
/en-US/docs/Web/API/IDBDatabase/onclose /en-US/docs/Web/API/IDBDatabase/close_event
/en-US/docs/Web/API/IDBDatabase/onerror /en-US/docs/Web/API/IDBTransaction/error_event
/en-US/docs/Web/API/IDBDatabase/onversionchange /en-US/docs/Web/API/IDBDatabase/versionchange_event
/en-US/docs/Web/API/IDBEnvironment.indexedDB /en-US/docs/Web/API/indexedDB
/en-US/docs/Web/API/IDBEnvironment/indexedDB /en-US/docs/Web/API/indexedDB
/en-US/docs/Web/API/IDBEnvironment.indexedDB /en-US/docs/Web/API/Window/indexedDB
/en-US/docs/Web/API/IDBEnvironment/indexedDB /en-US/docs/Web/API/Window/indexedDB
/en-US/docs/Web/API/IDBFactory.cmp /en-US/docs/Web/API/IDBFactory/cmp
/en-US/docs/Web/API/IDBFactory.deleteDatabase /en-US/docs/Web/API/IDBFactory/deleteDatabase
/en-US/docs/Web/API/IDBFactory.open /en-US/docs/Web/API/IDBFactory/open
Expand Down Expand Up @@ -10142,7 +10142,6 @@
/en-US/docs/Web/API/Window/convertPointFromPageToNode /en-US/docs/Web/API/Window/webkitConvertPointFromPageToNode
/en-US/docs/Web/API/Window/crypto /en-US/docs/Web/API/crypto_property
/en-US/docs/Web/API/Window/fetch /en-US/docs/Web/API/fetch
/en-US/docs/Web/API/Window/indexedDB /en-US/docs/Web/API/indexedDB
/en-US/docs/Web/API/Window/minimize /en-US/docs/Web/API/Window
/en-US/docs/Web/API/Window/mozAnimationStartTime /en-US/docs/Web/API/Animation/startTime
/en-US/docs/Web/API/Window/mozPaintCount /en-US/docs/Web/API/Window
Expand Down Expand Up @@ -10250,7 +10249,7 @@
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/createImageBitmap /en-US/docs/Web/API/createImageBitmap
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/crossOriginIsolated /en-US/docs/Web/API/crossOriginIsolated
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch /en-US/docs/Web/API/fetch
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/indexedDB /en-US/docs/Web/API/indexedDB
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/indexedDB /en-US/docs/Web/API/Window/indexedDB
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/isSecureContext /en-US/docs/Web/API/isSecureContext
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/origin /en-US/docs/Web/API/origin
/en-US/docs/Web/API/WindowOrWorkerGlobalScope/queueMicrotask /en-US/docs/Web/API/queueMicrotask
Expand Down Expand Up @@ -10304,7 +10303,6 @@
/en-US/docs/Web/API/WorkerGlobalScope/close /en-US/docs/Web/API/DedicatedWorkerGlobalScope/close
/en-US/docs/Web/API/WorkerGlobalScope/console /en-US/docs/Web/API/console
/en-US/docs/Web/API/WorkerGlobalScope/fetch /en-US/docs/Web/API/fetch
/en-US/docs/Web/API/WorkerGlobalScope/indexedDB /en-US/docs/Web/API/indexedDB
/en-US/docs/Web/API/WorkerGlobalScope/onclose /en-US/docs/Web/API/DedicatedWorkerGlobalScope/close
/en-US/docs/Web/API/WorkerGlobalScope/onerror /en-US/docs/Web/API/WorkerGlobalScope/error_event
/en-US/docs/Web/API/WorkerGlobalScope/onlanguagechange /en-US/docs/Web/API/WorkerGlobalScope/languagechange_event
Expand Down Expand Up @@ -10650,6 +10648,7 @@
/en-US/docs/Web/API/form.submit /en-US/docs/Web/API/HTMLFormElement/submit
/en-US/docs/Web/API/form.target /en-US/docs/Web/API/HTMLFormElement/target
/en-US/docs/Web/API/html.version /en-US/docs/Web/API/HTMLHtmlElement/version
/en-US/docs/Web/API/indexedDB /en-US/docs/Web/API/Window/indexedDB
/en-US/docs/Web/API/mozRTCSessionDescription /en-US/docs/Web/API/RTCSessionDescription
/en-US/docs/Web/API/mozRTCSessionDescription.sdp /en-US/docs/Web/API/RTCSessionDescription/sdp
/en-US/docs/Web/API/mozRTCSessionDescription.type /en-US/docs/Web/API/RTCSessionDescription/type
Expand Down
28 changes: 14 additions & 14 deletions files/en-us/_wikihistory.json
Original file line number Diff line number Diff line change
Expand Up @@ -67230,6 +67230,20 @@
"JesseW"
]
},
"Web/API/Window/indexedDB": {
"modified": "2020-10-15T21:25:18.475Z",
"contributors": [
"sideshowbarker",
"mfluehr",
"fscholz",
"jpmedley",
"nmve",
"arronei",
"chrisdavidmills",
"libbymc",
"teoli"
]
},
"Web/API/Window/innerHeight": {
"modified": "2020-11-20T13:42:29.125Z",
"contributors": [
Expand Down Expand Up @@ -71600,20 +71614,6 @@
"kscarfone"
]
},
"Web/API/indexedDB": {
"modified": "2020-10-15T21:25:18.475Z",
"contributors": [
"sideshowbarker",
"mfluehr",
"fscholz",
"jpmedley",
"nmve",
"arronei",
"chrisdavidmills",
"libbymc",
"teoli"
]
},
"Web/API/isSecureContext": {
"modified": "2020-10-15T21:51:32.759Z",
"contributors": [
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/mozilla/firefox/releases/20/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Firefox 20 was released on April, 2nd 2013. This article provides information ab
- The third, optional, `transfer` argument of {{domxref("Window.postMessage")}} is now supported. It allows to transfer a sequence of [transferable objects](/en-US/docs/Web/API/Web_Workers_API/Transferable_objects) to the destination ([Firefox bug 822094](https://bugzil.la/822094)).
- The non-standard {{domxref("Window.sizeToContent()")}} method now clamps the minimal size: the window cannot be forced anymore to small sizes preventing the user from interacting with ([Firefox bug 764240](https://bugzil.la/764240)).
- Blend modes, such as `overlay`, `color-burn`, `hue`, etc. have been added to the Canvas {{domxref("CanvasRenderingContext2D.globalCompositeOperation")}} property ([Firefox bug 748433](https://bugzil.la/748433)).
- The prefixed version of [`window.indexedDB`](/en-US/docs/Web/API/indexedDB) — `window.mozIndexedDB` — was reintroduced to Gecko, so that bad cross-browser prefixing code (such as `var indexedDB = window.indexedDB || window.webkitIndexedDB …`) doesn't break in Firefox. A better approach is `window.indexedDB = window.indexedDB || window.webkitIndexedDB …` (see [Firefox bug 770844](https://bugzil.la/770844).)
- The prefixed version of [`window.indexedDB`](/en-US/docs/Web/API/Window/indexedDB) — `window.mozIndexedDB` — was reintroduced to Gecko, so that bad cross-browser prefixing code (such as `var indexedDB = window.indexedDB || window.webkitIndexedDB …`) doesn't break in Firefox. A better approach is `window.indexedDB = window.indexedDB || window.webkitIndexedDB …` (see [Firefox bug 770844](https://bugzil.la/770844).)

### SVG

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/mozilla/firefox/releases/38/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Highlights:
- {{domxref("KeyboardEvent.code")}} now supports special keys on Sun keyboards on Linux, Android, and Firefox OS. ([Firefox bug 1020139](https://bugzil.la/1020139))
- The {{domxref("TextEncoder.TextEncoder", "TextEncoder()")}} constructor has been changed to match the spec: when an invalid parameter is passed, the `RangeError` {{domxref("DOMException")}} is now raised, rather than the erroneous {{jsxref("TypeError")}} ([Firefox bug 1125766](https://bugzil.la/1125766)).
- The User Timing API, adding {{domxref("Performance.mark()")}}, {{domxref("Performance.clearMarks()")}}, {{domxref("Performance.measure()")}}, and {{domxref("Performance.clearMeasures()")}} has been implemented ([Firefox bug 782751](https://bugzil.la/782751)).
- The prefixed version of {{domxref("indexedDB")}}, `mozIndexedDB` has been removed ([Firefox bug 975699](https://bugzil.la/975699)).
- The prefixed version of {{domxref("Window.indexedDB")}}, `mozIndexedDB`, has been removed ([Firefox bug 975699](https://bugzil.la/975699)).
- The {{domxref("Document/DOMContentLoaded_event", "DOMContentLoaded")}} event is no longer cancelable ([Firefox bug 1134559](https://bugzil.la/1134559)).
- You can now use [WebSockets](/en-US/docs/Web/API/WebSockets_API) in [Workers](/en-US/docs/Web/API/Web_Workers_API) ([Firefox bug 504553](https://bugzil.la/504553)).
- The {{domxref("XMLHttpRequest.responseType")}} and {{domxref("XMLHttpRequest.withCredentials")}} properties can now be set before calling {{domxref("XMLHttpRequest.open()")}} ([Firefox bug 707484](https://bugzil.la/707484)).
Expand Down
4 changes: 2 additions & 2 deletions files/en-us/web/api/indexeddb_api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ There are a number of web technologies that store data of one kind or another on

## Interfaces

To get access to a database, call [`open()`](/en-US/docs/Web/API/IDBFactory/open) on the [`indexedDB`](/en-US/docs/Web/API/indexedDB) property of a [window](/en-US/docs/Web/API/Window) object. This method returns an {{domxref("IDBRequest")}} object; asynchronous operations communicate to the calling application by firing events on {{domxref("IDBRequest")}} objects.
To get access to a database, call [`open()`](/en-US/docs/Web/API/IDBFactory/open) on the [`indexedDB`](/en-US/docs/Web/API/Window/indexedDB) property of a [window](/en-US/docs/Web/API/Window) object. This method returns an {{domxref("IDBRequest")}} object; asynchronous operations communicate to the calling application by firing events on {{domxref("IDBRequest")}} objects.

### Connecting to a database

- {{domxref("IDBFactory")}}
- : Provides access to a database. This is the interface implemented by the global object {{domxref("indexedDB")}} and is therefore the entry point for the API.
- : Provides access to a database. An object of this type is the value of the global {{domxref("Window.indexedDB")}} and {{domxref("WorkerGlobalScope.indexedDB")}} properties. It is therefore the entry point for the API.
- {{domxref("IDBOpenDBRequest")}}
- : Represents a request to open a database.
- {{domxref("IDBDatabase")}}
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/window/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Note that properties which are objects (e.g., for overriding the prototype of bu
- : This property indicates whether the window is displayed in full screen or not.
- {{domxref("Window.history")}} {{ReadOnlyInline}}
- : Returns a reference to the history object.
- {{domxref("indexedDB", "Window.indexedDB")}} {{ReadOnlyInline}}
- {{domxref("Window.indexedDB")}} {{ReadOnlyInline}}
- : Provides a mechanism for applications to asynchronously access capabilities of indexed databases; returns an {{domxref("IDBFactory")}} object.
- {{domxref("Window.innerHeight")}} {{ReadOnlyInline}}
- : Gets the height of the content area of the browser window including, if rendered, the horizontal scrollbar.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
title: indexedDB global property
title: "Window: indexedDB property"
short-title: indexedDB
slug: Web/API/indexedDB
page-type: web-api-global-property
slug: Web/API/Window/indexedDB
page-type: web-api-instance-property
browser-compat: api.indexedDB
---

{{APIRef("IndexedDB")}}{{AvailableInWorkers}}
{{APIRef("IndexedDB")}}

The global **`indexedDB`** read-only property provides a mechanism for applications to
The **`indexedDB`** read-only property of the {{domxref("Window")}} interface provides a mechanism for applications to
asynchronously access the capabilities of indexed databases.

## Value
Expand Down
22 changes: 6 additions & 16 deletions files/en-us/web/api/workerglobalscope/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ This interface is usually specialized by each worker type: {{domxref("DedicatedW

_This interface inherits properties from the {{domxref("EventTarget")}} interface._

### Standard properties

- {{domxref("caches", "WorkerGlobalScope.caches")}} {{ReadOnlyInline}}
- : Returns the {{domxref("CacheStorage")}} object associated with the current context. This object enables functionality such as storing assets for offline use, and generating custom responses to requests.
- {{domxref("console")}} {{ReadOnlyInline}} {{Non-standard_inline}}
- : Returns the {{domxref("console")}} associated with the worker.
- {{domxref("crossOriginIsolated", "WorkerGlobalScope.crossOriginIsolated")}} {{ReadOnlyInline}}
- : Returns a boolean value that indicates whether the website is in a cross-origin isolation state.
- {{domxref("crypto_property", "WorkerGlobalScope.crypto")}} {{ReadOnlyInline}}
- : Returns the {{domxref("Crypto")}} object associated to the global object.
- {{domxref("WorkerGlobalScope.fonts")}} {{ReadOnlyInline}}
- : Returns the {{domxref("FontFaceSet")}} associated with the worker.
- {{domxref("indexedDB", "WorkerGlobalScope.indexedDB")}} {{ReadOnlyInline}}
- : Provides a mechanism for applications to asynchronously access capabilities of indexed databases; returns an {{domxref("IDBFactory")}} object.
- {{domxref("WorkerGlobalScope.indexedDB")}} {{ReadOnlyInline}}
- : Provides a mechanism for workers to asynchronously access capabilities of indexed databases; returns an {{domxref("IDBFactory")}} object.
- {{domxref("isSecureContext", "WorkerGlobalScope.isSecureContext")}} {{ReadOnlyInline}}
- : Returns a boolean indicating whether the current context is secure (`true`) or not (`false`).
- {{domxref("WorkerGlobalScope.location")}} {{ReadOnlyInline}}
Expand All @@ -44,17 +44,10 @@ _This interface inherits properties from the {{domxref("EventTarget")}} interfac
- {{domxref("WorkerGlobalScope.self")}} {{ReadOnlyInline}}
- : Returns a reference to the `WorkerGlobalScope` itself. Most of the time it is a specific scope like {{domxref("DedicatedWorkerGlobalScope")}}, {{domxref("SharedWorkerGlobalScope")}} or {{domxref("ServiceWorkerGlobalScope")}}.

### Non-standard properties

- {{domxref("console")}} {{ReadOnlyInline}} {{Non-standard_inline}}
- : Returns the {{domxref("console")}} associated with the worker.

## Instance methods

_This interface inherits methods from the {{domxref("EventTarget")}} interface._

### Standard methods

- {{domxref("atob()", "WorkerGlobalScope.atob()")}}
- : Decodes a string of data which has been encoded using base-64 encoding.
- {{domxref("btoa()", "WorkerGlobalScope.btoa()")}}
Expand All @@ -65,6 +58,8 @@ _This interface inherits methods from the {{domxref("EventTarget")}} interface._
- : Cancels the delayed execution set using {{domxref("setTimeout()")}}.
- {{domxref("createImageBitmap()", "WorkerGlobalScope.createImageBitmap()")}}
- : Accepts a variety of different image sources, and returns a {{jsxref("Promise")}} which resolves to an {{domxref("ImageBitmap")}}. Optionally the source is cropped to the rectangle of pixels originating at _(sx, sy)_ with width sw, and height sh.
- {{domxref("WorkerGlobalScope.dump()")}} {{deprecated_inline}} {{non-standard_inline}}
- : Allows you to write a message to stdout — i.e. in your terminal. This is the same as Firefox's {{domxref("window.dump")}}, but for workers.
- {{domxref("fetch()", "WorkerGlobalScope.fetch()")}}
- : Starts the process of fetching a resource from the network.
- {{domxref("WorkerGlobalScope.importScripts()")}}
Expand All @@ -80,11 +75,6 @@ _This interface inherits methods from the {{domxref("EventTarget")}} interface._
- {{domxref("reportError()", "WorkerGlobalScope.reportError()")}}
- : Reports an error in a script, emulating an unhandled exception.

### Non-standard methods

- {{domxref("WorkerGlobalScope.dump()")}} {{deprecated_inline}} {{non-standard_inline}}
- : Allows you to write a message to stdout — i.e. in your terminal. This is the same as Firefox's {{domxref("window.dump")}}, but for workers.

## Events

- {{domxref("WorkerGlobalScope/error_event", "error")}}
Expand Down
49 changes: 49 additions & 0 deletions files/en-us/web/api/workerglobalscope/indexeddb/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: "WorkerGlobalScope: indexedDB property"
short-title: indexedDB
slug: Web/API/WorkerGlobalScope/indexedDB
page-type: web-api-instance-property
browser-compat: api.indexedDB
---

{{APIRef("IndexedDB")}}

The **`indexedDB`** read-only property of the {{domxref("WorkerGlobalScope")}} interface provides a mechanism for workers to
asynchronously access the capabilities of indexed databases.

## Value

An {{domxref("IDBFactory")}} object.

## Examples

The following code creates a request for a database to be opened asynchronously, after
which the database is opened when the request's `onsuccess` handler is fired:

```js
let db;
function openDB() {
const DBOpenRequest = self.indexedDB.open("toDoList");
DBOpenRequest.onsuccess = (e) => {
db = DBOpenRequest.result;
};
}
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- [Using IndexedDB](/en-US/docs/Web/API/IndexedDB_API/Using_IndexedDB)
- Starting transactions: {{domxref("IDBDatabase")}}
- Using transactions: {{domxref("IDBTransaction")}}
- Setting a range of keys: {{domxref("IDBKeyRange")}}
- Retrieving and making changes to your data: {{domxref("IDBObjectStore")}}
- Using cursors: {{domxref("IDBCursor")}}
- Reference example: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications) ([View the example live](https://mdn.github.io/dom-examples/to-do-notifications/)).
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ self.addEventListener("fetch", (event) => {
});
```

In this code example, the shared files are extracted from the form data and the user is redirected to a different page. It's up to you, using the code in your service worker, to handle the extracted files as you want. For example, you can send them to your app's main JavaScript code using the {{domxref("Worker.postMessage()")}} method or store them in an {{domxref("IndexedDB")}} database which can be accessed both by your service worker and app's main JavaScript code.
In this code example, the shared files are extracted from the form data and the user is redirected to a different page. It's up to you, using the code in your service worker, to handle the extracted files as you want. For example, you can send them to your app's main JavaScript code using the {{domxref("Worker.postMessage()")}} method or store them in an [Indexed DB](/en-US/docs/Web/API/IndexedDB_API) database which can be accessed both by your service worker and app's main JavaScript code.

For more information, see the [receiving shared files](/en-US/docs/Web/Manifest/share_target#receiving_shared_files) example on the `share_target` web app manifest member page.

Expand Down
2 changes: 1 addition & 1 deletion files/jsondata/GroupData.json
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@
"IDBVersionChangeEvent"
],
"methods": [],
"properties": ["indexedDB"],
"properties": ["Window.indexedDB", "WorkerGlobalScope.indexedDB"],
"events": []
},
"Ink API": {
Expand Down
Loading