In addition to the standard
JavaScript
set of functions (such as
字符串
,
数组
,
对象
,
JSON
, etc), there are a variety of functions available from the DOM to workers. This article provides a list of those.
Workers run in another global context,
DedicatedWorkerGlobalScope
, different from the current window
. By default, methods and properties of
Window
are not available to them, but
DedicatedWorkerGlobalScope
,像
Window
, implements
WindowTimers
and
WindowBase64
.
| 函数 | 功能 | Support in Gecko (Firefox) | Support in IE | Support in Blink (Chrome and Opera) | Support in WebKit (Safari) |
广播通道 API
|
Allows simple communication between 浏览上下文 (that is windows , tabs , frames ,或 iframes ) with the same origin (usually pages from the same site). | 38 (38) | No support | No support | No support |
缓存
|
Cache API provides the ability to programmatically control cache storage associated with current origin. | (Yes) | No support | 43 | ? |
通道消息 API
|
Allows two separate scripts running in different browsing contexts attached to the same document (e.g., two IFrames, or the main document and an IFrame, two documents via a
SharedWorker
, or two workers) to communicate directly via two ports.
|
41 (41) | (Yes) | (Yes) | (Yes) |
控制台 API
|
Provides access to the browser's debugging console (e.g., the Web 控制台 in Firefox). The specifics of how it works vary from browser to browser, but there is a de facto set of features that are typically provided. | 38 (38) | (Yes) | (Yes) | (Yes) |
Crypto
|
Crypto
interface represents basic cryptography features available in the current context. It allows access to a cryptographically strong random number generator and to cryptographic primitives.
|
? | No support | ? | ? |
CustomEvent
|
CustomEvent
interface represents events initialized by an application for any purpose.
|
48 (48) | (Yes) | (Yes) | (Yes) |
Data Store
|
A powerful, flexible storage mechanism for multiple Firefox OS applications to use to store and share data between one another quickly, efficiently, and securely. | Only in Firefox OS internal (certified) applications, since v1.0.1. | No support | No support | No support |
DOMRequest
and
DOMCursor
|
Respectively, these objects represents an ongoing operation (with listeners for reacting to the operation completely successfully, or failing, for example), and an ongoing operation over a list of results. | 41 (41) | ? | ? | ? |
Fetch
|
The Fetch spec provides an up-to-date definition of, and API for, fetching resources (e.g. across the network.) | 39 (39) (mostly in 34 (34) behind pref, although a few features are later.) | No support |
42
41 behind pref |
10.1 |
FileReader
|
This API allows asynchronous read of
Blob
and
File
对象。
|
46 (46) | No support | (Yes) | No support |
FileReaderSync
|
This API allows synchronous read of
Blob
and
File
objects. This is an API that works only in workers.
|
8 (8) | No support | No support | No support |
FormData
|
FormData
objects provide a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the XMLHttpRequest
send()
方法。
|
? (should be in 39 (39)) | ? | (Yes) | ? |
ImageData
|
The underlying pixel data of an area of a
canvas
element. Manipulating such data can be a complex task better suited to be delegated to a Web Worker.
|
25 (25) | No support | No support | No support |
IndexedDB
|
Database to store records holding simple values and hierarchical objects. |
37
(37),
42
(42) for
IDBCursorWithValue
.
|
10.0 | (Yes) | 10.1 |
| 网络信息 API | provides information about the system's connection in terms of general connection type (e.g., 'wifi', 'cellular', etc.). | 53.0 (53) only on mobile | (Yes) only on mobile | No support | No support |
Notifications
|
Allows web pages to control the display of system notifications to the end user | 41 (41) | ? | ? | ? |
性能
|
性能
interface represents timing-related performance information for the given page.
|
34.0 (34.0) | No support | 33.0 | No support |
PerformanceEntry
,
PerformanceMeasure
,
PerformanceMark
,
PerformanceObserver
,
PerformanceResourceTiming
|
Enables retrieval and analysis of detailed data regarding various aspects of an application's network performance. | (Yes) | (Yes) | (Yes) | (Yes) |
Promise
|
JavaScript objects that allow you to write asynchronous functions. | 28 (28) | (Yes) | (Yes) | (Yes) |
| 服务器发送事件 | Allows a server to push data to a web page at any point, after a connection has been opened to it. | 53 (53) (currently only available in dedicated and shared workers; not service workers.) | ? | (Yes) | ? |
ServiceWorkerRegistration
|
You can register a service worker from inside a standard worker, and use associated functionality. | 40 (40) | No support | (Yes) | No support |
TextEncoder
and
TextDecoder
|
创建并返回新的
TextEncoder
, or respectively
TextDecoder
, allowing to encode or decode strings into specific encodings.
|
20 (20) | No support | No support | No support |
URL
|
Workers can use the static methods
URL.createObjectURL
and
URL.revokeObjectURL
with
Blob
objects accesible to the worker.
Workers can also create a new URL using the
URL()
constructor and call any normal method on the returned object.
|
21 (21) and 26 (26) for URL() constructor | No support | No support | No support |
WebGL
with
OffscreenCanvas
|
WebGL (Web Graphics Library) is a JavaScript API for rendering interactive 3D and 2D graphics within any compatible web browser without the use of plug-ins. |
44
(44) behind a feature preference setting. In
about:config
, set
gfx.offscreencanvas.enabled
to true.
|
No support | No support | No support |
WebSocket
|
创建并返回新
WebSocket
object; this mimics the behavior of the standard
WebSocket()
构造函数。
|
37 (37) | 11.0 | (Yes) | (Yes) |
Worker
|
创建新的
Worker
. Yes, workers can spawn more workers.
|
3.5 (1.9.1) | 10.0 | Enabled since Chrome 69 | No support |
WorkerGlobalScope
|
The global scope of workers. This objects defines worker-specific functions . | (Yes) | 10.0 | (Yes) | (Yes) |
WorkerLocation
|
The subset of the
定位
interface available to workers.
|
3.6 (1.9.2) | 10.0 | (Yes) | (Yes) |
WorkerNavigator
|
The subset of the
Navigator
interface available to workers.
|
Basic implementation
(Yes)
appCodeName
,
product
,
taintEnabled()
:
28
(28)
onLine
:
29
(29)
NavigatorLanguage
:
(Yes)
|
appName
,
appVersion
,
onLine
,
platform
,
userAgent
: 10.0
其它: No support |
(Yes) | (Yes) |
XMLHttpRequest
|
创建并返回新
XMLHttpRequest
object; this mimics the behavior of the standard
XMLHttpRequest()
constructor. Note that the
responseXML
and
channel
attributes on
XMLHttpRequest
始终返回
null
.
|
Basic:
3.5
(1.9.1)
|
(Yes) | (Yes) | (Yes) |