はじめに
JavaScriptランタイム環境は、ウェブブラウザ以外にも、特にウェブサーバーやエッジプラットフォームで広く利用されています。その大きな理由のひとつは、JavaScriptがサーバー側とクライアント側の両方で利用できるため、異なるコードベースの部分で必要な専門性を減らし、サーバーとクライアント側でコードの再利用が可能になるからです。
ただし、ウェブブラウザ上で動作するコードがJavaScriptコードの大部分を占めているため、そのようなランタイムがウェブブラウザと同じAPIをサポートしていることが重要です。予想通り、ますます多くのランタイム環境がウェブプラットフォームAPIのサポートを始めています。しかし、こうした環境の増加や採用するウェブプラットフォームAPIの違いにより、環境間の相互運用性が低下する結果となっています。
そこで、このEcma規格では、サーバーサイドやエッジランタイムがウェブ相互運用性を目指す場合に実装すべき、厳選された最小限のウェブプラットフォームAPIサブセットを定義した「最小限共通Web API仕様」を策定します。本規格は2025年スナップショットに対応する第1版であり、毎年追加のスナップショットが公開されます。
1. 対象範囲
本規格は、W3CやWHATWGなどのウェブプラットフォーム規格で定義されたAPIの中から厳選した最小限サブセットとして、2025年スナップショット「最小限共通ウェブプラットフォームAPI」を定義します。これは、ブラウザと非ブラウザJavaScriptベースランタイム環境に共通する最低限の機能を定義することを目的としています。
2. 適合性
最小限共通ウェブプラットフォームAPIの適合実装は、ECMA-262に準拠し、さらに本仕様に記載されたインターフェースおよびプロパティを、対応するW3CまたはWHATWG標準の定義に従って提供しなければなりません。
適合するランタイムは、任意のウェブプラットフォームAPIに対してランタイム固有の拡張を実装することができます。こうした拡張は、いかなるウェブプラットフォームAPIの規定機能と矛盾したり、非適合とならないように定義されなければなりません。こうした拡張の使用は、ランタイム間での相互運用性やコードの移植性を低下させるため、慎重な検討が必要です。
本仕様は、ここに記載された以外のウェブプラットフォームAPIを追加実装することを禁止しません。
注意: 例えば、Performance
APIは、[HR-TIME]仕様で定義された以外にも、[PERFORMANCE-TIMELINE]や[USER-TIMING]仕様で定義された追加メソッドやプロパティで拡張できます。
3. 規定参照
以下の文書は、本書中で参照されており、その一部または全部が本書の要求事項となります。日付付き参照については、記載された版のみが適用されます。日付なし参照については、参照文書の最新版(改訂を含む)が適用されます。
参考文献
規定参考文献
- [COMPRESSION]
- Adam Rice. Compression Standard. Living Standard. URL: https://compression.spec.whatwg.org/
- [CONSOLE]
- Dominic Farolino; Robert Kowalski; Terin Stock. Console Standard. Living Standard. URL: https://console.spec.whatwg.org/
- [DOM]
- Anne van Kesteren. DOM Standard. Living Standard. URL: https://dom.spec.whatwg.org/
- [ECMASCRIPT]
- ECMAScript Language Specification. URL: https://tc39.es/ecma262/multipage/
- [ENCODING]
- Anne van Kesteren. Encoding Standard. Living Standard. URL: https://encoding.spec.whatwg.org/
- [FETCH]
- Anne van Kesteren. Fetch Standard. Living Standard. URL: https://fetch.spec.whatwg.org/
- [FILEAPI]
- Marijn Kruisselbrink. File API. URL: https://w3c.github.io/FileAPI/
- [HR-TIME]
- Yoav Weiss. High Resolution Time. URL: https://w3c.github.io/hr-time/
- [HTML]
- Anne van Kesteren; et al. HTML Standard. Living Standard. URL: https://html.spec.whatwg.org/multipage/
- [RFC7231]
- R. Fielding, Ed.; M. Nottingham, Ed.; J. Reschke, Ed.. HTTP Semantics. June 2022. Internet Standard. URL: https://httpwg.org/specs/rfc9110.html
- [STREAMS]
- Adam Rice; et al. Streams Standard. Living Standard. URL: https://streams.spec.whatwg.org/
- [URL]
- Anne van Kesteren. URL Standard. Living Standard. URL: https://url.spec.whatwg.org/
- [URLPATTERN]
- Ben Kelly; Jeremy Roman; 宍戸俊哉 (Shunya Shishido). URL Pattern Standard. Living Standard. URL: https://urlpattern.spec.whatwg.org/
- [WASM-JS-API-2]
- . Ms2ger. WebAssembly JavaScript Interface. URL: https://webassembly.github.io/spec/js-api/
- [WASM-WEB-API-2]
- . Ms2ger. WebAssembly Web API. URL: https://webassembly.github.io/spec/web-api/
- [WEBCRYPTO]
- Daniel Huigens. Web Cryptography Level 2. URL: https://w3c.github.io/webcrypto/
- [WEBIDL]
- Edgar Chen; Timothy Gu. Web IDL Standard. Living Standard. URL: https://webidl.spec.whatwg.org/
- [XHR]
- Anne van Kesteren. XMLHttpRequest Standard. Living Standard. URL: https://xhr.spec.whatwg.org/
参考参考文献
- [PERFORMANCE-TIMELINE]
- Nicolas Pena Moreno. Performance Timeline. URL: https://w3c.github.io/performance-timeline/
- [USER-TIMING]
- Nicolas Pena Moreno. User Timing Level 3. URL: https://w3c.github.io/user-timing/
4. 用語定義
4.1. ウェブプラットフォーム
ウェブプラットフォームとは、W3CやWHATWGなどの組織によって定義され、ウェブブラウザによって実装された技術規格群の総称です。
4.2. ウェブ相互運用可能ランタイム
本仕様で示されたウェブプラットフォームAPIのサブセットを実装するすべてのECMAScriptベースのアプリケーションランタイム環境。
この用語は、意図的に幅広く定義されており、ウェブブラウザも含みますが、ここでの主な焦点は非ブラウザランタイムの期待事項の提示にあります。
5. 共通API索引
本仕様に準拠するすべてのウェブ相互運用可能ランタイムは、以下のウェブプラットフォームAPIを実装しなければなりません。これらは、ここで修正された場合を除き、規定の要求事項に従って実装する必要があります。規定の要求事項から逸脱する場合(必要性やその他の理由による場合を含む)、その逸脱について明確かつ容易にアクセスできる形でドキュメントに説明を記載しなければなりません。
以下のすべてのインターフェースは、特に本仕様で指定がない限り、globalThis経由でアクセス可能なグローバルオブジェクト上に公開されなければなりません。
以下のすべてのメソッドとプロパティは、特に本仕様で指定がない限り、globalThis経由でアクセス可能なグローバルオブジェクト上に公開されなければなりません。
-
globalThis.clearTimeout()[HTML] -
globalThis.clearInterval()[HTML] -
globalThis.crypto[WEBCRYPTO] -
globalThis.onunhandledrejection[HTML] -
globalThis.onrejectionhandled[HTML] -
globalThis.performance[HR-TIME] -
globalThis.queueMicrotask()[HTML] -
globalThis.reportError()[HTML] -
globalThis.setTimeout()[HTML] -
globalThis.setInterval()[HTML] -
globalThis.structuredClone()[HTML] -
globalThis.WebAssembly.compile()[WASM-JS-API-2] -
globalThis.WebAssembly.compileStreaming()[WASM-WEB-API-2] -
globalThis.WebAssembly.instantiate()[WASM-JS-API-2] -
globalThis.WebAssembly.instantiateStreaming()[WASM-WEB-API-2] -
globalThis.WebAssembly.JSTag[WASM-JS-API-2] -
globalThis.WebAssembly.validate()[WASM-JS-API-2]
ワーカーをサポートするウェブ相互運用可能ランタイムは、onerror,
onunhandledrejection,
onrejectionhandled
および
self
をワーカーのglobalThis上に公開しなければなりません(本仕様で別途指定がない限り)。 [HTML]
6. グローバルスコープ
グローバルスコープ(globalThis)の正確な型はランタイムによって異なります。多くのウェブプラットフォームAPIは、Windowや
WorkerGlobalScope
など、ウェブブラウザ環境で型が明示的に公開されていることを前提に定義されています。適合性を簡素化するため、本仕様で定義されたすべてのインターフェース、メソッド、およびプロパティは、ランタイムの該当するグローバルスコープ(例:globalThis.crypto、globalThis.ReadableStreamなど)上に公開されなければなりません。
多くのランタイムでは、グローバルスコープに新しいプロパティを追加すると、既存のアプリケーションコードと衝突した場合に破壊的変更が発生することがあります。多くのウェブプラットフォームAPIは、
readonly属性
を使用してグローバルプロパティを定義しています。[WEBIDL]
このような破壊的変更を回避するため、本仕様に適合するランタイムは、グローバルスコープに追加されるプロパティに関してreadonly属性を無視することができます。これにより、ランタイムの利用者は既存のアプリケーションコードと衝突する場合、これらのプロパティを削除または上書きすることが可能になります。
Window
やワーカー環境におけるグローバルオブジェクトは、常にEventTarget
のインスタンスであるべきです。ウェブ相互運用可能ランタイムは、例外を報告するアルゴリズムおよびJavaScriptのHostPromiseRejectionTrackerホストフックに従う必要があります([HTML])。これにはグローバルオブジェクト上でerror、
unhandledrejection
およびrejectionhandled
イベントを発火することが含まれます。
レガシーな理由などでグローバルオブジェクトがEventTarget
のインスタンスになれない場合でも、該当イベントはグローバルスコープ上で利用可能な適切な代替メカニズムを通じて発火されなければなりません。このメカニズムは、グローバルオブジェクトがEventTarget
であった場合に提供される情報と同等以上を提供する必要があります。こうしたランタイムはonerror、
onunhandledrejection、
onrejectionhandled
グローバルプロパティをサポートしてはなりません。また、ErrorEvent
やPromiseRejectionEvent
インターフェースの実装は不要です。
注意: 例えば、Node.jsではグローバルオブジェクトはEventTarget
を実装しておらず、該当イベントはglobalThis.processオブジェクト上でuncaughtException、unhandledRejection、rejectionHandledという名前で発火されます。
7. デフォルトUser-Agent値の要件
デフォルト`User-Agent`値は、アプリケーションコードが自身が動作しているランタイムを確実に識別できるよう提供されます。この値は
の構成に準拠した文字列でなければなりません。[RFC7231]:User-Agent
User-Agent = product *( RWS ( product / comment ) ) product = token ["/" product-version] product-version = token
デフォルト`User-Agent`値は、単一かつ完全で不透明な非構造化値として扱うべきです。値は、オプションのproduct-versionを除く単一のproductトークンに制限することが推奨されます。値にはcomment成分を含めてはなりません。
注意:
例えば、navigator.userAgentには'MyRuntime'などを設定できます。
索引
本仕様で定義された用語
- ウェブ相互運用可能ランタイム, in § 4.2
- ウェブプラットフォーム, in § 4.1
他参照で定義された用語
-
[COMPRESSION] で定義されている用語:
- CompressionStream
- DecompressionStream
-
[CONSOLE] で定義されている用語:
- console
-
[DOM] で定義されている用語:
- AbortController
- AbortSignal
- CustomEvent
- Event
- EventTarget
-
[ECMASCRIPT] で定義されている用語:
- globalThis
-
[ENCODING] で定義されている用語:
- TextDecoder
- TextDecoderStream
- TextEncoder
- TextEncoderStream
-
[FETCH] で定義されている用語:
- Headers
- Request
- Response
- default `User-Agent` value
- fetch(input)
-
[FILEAPI] で定義されている用語:
- Blob
- File
-
[HR-TIME] で定義されている用語:
- Performance
- performance
-
[HTML] で定義されている用語:
- ErrorEvent
- MessageChannel
- MessageEvent
- MessagePort
- PromiseRejectionEvent
- Window
- WorkerGlobalScope
- atob(data)
- btoa(data)
- clearInterval(id)
- clearTimeout(id)
- error
- navigator
- onerror (for GlobalEventHandlers)
- onerror (for WorkerGlobalScope)
- onrejectionhandled (for WindowEventHandlers)
- onrejectionhandled (for WorkerGlobalScope)
- onunhandledrejection (for WindowEventHandlers)
- onunhandledrejection (for WorkerGlobalScope)
- queueMicrotask(callback)
- rejectionhandled
- report an exception
- reportError(e)
- self (for Window)
- self (for WorkerGlobalScope)
- setInterval(handler, timeout, ...arguments)
- setTimeout(handler, timeout, ...arguments)
- structuredClone(value, options)
- unhandledrejection
- userAgent
-
[STREAMS] で定義されている用語:
- ByteLengthQueuingStrategy
- CountQueuingStrategy
- ReadableByteStreamController
- ReadableStream
- ReadableStreamBYOBReader
- ReadableStreamBYOBRequest
- ReadableStreamDefaultController
- ReadableStreamDefaultReader
- TransformStream
- TransformStreamDefaultController
- WritableStream
- WritableStreamDefaultController
- WritableStreamDefaultWriter
-
[URL] で定義されている用語:
- URL
- URLSearchParams
-
[URLPATTERN] で定義されている用語:
- URLPattern
-
[WASM-JS-API-2] で定義されている用語:
- CompileError
- Exception
- Global
- Instance
- JSTag
- LinkError
- Memory
- Module
- RuntimeError
- Table
- Tag
- WebAssembly
- compile(bytes)
- instantiate(bytes)
- validate(bytes)
-
[WASM-WEB-API-2] で定義されている用語:
- compileStreaming(source)
- instantiateStreaming(source)
-
[WEBCRYPTO] で定義されている用語:
- Crypto
- CryptoKey
- SubtleCrypto
- crypto
-
[WEBIDL] で定義されている用語:
- DOMException
- read only
-
[XHR] で定義されている用語:
- FormData
Copyright & Software License
Ecma International
Rue du Rhone 114
CH-1204 Geneva
Tel: +41 22 849 6000
Fax: +41 22 849 6001
Web: https://ecma-international.org/
Copyright Notice
© 2025 Ecma International
This draft document may be copied and furnished to others, and derivative works that comment on or otherwise explain it or assist in its implementation may be prepared, copied, published, and distributed, in whole or in part, without restriction of any kind, provided that the above copyright notice and this section are included on all such copies and derivative works. However, this document itself may not be modified in any way, including by removing the copyright notice or references to Ecma International, except as needed for the purpose of developing any document or deliverable produced by Ecma International.
This disclaimer is valid only prior to final version of this document. After approval all rights on the standard are reserved by Ecma International.
The limited permissions are granted through the standardization phase and will not be revoked by Ecma International or its successors or assigns during this time.
This document and the information contained herein is provided on an "AS IS" basis and ECMA INTERNATIONAL DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
Software License
All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.