URL origin

起源 (URL)

[1] URL起源 (origin) を持ちます。多くの場合、 URL起源URL schemeauthority から決まります。

[2] 起源一般については、起源の項を参照。

[8] URL起源は、文書起源などの定義に使われる、 起源の基礎となるものです。

仕様書

定義

[301] URL URL起源は、次の手順が返す値です >>300

  1. [21] URLscheme により、
    http, https, ftp, ws, wss のいずれかの場合
    項組起源を返します。
    項組起源
    scheme
    URLscheme
    ホスト
    URLホスト
    ポート
    URLポート

    [43] かつては gopher も該当していましたが、 の改訂で変更されました。

    blob の場合
    1. [36] URLblob URL entrynullない場合、
      1. [37] URLblob URL entry環境起源を返します。
    2. [38] それ以外の場合、
      1. [22] URL2 を、URLpath [ 0 ] に基本URL構文解析器を適用した結果に設定します。
      2. [24] URL2失敗の場合、
        1. [25] 不透明起源を返します。
      3. [26] それ以外の場合、
        1. [27] URL2起源を返します。
    file の場合
    実装依存の値を返します (>>31)。決めかねる時は不透明起源を返します。
    実装依存scheme の場合
    実装依存の方法で決めた値を返します (>>29)。
    それ以外の場合
    不透明起源を返します。
[306] ここでいう schemeホストポートURLの構文解析で得られる値なので、正準化が済んだ値です。 schemeホスト小文字化されています。

[28] about:blank起源は、 新しい不透明起源です。

[162] URL実効スクリプト起源起源と同じです >>135

[242] 別名ではありません。
[5] 文書の起源文書のURL起源は必ずしも一致しません。

[11] 例えば about:blank起源は、新しい大域的に固有な識別子です。

[17] 大域的に固有な識別子は、 URL ごとに新しいものが発行されます。 文字列として同じ URL であっても、URLの起源を取得する毎に異なる起源になります。

file: URL の起源

[31] 仕様上 file: URL起源実装定義となっています。 古い利用者エージェントfile: URL に対して緩い制限しかかけていませんでしたが、 セキュリティー上の問題から最近の利用者エージェントでは細かい単位で起源を設定していたりします。 例えば、ディレクトリー単位でアクセスを制限したり、ファイルごとに完全に別の起源として扱ったりしています >>23 4.

file: 参照。

Web ブラウザー依存の URL scheme の起源

[29] URL Standard には明記されていませんが、実際には、 各Webブラウザー固有の URL scheme では実装依存の方法で決定された起源が用いられることがあります。

[12] Chrome は、 chrome://version/ では Origin: chrome://version といったように、 chrome: URL でも URL schemeauthority起源を構成しているようです。

[32] Chrome は、 chrome://settings/chrome://extensions/chrome://chrome/ では、 chrome://chrome起源としているようです。

[33] Chrome は、 chrome-devtools://devtools/bundled/inspector.html?... のような URL のページで、 document.origin として chrome-devtools://devtools を返します。

[13] Firefox は、 about:mozilla から要求を送信させると Origin: null を送ります。

[14] Firefox は、 chrome: URL では Origin: chrome://global のように URL schemeauthority起源を構成するようです。

[34] Chromeview-source: URLURLoriginview-source:// とします。 view-source: URLnavigate したとき location.hrefview-source: を削った URL となり、 location.origin はそのURLの起源となり、 document.originfetchOrigin:null となります。

[7] HbbTV 2.0 は次のように規定しています。

[6] ( 版) http://www.hbbtv.org/pages/about_hbbtv/HbbTV_specification_2_0.pdf#page=44

For resources loaded via DSM-CC object carousel, the origin shall be the DVB URI in the form (as defined in TS 102 851 [10] clause 6.3.1):

"dvb" ":" "//" original_network_id "." transport_stream_id "." service_id "." component_tag

歴史

[3] URLの起源ははじめ HTML5 (現在の HTML Standard) で規定されましたが、 後に RFC 6454 に移動しました。その後更に URL Standard へと移動しました。

[4] 詳しくは起源の項を参照してください。

[18] Clarify that "new globally unique identifier" is intentional. Fixes #56. · whatwg/url@330e090 ( 版) https://github.com/whatwg/url/commit/330e090c53e9bebc9752757cd237a0bd71877e03

[19] Merge effective script origin into origin · whatwg/html@8a843f2 ( 版) https://github.com/whatwg/html/commit/8a843f2169a6864a3024c4329528dccb2051d275

[20] Align with origin changes in HTML · whatwg/url@b0e4def ( 版) https://github.com/whatwg/url/commit/b0e4def5b62e0be2d75b4b7b5720a5e0ea879596

[30] What is the 'Origin' (in Same-Origin-Policy sense) of a Google Chrome extension? - Quora ( 版) https://www.quora.com/What-is-the-Origin-in-Same-Origin-Policy-sense-of-a-Google-Chrome-extension

If you're writing JavaScript for Chrome extension, the origin is the directory structure inside the zipped up file of the extension itself.

[35] Use File API to resolve blob: URLs and their origins (mkruisselbrink著, ) https://github.com/whatwg/url/commit/d2ef633869b3f31d8c7e3bb76602400e4d2c126c

[39] Origin of blob URLs doesn't match what implementations do · Issue #127 · whatwg/url () https://github.com/whatwg/url/issues/127

[40] Fix Blob Origin · Issue #20 · w3c/FileAPI () https://github.com/w3c/FileAPI/issues/20

[41] "origin of a blob URL" is redundant/confusing · Issue #63 · w3c/FileAPI () https://github.com/w3c/FileAPI/issues/63

[42] Use definitions in FileAPI spec to resolve blob URLs and their origins. by mkruisselbrink · Pull Request #371 · whatwg/url () https://github.com/whatwg/url/pull/371

[44] Remove gopher case from origin algorithm (rmisev著, ) https://github.com/whatwg/url/commit/7ae1c691c96f0d82fafa24c33aa1e8df9ffbf2bc

[45] Remove gopher from list of special schemes by achristensen07 · Pull Request #453 · whatwg/url () https://github.com/whatwg/url/pull/453