[8] [[文書]]は、[DFN[[F[[RUBYB[[[起源]]]@en[origin]]]]]]を持ちます。

* 仕様書

[REFS[
- [3] '''[CITE@en-US[DOM Standard]] ([TIME[2014-09-14 14:03:21 +09:00]] 版) <https://dom.spec.whatwg.org/#dom-document-origin>'''
- [253] [CITE@en-US[DOM Standard]] ([TIME[2012-12-20 16:17:48 +09:00]] 版) <http://dom.spec.whatwg.org/#concept-document>
- [135] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#origin>
- [127] [CITE@en-US-x-hixie[HTML Standard]] ([TIME[2012-02-22 20:11:59 +09:00]] 版) <http://www.whatwg.org/specs/web-apps/current-work/#windows>
- [69] [CITE@en-GB-x-hixie[HTML Standard]] ([TIME[2014-10-14 21:54:07 +09:00]] 版) <https://html.spec.whatwg.org/#environment-settings-object>
- [20] [CITE@en[Service Workers Nightly]] ([TIME[2017-02-16 20:10:49 +09:00]]) <https://w3c.github.io/ServiceWorker/#service-worker-client-concept>
]REFS]

* 文書の起源

[9] [[文書]]は、[F[起源]]を持ちます [SRC[>>253]]。
これは、色々な操作で[[セキュリティー]]検査のために使われます。

;; [[起源]]も参照。

[HISTORY[
[10] かつては他に[F[実効スクリプト起源]]もありましたが、[F[起源][文書の起源]]と統合されました。
]HISTORY]

[6] [[文書の[F[起源]]]]の[[オブジェクト]]は、作成時に定まります。
その後変更されることはありません。
ただし [CODE(JS)@en[document.domain]] の設定によりオブジェクトが編集されることはあります。

;; [28] 
[[新しい閲覧文脈を作成]]する手順群,
[CODE(DOMi)@en[Document]] の作成の項、[[navigate]] の項、
[CODE(JS)@en[document.domain]] の項を参照。

[32] 
基本的には[[文書の[VAR[起源]]]]はそれが由来する[[サーバー]]の[[起源]]になります。
[CODE[about:blank]] 
の扱いなど例外も色々あります。


[HISTORY[
[30] 
[[文書の[F[起源]]]]は、
[CITE[DOM Standard]]
や
[CITE[HTML Standard]]
で[[規定]]されています。
[[Webセキュリティー]]モデルの基本中の基本であるため
[CITE[HTML5]]
のかなり初期に規定されましたが、
その後いろいろな操作に関する規定が整備された結果、
古いスタイルと新しいスタイルの規定が入り乱れて分かりにくくなっていました。

[31] 
[TIME[令和元(2019)年][2019]]の
[CITE[HTML Standard]]
の改訂で整理され、
かなりわかりやすくなりました。
[SEE[ [[起源を決定]] ]]
]HISTORY]



* 環境設定群オブジェクトの起源

[71] [[スクリプト]]を介した色々な操作のアクセス制御が[[同一起源ポリシー]]によって行われます。
その時、
[[環境設定群オブジェクト]]の[DFN[[F[起源]]]] [SRC[>>69]]
が参照されることがあります。

[HISTORY[
[70] これらは以前は「[[スクリプト]]の[[起源]]」などと呼ばれていたこともありました。

;; [[環境設定群オブジェクト]]の歴史の項も参照。
]HISTORY]

[72] [[環境設定群オブジェクト]]の[F[起源]]は、
その作成時に決まります。

;; [[環境設定群オブジェクト]]参照。

[21] [[サービスワーカークライアント]][VAR[クライアント]]の[DFN[[F[[RUBYB[[[起源][環境設定群オブジェクトの起源]]]@en[origin]]]]]]は、
次のものです [SRC[>>20]]。

[FIG(steps)[
= [22] [VAR[クライアント]]が[[環境]]の場合、
== [23] [VAR[クライアント]]の[F[作成URL]]の[F[起源][URLの起源]]を返します。
= [24] それ以外の場合、
== [25] [VAR[クライアント]]の[F[起源][環境設定群オブジェクトの起源]]を返します。
]FIG]

* 関連

[HISTORY[
[4] [[文書の[F[ドメイン]]]]は、[[文書の[F[起源]]]]のうち、[F[ホスト]]の部分を指します。
[[文書の[F[起源]]]]が[[三項組]]でないなら、ありません。

;; [[文書のドメイン]]参照。
]HISTORY]

* 歴史

;; [11] [[起源]]の歴史の項も参照。

[269] [CITE@en[Web Applications 1.0 r7881     Security: data: URLs shouldn't get the origin of a redirector, since that redirector might be tricked into redirecting a data: URLs by a hostile origin, thus letting that hostile origin expose a same-origin data: URL.]] ([TIME[2013-06-01 05:13:00 +09:00]] 版) <http://html5.org/tools/web-apps-tracker?from=7880&to=7881>

[174] [[文書の起源]]の「その他」ケースは [[HTML Living Standard]] で最初に規定され、次に 
[[DOM Living Standard]]
でも規定され、
[CITE@en[Web Applications 1.0 r7732 Defer to DOM.]] ([TIME[2013-03-07 04:51:00 +09:00]] 版) <http://html5.org/tools/web-apps-tracker?from=7731&to=7732>
で [[DOM]] の規定を参照するよう変更されました。

[REFS[
- [1] [CITE[Add document.origin. https://www.w3.org/Bugs/Public/show_bug.cgi?id=2340... · 0999d4d · whatwg/dom]]
( ([TIME[2013-11-13 11:34:52 +09:00]] 版))
<https://github.com/whatwg/dom/commit/0999d4d9acbe9cb178021b9f6ceba8cc72cc00fd>
- [2] [CITE[Actually serialize the origin, oops! · b5dcd15 · whatwg/dom]]
( ([TIME[2013-11-13 11:35:32 +09:00]] 版))
<https://github.com/whatwg/dom/commit/b5dcd1560f4c19a70f2dfc7eb1e00289809554e2>
]REFS]

[5] [CITE@en[931884 – Implement document.origin]]
([TIME[2015-06-13 12:32:38 +09:00]] 版)
<https://bugzilla.mozilla.org/show_bug.cgi?id=931884>

[7] [CITE@en[Remove the origin aliasing concept · whatwg/html@438155d]]
([TIME[2016-03-23 22:28:21 +09:00]] 版)
<https://github.com/whatwg/html/commit/438155d2a2255aa5ea84ae390744d8a8662ebec2>

[12] [CITE@en[Define the origin of non-initial about:blank documents · whatwg/html@baad9fd]]
([TIME[2016-03-25 13:32:16 +09:00]] 版)
<https://github.com/whatwg/html/commit/baad9fd10e5a49c1c72fc89426ffa2a26e0b72e4>

[13] [CITE@en[Merge effective script origin into origin · whatwg/html@8a843f2]]
([TIME[2016-03-31 16:19:57 +09:00]] 版)
<https://github.com/whatwg/html/commit/8a843f2169a6864a3024c4329528dccb2051d275>

[14] [CITE@en[Align with origin changes in HTML · whatwg/dom@20b3f3e]]
([TIME[2016-04-06 17:07:32 +09:00]] 版)
<https://github.com/whatwg/dom/commit/20b3f3e427180e40531a40d1d93ea0097c221c90>

[15] [CITE@en[Assign document's origin during creation · whatwg/html@b94d600]]
([TIME[2016-05-01 14:28:39 +09:00]] 版)
<https://github.com/whatwg/html/commit/b94d600e0e4de5ddea2215078611d6dfd0800391>

[16] [CITE@en[Use USVString for URLs and origins in IDL]]
( ([[zcorpan]]著, [TIME[2016-05-20 21:56:11 +09:00]]))
<https://github.com/whatwg/dom/commit/1bb85a48e07d1000e00bd792d61247b9a5e2e4ae>

[17] [CITE@en[Define document's origin slot in DOM rather than HTML]]
([[jyasskin]]著, [TIME[2016-08-24 02:19:02 +09:00]])
<https://github.com/whatwg/dom/commit/e4b7778c543f0674454fa4eccf323ffde3f691fb>

[18] [CITE@en[Treat 'data:' documents as unique, opaque origins (#1756)]]
([[mikewest]]著, [TIME[2016-09-13 18:20:33 +09:00]])
<https://github.com/whatwg/html/commit/00769464e80149368672b894b50881134da4602f>

[19] [CITE@en[Copy the origin pointer when cloning a document]]
([[annevk]]著, [TIME[2016-12-01 01:43:07 +09:00]])
<https://github.com/whatwg/dom/commit/623f655c9f58039fa6b30e0f65ee325700e8b977>

[26] [CITE@en[Origins serialize to ASCII these days]]
([[annevk]]著, [TIME[2017-07-05 19:31:34 +09:00]])
<https://github.com/whatwg/dom/commit/fba2caf4be29c30e7e03010d5fce240a729e0bed>

[27] [CITE@en[Origins serialize to ASCII these days by annevk · Pull Request #475 · whatwg/dom]]
([TIME[2017-07-15 14:26:25 +09:00]])
<https://github.com/whatwg/dom/pull/475>

[29] [CITE@en[Refactor the navigation algorithm]]
([[dtapuska]], [TIME[2019-07-12 00:49:55 +09:00]], [TIME[2021-07-01T09:53:23.000Z]])
<https://github.com/whatwg/html/commit/061e782437c6cff600f18bc96c1a11489e09c3ab>