| 1 |
wakaba |
1.1 |
|
| 2 |
|
|
<html lang=en-US-x-hixie> |
| 3 |
|
|
<head> |
| 4 |
|
|
<title>Web Workers</title> |
| 5 |
|
|
<link href="http://www.whatwg.org/style/specification" rel=stylesheet> |
| 6 |
|
|
<!-- Japanese-translation-only style rules --> |
| 7 |
|
|
<style> |
| 8 |
|
|
em { |
| 9 |
|
|
text-decoration: underline; |
| 10 |
|
|
} |
| 11 |
|
|
ins.ja-note { |
| 12 |
|
|
background-color: #EEFFFF; |
| 13 |
|
|
color: black; |
| 14 |
|
|
} |
| 15 |
|
|
</style> |
| 16 |
|
|
<link href="http://www.whatwg.org/images/icon" rel=icon> |
| 17 |
|
|
|
| 18 |
|
|
<body class=draft> |
| 19 |
|
|
<div class=head> |
| 20 |
|
|
<p><span class=ja-translation lang=ja><a class=logo href="http://www.whatwg.org/" rel=home><img lang=en alt=WHATWG |
| 21 |
|
|
src="http://www.whatwg.org/images/logo"></a></span></p> |
| 22 |
|
|
|
| 23 |
|
|
<h1 id=web-workers>Web Workers</h1> |
| 24 |
|
|
|
| 25 |
|
|
<h2 class="no-num no-toc" id=draft><span class=ja-translation lang=ja>勧告案<ins class=ja-note>の非公式和訳</ins> — |
| 26 |
wakaba |
1.13 |
<ins class=ja-note>(原文出版日)</ins> 2008年7月18日</span></h2> |
| 27 |
wakaba |
1.1 |
|
| 28 |
|
|
<p><span class=ja-translation lang=ja>みなさんにも作業にご参加いただけます。 <a |
| 29 |
|
|
href="http://www.whatwg.org/mailing-list">作業部会の議論用メイリング・リストに参加してください。</a></span></p> |
| 30 |
|
|
|
| 31 |
|
|
<p><span class=ja-translation lang=ja><strong>Web デザイナー!</strong> みなさんのための <a |
| 32 |
|
|
href="http://blog.whatwg.org/faq/" lang=en>FAQ</a>、<a |
| 33 |
|
|
href="http://forums.whatwg.org/">掲示板</a>、<a |
| 34 |
|
|
href="http://www.whatwg.org/mailing-list#help">ヘルプ用メイリング・リスト</a>があります! |
| 35 |
|
|
|
| 36 |
|
|
</span><p> |
| 37 |
|
|
|
| 38 |
|
|
<!-- Japanese-translation-only notes --> |
| 39 |
wakaba |
1.3 |
<ins class=ja-note style="display: block" lang=ja> |
| 40 |
wakaba |
1.1 |
<p>この文書は、 WHATWG HTML5 仕様書の日本語訳です。 |
| 41 |
|
|
HTML5 の正式な仕様書は英語版だけであり、 |
| 42 |
|
|
この日本語訳はあくまで参考としてご利用ください。 |
| 43 |
|
|
|
| 44 |
wakaba |
1.3 |
<p lang=en>This document is a Japanese translation of |
| 45 |
wakaba |
1.1 |
the WHATWG HTML5 specification. Note that the only normative specification |
| 46 |
|
|
for the HTML5 is the original English version and this Japanese |
| 47 |
|
|
translation is non‐normative. |
| 48 |
wakaba |
1.3 |
|
| 49 |
|
|
<p>日本語訳は <a href="edit/" rel=edit>Web 界面</a>を使って編集できます。 |
| 50 |
|
|
編集結果はおよそ3時間おきに反映されます。 |
| 51 |
|
|
また、原文の変更には毎日自動的に追随しています。 |
| 52 |
|
|
|
| 53 |
wakaba |
1.8 |
<p lang=en>The Japanese text can be edited using the <a href="edit/" rel=edit>Web |
| 54 |
wakaba |
1.3 |
interface</a>. Any modifications will be reflected to this translation |
| 55 |
|
|
in about three hours. Note that any changes to the original specification |
| 56 |
|
|
will automatically be incorporated to this translation every day. |
| 57 |
wakaba |
1.1 |
</ins> |
| 58 |
|
|
|
| 59 |
|
|
<p><span><!-- dummy --></span></p> |
| 60 |
|
|
|
| 61 |
|
|
<dl> |
| 62 |
|
|
<dt><span class=ja-translation lang=ja><ins class=ja-note>原文の</ins>この版</span><dd><a |
| 63 |
wakaba |
1.13 |
href="http://www.whatwg.org/specs/web-workers/current-work/">http://whatwg.org/ww</a> |
| 64 |
wakaba |
1.1 |
|
| 65 |
|
|
<dt><span class=ja-translation lang=ja><ins class=ja-note>原文の</ins>改版履歴:</span><dd><span class=ja-translation lang=ja><span lang=en>Twitter</span> メッセージ (編集上の変更以外): <a |
| 66 |
|
|
href="http://twitter.com/WHATWG">http://twitter.com/WHATWG</a></span><dd>Commit-Watchers mailing list: <a |
| 67 |
|
|
href="http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org">http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org</a> |
| 68 |
|
|
|
| 69 |
|
|
<dd><span class=ja-translation lang=ja>対話的 <span lang=en>Web</span> 界面: <a href="http://html5.org/tools/web-workers-tracker">http://html5.org/tools/web-workers-tracker</a></span><dd><span class=ja-translation lang=ja><span lang=en>Subversion</span> 界面: <a href="http://svn.whatwg.org/webworkers/">http://svn.whatwg.org/webworkers/</a></span><dt><span class=ja-translation lang=ja>問題:</span><dd><span class=ja-translation lang=ja>フィードバックの送信先: <a |
| 70 |
|
|
href="http://www.whatwg.org/mailing-list">[email protected]</a></span><dd><span class=ja-translation lang=ja>フィードバックの閲覧・投票: <a |
| 71 |
|
|
href="http://www.whatwg.org/issues/">http://www.whatwg.org/issues/</a></span><dt><span class=ja-translation lang=ja>編集者:</span><dd>Ian Hickson, Google, [email protected] |
| 72 |
|
|
</dl> |
| 73 |
|
|
|
| 74 |
|
|
<p class=copyright>© Copyright 2004-2008 Apple Computer, Inc., |
| 75 |
|
|
Mozilla Foundation, and Opera Software ASA.</p> |
| 76 |
|
|
|
| 77 |
|
|
<p class=copyright>You are granted a license to use, reproduce and create |
| 78 |
|
|
derivative works of this document.</p> |
| 79 |
|
|
</div> |
| 80 |
|
|
|
| 81 |
|
|
<hr> |
| 82 |
|
|
|
| 83 |
|
|
<h2 class="no-num no-toc" id=abstract><span class=ja-translation lang=ja>概要</span></h2> |
| 84 |
|
|
|
| 85 |
|
|
<p><span class=ja-translation lang=ja>この仕様書は、 Web アプリケーションで主たる頁と並列に背景労働者スクリプトを動作させることを可能とする |
| 86 |
|
|
API を定義します。 |
| 87 |
|
|
これによって、メッセージ・パッシングによるスレッド的操作を協調機構として利用できるようになります。</span><h2 class="no-num no-toc" id=status><span class=ja-translation lang=ja>この文書の状態</span></h2> |
| 88 |
|
|
|
| 89 |
|
|
<p><span class=ja-translation lang=ja><strong>この文書は作業中です!</strong> |
| 90 |
|
|
この文書は、コメントへの対応や通常の開発の過程として、 |
| 91 |
|
|
毎時毎分とは言い過ぎですが毎日のペースで変更されています。 |
| 92 |
|
|
コメントは非常に歓迎していますので、 |
| 93 |
|
|
<a href="mailto:[email protected]">[email protected]</a> |
| 94 |
|
|
へお送りください。よろしくお願いします。</span><p><span class=ja-translation lang=ja>現在の焦点は、第1案の開発です。</span><p><span class=ja-translation lang=ja>実装者は、この仕様書が安定していないことに注意するべきです。 |
| 95 |
|
|
<strong>実装者は議論に参加しておかないと、 |
| 96 |
|
|
仕様がその実装とは非互換に変更されてしまうかもしれません。</strong> |
| 97 |
|
|
この仕様書がいずれ実装呼び掛けの段階に達するのよりも前にこの仕様を実装したい販売者は、 |
| 98 |
wakaba |
1.7 |
<a href="http://www.whatwg.org/mailing-list">WHATWG メイリング・リスト</a>に参加し、 |
| 99 |
wakaba |
1.1 |
議論に加わるべきです。</span><p><span class=ja-translation lang=ja>この仕様書は <a |
| 100 |
|
|
href="http://www.w3.org/html/wg">W3C HTML WG</a> |
| 101 |
|
|
によっても出版されています。2つの仕様書の目次以降は同一です。</span><h2 class="no-num no-toc" id=contents><span class=ja-translation lang=ja>目次 |
| 102 |
|
|
</span></h2> |
| 103 |
|
|
<!--begin-toc--> |
| 104 |
|
|
|
| 105 |
|
|
<ul class=toc> |
| 106 |
|
|
<li><a href="#introduction"><span class=secno>1. </span>Introduction</a> |
| 107 |
|
|
<ul class=toc> |
| 108 |
wakaba |
1.9 |
<li><a href="#tutorial"><span class=secno>1.1 </span>Tutorial</a> |
| 109 |
wakaba |
1.1 |
|
| 110 |
wakaba |
1.4 |
<li><a href="#requirements"><span class=secno>1.2 |
| 111 |
|
|
</span>Requirements</a> |
| 112 |
wakaba |
1.1 |
|
| 113 |
wakaba |
1.9 |
<li><a href="#conformance"><span class=secno>1.3 </span>Conformance |
| 114 |
wakaba |
1.1 |
requirements</a> |
| 115 |
|
|
<ul class=toc> |
| 116 |
wakaba |
1.9 |
<li><a href="#dependencies"><span class=secno>1.3.1 |
| 117 |
wakaba |
1.1 |
</span>Dependencies</a> |
| 118 |
|
|
</ul> |
| 119 |
|
|
|
| 120 |
wakaba |
1.9 |
<li><a href="#terminology"><span class=secno>1.4 </span>Terminology</a> |
| 121 |
|
|
</ul> |
| 122 |
|
|
|
| 123 |
wakaba |
1.13 |
<li><a href="#infrastructure"><span class=secno>2. |
| 124 |
|
|
</span>Infrastructure</a> |
| 125 |
wakaba |
1.9 |
<ul class=toc> |
| 126 |
|
|
<li><a href="#the-windowworker"><span class=secno>2.1 </span>The |
| 127 |
|
|
<code>WindowWorker</code> interface</a> |
| 128 |
|
|
|
| 129 |
|
|
<li><a href="#the-queue"><span class=secno>2.2 </span>The queue of |
| 130 |
|
|
events</a> |
| 131 |
|
|
|
| 132 |
wakaba |
1.11 |
<li><a href="#the-workers"><span class=secno>2.3 </span>The worker's |
| 133 |
|
|
ports</a> |
| 134 |
|
|
|
| 135 |
|
|
<li><a href="#processing"><span class=secno>2.4 </span>Processing |
| 136 |
wakaba |
1.9 |
model</a> |
| 137 |
wakaba |
1.13 |
|
| 138 |
|
|
<li><a href="#creating"><span class=secno>2.5 </span>Creating |
| 139 |
|
|
workers</a> |
| 140 |
wakaba |
1.9 |
</ul> |
| 141 |
|
|
|
| 142 |
wakaba |
1.13 |
<li><a href="#apis-available"><span class=secno>3. </span>APIs available |
| 143 |
|
|
to workers</a> |
| 144 |
wakaba |
1.1 |
|
| 145 |
|
|
<li class=no-num><a href="#references">References</a> |
| 146 |
|
|
|
| 147 |
|
|
<li class=no-num><a href="#acknowledgements">Acknowledgements</a> |
| 148 |
|
|
</ul> |
| 149 |
|
|
<!--end-toc--> |
| 150 |
|
|
|
| 151 |
|
|
<hr> |
| 152 |
|
|
|
| 153 |
wakaba |
1.3 |
<h2 id=introduction><span class=ja-translation lang=ja><span class=secno>1. </span>はじめに</span></h2> |
| 154 |
wakaba |
1.1 |
|
| 155 |
wakaba |
1.12 |
<h3 id=tutorial><span class=ja-translation lang=ja><span class=secno>1.1 </span>解説</span></h3> |
| 156 |
wakaba |
1.1 |
|
| 157 |
wakaba |
1.9 |
<p><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p class=big-issue>This section is missing. |
| 158 |
|
|
|
| 159 |
|
|
<h3 id=requirements><span class=ja-translation lang=ja><span class=secno>1.2 </span>要件</span></h3> |
| 160 |
wakaba |
1.1 |
|
| 161 |
wakaba |
1.6 |
<p><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p><span class=ja-translation lang=ja>この仕様書は、次に示す利用事例と要件に取り組むことを目指します。</span><ul> |
| 162 |
|
|
<li><span class=ja-translation lang=ja>背景労働者: Web アプリケーションは、そのデータを鯖と同期しておく必要があります。 |
| 163 |
|
|
これは、鯖への更新の送信と鯖からの更新の両方を含み、 |
| 164 |
|
|
アプリケーションがオフラインとなった時の更新のバッファリングの取扱いも含みます。 |
| 165 |
|
|
そのための符号は利用者界面の符号とは独立しているのが理想でしょう。</span><li><span class=ja-translation lang=ja>URL: 労働者は、文字列からではなく、 URL から生み出される<em class=rfc2119 title="SHOULD">べきです</em>。 |
| 166 |
|
|
スクリプトはその出典へのアクセスを滅多に有しないからです。</span><li><span class=ja-translation lang=ja>メッセージ・キューイング: 労働者が初期化される前に送信されたメッセージが失われるべきでは<em class=rfc2119 title="SHOULD NOT">ありません</em>。</span><li><span class=ja-translation lang=ja>労働者はタイマーへのアクセスを有する<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>労働者はネットワークへのアクセスを有する<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>労働者はライブラリを使える<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>実装は労働者に <code>Node</code> オブジェクトや |
| 167 |
|
|
<code>Document</code> オブジェクトを晒さなければならない<em class=rfc2119 title="SHOULD NOT">べきではありません</em>。</span><li><span class=ja-translation lang=ja>労働者は外界と何も共有する<em class=rfc2119 title="SHOULD NOT">べきではありません</em>。 |
| 168 |
|
|
例えば、労働者自体の中で労働者を現すオブジェクトと労働者を作成した文脈で労働者を表すオブジェクトは異なる<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>共有労働者: 同じ Web アプリケーションの複数の実現値は鯖に対する接続を1つだけ維持したいでしょう。</span><li><span class=ja-translation lang=ja>能力保証: ある iframe で動作している符号が他の iframe と何らかの権限 (例えば、 |
| 169 |
|
|
住所録へは追加するが読まない) を保証する接続を折衝することが可能である<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>委譲: ある労働者が別の労働者を生み出し、呼び出し元が委譲に気づかず、 |
| 170 |
|
|
かつ元の労働者がすべてのメッセージを仲介せずに、 |
| 171 |
|
|
当該労働者に対する要求を効率的に委譲できる<em class=rfc2119 title="SHOULD">べきです</em>。</span><li><span class=ja-translation lang=ja>親が有用ではなくなった労働者は殺される<em class=rfc2119 title="SHOULD">べきです</em>。 |
| 172 |
|
|
労働者はこれが起こることを検知して華麗に終了することができる<em class=rfc2119 title="SHOULD">べきです</em>。</span></ul> |
| 173 |
wakaba |
1.4 |
|
| 174 |
wakaba |
1.9 |
<h3 id=conformance><span class=ja-translation lang=ja><span class=secno>1.3 </span>適合性要件</span></h3> |
| 175 |
wakaba |
1.1 |
|
| 176 |
|
|
<p><span class=ja-translation lang=ja>この仕様書のすべての図、例、注意書きは、 |
| 177 |
|
|
規定の一部ではないと明記された節すべてと同様に、 |
| 178 |
|
|
規定の一部ではありません。 |
| 179 |
|
|
この仕様書のそれ以外のすべては規定の一部です。</span><p><span class=ja-translation lang=ja>この文書の規定の部分にあるキーワード「<em class=rfc2119 title="MUST">しなければなりません</em>」、 |
| 180 |
|
|
「<em class=rfc2119 title="MUST NOT">してはなりません</em>」、 |
| 181 |
|
|
「<em class=rfc2119 title="REQUIRED">必須です</em>」、「<em class=rfc2119 title="SHOULD">するべきです</em>」、 |
| 182 |
|
|
「<em class=rfc2119 title="SHOULD NOT">するべきではありません</em>」、 |
| 183 |
|
|
「<em class=rfc2119 title="RECOMMENDED">推奨します</em>」、「<em class=rfc2119 title="MAY">して構いません</em>」、 |
| 184 |
|
|
「<em class=rfc2119 title="OPTIONAL">任意です</em>」は、 RFC 2119 で説明されているように解釈します。 |
| 185 |
|
|
可読性の観点から、この仕様書<ins class=ja-note>の原文</ins>では、 |
| 186 |
|
|
これらの語<ins class=ja-note>の原語</ins>はすべて大文字では表記しません。 |
| 187 |
|
|
<a href="#refsRFC2119">[RFC2119]</a></span></p> |
| 188 |
|
|
<!-- XXX but they should be |
| 189 |
|
|
marked up --> |
| 190 |
|
|
|
| 191 |
|
|
<p><span class=ja-translation lang=ja>算法の一部として<ins class=ja-note>動作の指示の形で (原文では</ins>命令形で<ins class=ja-note>) </ins>記述された要件 |
| 192 |
|
|
(例えば「先頭の間隔文字をすべて除去します」や「偽を返し、これらの段階を停止します」) |
| 193 |
|
|
は、算法の紹介で使われたキーワード (<em class=rfc2119 title="MUST">しなければなりません</em>、 |
| 194 |
|
|
<em class=rfc2119 title="SHOULD">するべきです</em>、<em class=rfc2119 title="MAY">して構いません</em>など) の意味により解釈します。</span><p><span class=ja-translation lang=ja>いくつかの適合性要件は属性やメソッドやオブジェクトの要件として説明されています。 |
| 195 |
|
|
そのような要件は、利用者エージェントに関する要件として解釈します。</span><p><span class=ja-translation lang=ja>算法や特定の段階として説明されている適合性要件は、 |
| 196 |
|
|
最終的な結果が等価である限り、任意の方法で実装して<em class=rfc2119 title="MAY">構いません</em>。 |
| 197 |
|
|
(特に、この仕様書で定義されている算法は追うのを簡単にしており、 |
| 198 |
|
|
高性能であることを目指してはいません。)</span><p><span class=ja-translation lang=ja>この仕様書で定義される適合性の級は、利用者エージェントのみです。</span><p><span class=ja-translation lang=ja>利用者エージェントは、サービス拒否攻撃を防ぐため、 |
| 199 |
|
|
記憶容量を使い尽くすことを防ぐため、 |
| 200 |
|
|
あるいは環境特有の制限に対応するためなどの目的で、 |
| 201 |
wakaba |
1.9 |
別段の制約のない入力に対して実装特有の制限を設けて<em class=rfc2119 title="MAY">構いません</em>。</span><h4 id=dependencies><span class=ja-translation lang=ja><span class=secno>1.3.1 </span>依存性</span></h4> |
| 202 |
wakaba |
1.1 |
|
| 203 |
|
|
<p><span class=ja-translation lang=ja>この仕様書は他のいくつかの下位仕様書に依存しています。</span><dl> |
| 204 |
|
|
<dt>HTML5 |
| 205 |
|
|
|
| 206 |
|
|
<dd> |
| 207 |
|
|
<p><span class=ja-translation lang=ja>HTML5 の多くの基礎的な概念をこの仕様書で使用します。 |
| 208 |
|
|
<a href="#refsHTML5">[HTML5]</a></span></p> |
| 209 |
|
|
|
| 210 |
|
|
<dt>ECMAScript |
| 211 |
|
|
|
| 212 |
|
|
<dd> |
| 213 |
|
|
<p><span class=ja-translation lang=ja>この仕様書はスクリプト言語として JavaScript |
| 214 |
|
|
を使うことを想定しています。 <a href="#refsJS">[JS]</a></span></p> |
| 215 |
|
|
|
| 216 |
|
|
<dt>WebIDL |
| 217 |
|
|
|
| 218 |
|
|
<dd> |
| 219 |
wakaba |
1.5 |
<p><span class=ja-translation lang=ja>この仕様書の IDL ブロックは WebIDL 仕様書における意味を用います。 <a href="#refsWebIDL">[WebIDL]</a></span></p> |
| 220 |
wakaba |
1.1 |
</dl> |
| 221 |
|
|
|
| 222 |
wakaba |
1.9 |
<h3 id=terminology><span class=ja-translation lang=ja><span class=secno>1.4 </span>用語</span></h3> |
| 223 |
wakaba |
1.1 |
|
| 224 |
|
|
<p><span class=ja-translation lang=ja>簡単のため、<em>示す</em>、<em>表示する</em>、 |
| 225 |
|
|
<em>可視</em>などの用語を文書が利用者に対してレンダリングされる方法に言及する時に使うことがあります。 |
| 226 |
|
|
これらの語は視覚媒体を暗示することを意図していません。 |
| 227 |
wakaba |
1.10 |
これらの語は他の媒体にも等価な方法で適用されると考えなければ<em class=rfc2119 title="MUST">なりません</em>。</span><p><span class=ja-translation lang=ja>「<code title="">Foo</code> オブジェクト」という構文 (<code title="">Foo</code> |
| 228 |
|
|
は実際には界面) を時々使いますが、より正確な「界面 <code title="">Foo</code> |
| 229 |
|
|
を実装しているオブジェクト」の代わりに用いています。</span><p><span class=ja-translation lang=ja>DOM という語は、 Web アプリケーションでスクリプトに利用可能とされている API |
| 230 |
wakaba |
1.1 |
の集合を指して用い、必ずしも DOM 中核仕様書で定義されている実際の |
| 231 |
|
|
<code>Document</code> オブジェクトその他の <code>Node</code> |
| 232 |
|
|
オブジェクトの存在を暗示してはいません。<a |
| 233 |
|
|
href="#refsDOM3CORE">[DOM3CORE]</a></span><p><span class=ja-translation lang=ja>DOM 属性は、その値が (例えば著者のスクリプトにより) 取り出される時<em>取得される</em>といい、 |
| 234 |
|
|
新しい値がその属性に割り当てられる時<em>設定される</em>といいます。</span><p><span class=ja-translation lang=ja>DOM オブジェクトが<dfn id=live>生きている</dfn>という場合、 |
| 235 |
|
|
そのオブジェクトを返す属性は常に同じオブジェクトを返さなければ<em class=rfc2119 title="MUST">ならない</em> |
| 236 |
|
|
(毎回新しいオブジェクトを返すのではなく) 上に、 |
| 237 |
|
|
そのオブジェクトの属性やメソッドがそのオブジェクトの裏にある実際のデータのスナップ写真ではなく、 |
| 238 |
wakaba |
1.10 |
データそのものに対して操作されなければ<em class=rfc2119 title="MUST">ならない</em>ことを意味します。 |
| 239 |
wakaba |
1.13 |
</span><h2 id=infrastructure><span class=secno>2. </span>Infrastructure</h2> |
| 240 |
wakaba |
1.9 |
|
| 241 |
wakaba |
1.10 |
<h3 id=the-windowworker><span class=ja-translation lang=ja><span class=secno>2.1 </span><code><a href="#windowworker">WindowWorker</a></code> 界面</span></h3> |
| 242 |
wakaba |
1.9 |
|
| 243 |
|
|
<pre |
| 244 |
|
|
class=idl>[NoInterfaceObject] interface <dfn id=windowworker>WindowWorker</dfn> { |
| 245 |
wakaba |
1.13 |
readonly attribute DOMString <a href="#url" title=dom-WindowWorker-URL>URL</a>; |
| 246 |
|
|
readonly attribute DOMString <a href="#name" title=dom-WindowWorker-name>name</a>; |
| 247 |
|
|
readonly attribute boolean <a href="#closing" title=dom-WindowWorker-closing>closing</a>; |
| 248 |
|
|
void <a href="#close" title=dom-WindowWorker-close>close</a>(); |
| 249 |
wakaba |
1.11 |
|
| 250 |
|
|
// event handler attributes |
| 251 |
wakaba |
1.13 |
attribute <span>EventListener</span> <a href="#onattach" title=handler-WindowWorker-onattach>onattach</a>; |
| 252 |
|
|
attribute <span>EventListener</span> <a href="#onunload" title=handler-WindowWorker-onunload>onunload</a>; |
| 253 |
wakaba |
1.9 |
};</pre> |
| 254 |
|
|
|
| 255 |
wakaba |
1.13 |
<p>The <dfn id=url title=dom-WindowWorker-URL><code>URL</code></dfn> |
| 256 |
|
|
attribute must return the value it was assigned when the <code><a |
| 257 |
|
|
href="#windowworker">WindowWorker</a></code> object was created by the "<a |
| 258 |
|
|
href="#run-a">run a worker</a>" algorithm. It gives the <span>absolute |
| 259 |
|
|
URL</span> of the script that was used to initialize the worker. |
| 260 |
|
|
|
| 261 |
|
|
<p>The <dfn id=name title=dom-WindowWorker-name><code>name</code></dfn> |
| 262 |
|
|
attribute must return the value it was assigned when the <code><a |
| 263 |
|
|
href="#windowworker">WindowWorker</a></code> object was created by the "<a |
| 264 |
|
|
href="#run-a">run a worker</a>" algorithm. If it has a value that isn't |
| 265 |
|
|
the empty string, its value represents the name that can be used to obtain |
| 266 |
|
|
a reference to the worker using the <code |
| 267 |
|
|
title=dom-WindowWorkerCreators-createNamedWorker><a |
| 268 |
|
|
href="#createnamedworker">createNamedWorker()</a></code> method. |
| 269 |
|
|
|
| 270 |
|
|
<p>The <dfn id=closing |
| 271 |
|
|
title=dom-WindowWorker-closing><code>closing</code></dfn> attribute must |
| 272 |
wakaba |
1.9 |
return false until the "<a href="#kill-a">kill a worker</a>" processing |
| 273 |
|
|
model defined below sets it to false. |
| 274 |
|
|
|
| 275 |
wakaba |
1.12 |
<p><span class=ja-translation lang=ja>次に示すのは、 <code><a |
| 276 |
|
|
href="#windowworker">WindowWorker</a></code> |
| 277 |
|
|
界面を実装するオブジェクトが対応しなければ<em class=rfc2119 title="MUST">ならない</em>事象取扱器 DOM 属性です。</span><dl> |
| 278 |
wakaba |
1.13 |
<dt><dfn id=onattach |
| 279 |
|
|
title=handler-WindowWorker-onattach><code>onattach</code></dfn> |
| 280 |
wakaba |
1.11 |
|
| 281 |
|
|
<dd> |
| 282 |
wakaba |
1.13 |
<p><span class=ja-translation lang=ja><code title=event-WindowWorker-attach>attach</code> 事象が当該 <code><a href="#windowworker">WindowWorker</a></code> オブジェクトを対象としているか、泡立って当該オブジェクトを通過する時に、 |
| 283 |
wakaba |
1.12 |
呼び出されなければなりません。</span><dt><dfn id=onunload |
| 284 |
wakaba |
1.13 |
title=handler-WindowWorker-onunload><code>onunload</code></dfn> |
| 285 |
wakaba |
1.11 |
|
| 286 |
|
|
<dd> |
| 287 |
wakaba |
1.12 |
<p><span class=ja-translation lang=ja><code title=event-unload>unload</code> 事象が当該 <code><a href="#windowworker">WindowWorker</a></code> オブジェクトを対象としているか、泡立って当該オブジェクトを通過する時に、 |
| 288 |
|
|
呼び出されなければなりません。</span></dl> |
| 289 |
wakaba |
1.11 |
|
| 290 |
wakaba |
1.10 |
<h3 id=the-queue><span class=ja-translation lang=ja><span class=secno>2.2 </span>事象の待ち行列</span></h3> |
| 291 |
wakaba |
1.9 |
|
| 292 |
wakaba |
1.10 |
<p><span class=ja-translation lang=ja>各 <code><a href="#windowworker">WindowWorker</a></code> オブジェクトは、 |
| 293 |
wakaba |
1.12 |
<dfn id=queue>事象の待ち行列</dfn> (はじめは空) と関連付けられています。</span><p><span class=ja-translation lang=ja>待ち行列中の事象は、 DOM 事象か小休止呼び戻しのいずれかです。</span><p><span class=ja-translation lang=ja>労働者中で呼び出しまたは発送されるすべての非同期の呼び戻しと事象は、 |
| 294 |
|
|
作業者の待ち行列に追加されなければなりません。 |
| 295 |
|
|
ただし、実際の呼び戻しの呼び出しや事象の発送は、後述の「<a |
| 296 |
wakaba |
1.13 |
href="#run-a">労働者を起動</a>」処理モデルに従い処理されます。</span><p>Once the <code><a href="#windowworker">WindowWorker</a></code>'s <code |
| 297 |
|
|
title=dom-WindowWorker-closing><a href="#closing">closing</a></code> |
| 298 |
|
|
attribute is set to true, the queue must discard anything else that would |
| 299 |
|
|
be added to it. Effectively, once the <code |
| 300 |
|
|
title=dom-WindowWorker-closing><a href="#closing">closing</a></code> |
| 301 |
|
|
attribute is true, timers stop firing, notifications for all pending |
| 302 |
|
|
asynchronous operations are dropped, etc. |
| 303 |
|
|
|
| 304 |
|
|
<h3 id=the-workers><span class=ja-translation lang=ja><span class=secno>2.3 </span>作業者のポート</span></h3> |
| 305 |
wakaba |
1.11 |
|
| 306 |
wakaba |
1.12 |
<p><span class=ja-translation lang=ja>作業者は、メッセージ通信路とその <code>MessagePort</code> |
| 307 |
|
|
オブジェクトを通じて、他の労働者や閲覧文脈と通信します。</span><p><span class=ja-translation lang=ja>各 <code><a href="#windowworker">WindowWorker</a></code> <var |
| 308 |
|
|
title="">worker</var> は、<dfn id=the-workers0>労働者のポート</dfn>の並びを持ちます。 |
| 309 |
|
|
これは、他のポートと絡められており、かつ <code title=dom-MessagePort-ownerWindow>ownerWindow</code> |
| 310 |
|
|
が <var |
| 311 |
|
|
title="">worker</var> であるポートを1つ (だけ) 持つような <code>MessagePort</code> |
| 312 |
|
|
オブジェクトすべてを含むものです。この並びは<a href="#queue">事象の待ち行列</a>中で未決の事象中にある |
| 313 |
|
|
<code>MessagePort</code> オブジェクトすべてを含みます。</span><h3 id=processing><span class=ja-translation lang=ja><span class=secno>2.4 </span>処理モデル</span></h3> |
| 314 |
|
|
|
| 315 |
|
|
<p><span class=ja-translation lang=ja>利用者エージェントが、<span>URL</span> <var |
| 316 |
|
|
title="">url</var>、閲覧文脈 <var title="">owner browsing |
| 317 |
|
|
context</var>、<code>Document</code> <var title="">owner |
| 318 |
|
|
document</var> のスクリプトに対する、 <var |
| 319 |
|
|
title="">name</var> と名付けられた<dfn id=run-a>労働者を起動</dfn>する、 |
| 320 |
|
|
という時には、利用者エージェントは、次の段階を、完全に分離された並列実行環境で実行しなければ<em class=rfc2119 title="MUST">なりません</em>。</span><ol> |
| 321 |
|
|
<li> |
| 322 |
|
|
<p><span class=ja-translation lang=ja><var title="">url</var> で識別される資源を取って来ようと試みます。</span></p> |
| 323 |
|
|
|
| 324 |
wakaba |
1.13 |
<p>If the attempt fails, then abort these steps and invoke the <a |
| 325 |
|
|
href="#worker" title="worker creation failed">error handling steps</a> |
| 326 |
|
|
defined by the algorithm that called this one.</p> |
| 327 |
wakaba |
1.12 |
|
| 328 |
|
|
<p><span class=ja-translation lang=ja>この試みが成功した場合、 <var title="">script</var> |
| 329 |
|
|
を得られた資源とします。</span></p> |
| 330 |
|
|
|
| 331 |
|
|
<p class=note><span class=ja-translation lang=ja><code>script</code> 要素と同様に、スクリプトの MIME 型は無視します。 |
| 332 |
|
|
<code>script</code> 要素とは異なり、 |
| 333 |
|
|
型を上書きする方法はありません。スクリプトは常に JavaScript |
| 334 |
|
|
と仮定します。</span></p> |
| 335 |
wakaba |
1.11 |
<!-- XXX people will complain about |
| 336 |
|
|
this. I guess we might want to examine the MIME type... --> |
| 337 |
|
|
|
| 338 |
|
|
|
| 339 |
|
|
<li> |
| 340 |
wakaba |
1.12 |
<p><span class=ja-translation lang=ja>新しい <code><a href="#windowworker">WindowWorker</a></code> |
| 341 |
|
|
オブジェクト <var title="">window</var> を作成します。</span></p> |
| 342 |
wakaba |
1.9 |
|
| 343 |
|
|
<li> |
| 344 |
wakaba |
1.13 |
<p>Set the <code title=dom-WindowWorker-URL><a href="#url">URL</a></code> |
| 345 |
|
|
attribute of <var title="">window</var> to the value of <var |
| 346 |
|
|
title="">url</var>.</p> |
| 347 |
|
|
|
| 348 |
|
|
<li> |
| 349 |
|
|
<p>Set the <code title=dom-WindowWorker-name><a |
| 350 |
|
|
href="#name">name</a></code> attribute of <var title="">window</var> to |
| 351 |
|
|
the value of <var title="">name</var>.</p> |
| 352 |
wakaba |
1.9 |
|
| 353 |
|
|
<li> |
| 354 |
wakaba |
1.12 |
<p><span class=ja-translation lang=ja><var title="">script</var> のスクリプト実行文脈 (と大域オブジェクトも) |
| 355 |
|
|
を <var |
| 356 |
|
|
title="">window</var> とします。</span></p> |
| 357 |
wakaba |
1.9 |
|
| 358 |
|
|
<li> |
| 359 |
wakaba |
1.12 |
<p><span class=ja-translation lang=ja><var title="">script</var> のスクリプト閲覧文脈を <var title="">owner browsing context</var> |
| 360 |
|
|
とします。</span></p> |
| 361 |
wakaba |
1.9 |
|
| 362 |
|
|
<li> |
| 363 |
wakaba |
1.12 |
<p><span class=ja-translation lang=ja><var title="">script</var> のスクリプト文書文脈を <var title="">owner document</var> |
| 364 |
|
|
とします。</span></p> |
| 365 |
wakaba |
1.9 |
|
| 366 |
|
|
<li> |
| 367 |
wakaba |
1.13 |
<p>Invoke the <a href="#success" title="worker creation |
| 368 |
|
|
succeeded">success steps</a> defined by the algorithm that called this |
| 369 |
|
|
one. (This will add an event to the <a href="#queue">queue of |
| 370 |
|
|
events</a>.)</p> |
| 371 |
|
|
|
| 372 |
|
|
<li> |
| 373 |
|
|
<p>Start monitoring <var title="">worker</var>, such that whenever the |
| 374 |
|
|
<var title="">window</var> object's <code |
| 375 |
|
|
title=dom-WindowWorker-closing><a href="#closing">closing</a></code> |
| 376 |
|
|
attribute is false and all <a href="#the-workers0">the worker's |
| 377 |
|
|
ports</a> have their <code title=dom-MessagePort-active>active</code> |
| 378 |
|
|
attributes set to false, the user agent suspends execution of script in |
| 379 |
|
|
that worker until such time as either the <code |
| 380 |
|
|
title=dom-WindowWorker-closing><a href="#closing">closing</a></code> |
| 381 |
|
|
attribute switches to true or one of the <code>MessagePort</code> |
| 382 |
|
|
objects in the list of <a href="#the-workers0">the worker's ports</a> |
| 383 |
|
|
has an <code title=dom-MessagePort-active>active</code> attribute with |
| 384 |
|
|
the value true.</p> |
| 385 |
wakaba |
1.11 |
|
| 386 |
|
|
<li> |
| 387 |
|
|
<p>Start monitoring <var title="">worker</var>, such that as soon as the |
| 388 |
|
|
list of <a href="#the-workers0">the worker's ports</a> becomes empty, |
| 389 |
|
|
the <var title="">window</var> object's <code |
| 390 |
wakaba |
1.13 |
title=dom-WindowWorker-closing><a href="#closing">closing</a></code> |
| 391 |
wakaba |
1.11 |
attribute is set to true.</p> |
| 392 |
|
|
|
| 393 |
|
|
<li> |
| 394 |
|
|
<p>Run <var title="">script</var> until it either returns, fails to catch |
| 395 |
|
|
an exception, or gets prematurely aborted by the "<a href="#kill-a">kill |
| 396 |
|
|
a worker</a>" algorithm below.</p> |
| 397 |
|
|
|
| 398 |
|
|
<p class=note>If the script gets aborted by the "<a href="#kill-a">kill a |
| 399 |
|
|
worker</a>" algorithm, then that same algorithm will cause there to only |
| 400 |
|
|
be a single event in the <a href="#queue">queue of events</a> at the |
| 401 |
|
|
next step, namely the <code title=message-unload>unload</code> event. |
| 402 |
|
|
However, if the event is ignored then it will become true as soon as |
| 403 |
|
|
that port is garbage collected.</p> |
| 404 |
wakaba |
1.9 |
|
| 405 |
|
|
<li> |
| 406 |
wakaba |
1.11 |
<p><i>Event loop</i>: Wait until either there is an event in the <a |
| 407 |
wakaba |
1.9 |
href="#queue">queue of events</a> associated with <var |
| 408 |
wakaba |
1.11 |
title="">window</var> or the <var title="">window</var> object's <code |
| 409 |
wakaba |
1.13 |
title=dom-WindowWorker-closing><a href="#closing">closing</a></code> |
| 410 |
wakaba |
1.11 |
attribute is set to true.</p> |
| 411 |
wakaba |
1.9 |
|
| 412 |
|
|
<li> |
| 413 |
|
|
<p>Dispatch the oldest event or callback in the <a href="#queue">queue of |
| 414 |
wakaba |
1.11 |
events</a>, if any. The handling of this event or the execution of this |
| 415 |
|
|
callback might get prematurely aborted by the "<a href="#kill-a">kill a |
| 416 |
|
|
worker</a>" algorithm below.</p> |
| 417 |
wakaba |
1.9 |
|
| 418 |
|
|
<li> |
| 419 |
|
|
<p>If there are any more events in the <a href="#queue">queue of |
| 420 |
|
|
events</a> or if the <var title="">window</var> object's <code |
| 421 |
wakaba |
1.13 |
title=dom-WindowWorker-closing><a href="#closing">closing</a></code> |
| 422 |
wakaba |
1.9 |
attribute is set to false, then jump back to the step above labeled |
| 423 |
|
|
<i>event loop</i>.</p> |
| 424 |
|
|
|
| 425 |
|
|
<li> |
| 426 |
|
|
<p class=big-issue>timers, intervals, XMLHttpRequests, database |
| 427 |
|
|
transactions, etc, must be killed; ports must be deactivated and |
| 428 |
wakaba |
1.11 |
unentangled (do not send unload)</p> |
| 429 |
wakaba |
1.9 |
</ol> |
| 430 |
|
|
|
| 431 |
|
|
<hr> |
| 432 |
|
|
|
| 433 |
|
|
<p>When a user agent is to <dfn id=kill-a>kill a worker</dfn>, it must run |
| 434 |
|
|
the following steps in parallel with the worker's main loop (the "<a |
| 435 |
|
|
href="#run-a">run a worker</a>" processing model defined above): |
| 436 |
|
|
|
| 437 |
|
|
<ol> |
| 438 |
|
|
<li> |
| 439 |
|
|
<p>Create an <code>Event</code> object with the event name <code |
| 440 |
|
|
title=event-unload>unload</code>, which does not bubble and is not |
| 441 |
|
|
cancelable, and add it to the worker's <code><a |
| 442 |
|
|
href="#windowworker">WindowWorker</a></code> object's <a |
| 443 |
wakaba |
1.11 |
href="#queue">queue of events</a>, targetted at the <code><a |
| 444 |
|
|
href="#windowworker">WindowWorker</a></code> object itself. |
| 445 |
|
|
|
| 446 |
|
|
<li> |
| 447 |
|
|
<p>Set the worker's <code><a href="#windowworker">WindowWorker</a></code> |
| 448 |
wakaba |
1.13 |
object's <code title=dom-WindowWorker-closing><a |
| 449 |
wakaba |
1.11 |
href="#closing">closing</a></code> attribute to true. |
| 450 |
wakaba |
1.9 |
|
| 451 |
|
|
<li> |
| 452 |
wakaba |
1.11 |
<p>Wait a user-agent-defined amount of time. If the "<a href="#run-a">run |
| 453 |
|
|
a worker</a>" processing model defined above immediately starts running |
| 454 |
|
|
event listeners registered for <code title=event-unload>unload</code> |
| 455 |
|
|
event, this time should not be zero — the idea is that the <code |
| 456 |
|
|
title=event-unload>unload</code> event can be used to clean up when |
| 457 |
|
|
shutting down unexpectedly. |
| 458 |
wakaba |
1.9 |
|
| 459 |
|
|
<li> |
| 460 |
|
|
<p>If there are any events in the <a href="#queue">queue of events</a> |
| 461 |
|
|
other than the <code title=event-unload>unload</code> event that this |
| 462 |
|
|
algorithm just added, discard them without dispatching them. |
| 463 |
|
|
|
| 464 |
|
|
<li> |
| 465 |
|
|
<p>If the <code title=event-unload>unload</code> event that this |
| 466 |
|
|
algorithm just added hasn't yet been dispatched, then abort the script |
| 467 |
|
|
currently running in the worker. |
| 468 |
|
|
|
| 469 |
|
|
<li> |
| 470 |
|
|
<p>Wait a user-agent-defined amount of time. |
| 471 |
|
|
|
| 472 |
|
|
<li> |
| 473 |
|
|
<p>Abort the script currently running in the worker (if any script is |
| 474 |
|
|
running, then it will be a handler for the <code |
| 475 |
|
|
title=event-unload>unload</code> event). |
| 476 |
|
|
</ol> |
| 477 |
|
|
|
| 478 |
wakaba |
1.11 |
<hr> |
| 479 |
|
|
|
| 480 |
|
|
<p>When a script invokes the <dfn id=close |
| 481 |
wakaba |
1.13 |
title=dom-WindowWorker-close><code>close()</code></dfn> method on a |
| 482 |
wakaba |
1.11 |
<code><a href="#windowworker">WindowWorker</a></code> object, the user |
| 483 |
|
|
agent must run the following steps: |
| 484 |
|
|
|
| 485 |
|
|
<ol> |
| 486 |
|
|
<li> |
| 487 |
|
|
<p>Create an <code>Event</code> object with the event name <code |
| 488 |
|
|
title=event-unload>unload</code>, which does not bubble and is not |
| 489 |
|
|
cancelable, and add it to the <code><a |
| 490 |
|
|
href="#windowworker">WindowWorker</a></code> object's <a |
| 491 |
|
|
href="#queue">queue of events</a>, targetted at the <code><a |
| 492 |
|
|
href="#windowworker">WindowWorker</a></code> object itself. |
| 493 |
|
|
|
| 494 |
|
|
<li> |
| 495 |
|
|
<p>Set the worker's <code><a href="#windowworker">WindowWorker</a></code> |
| 496 |
wakaba |
1.13 |
object's <code title=dom-WindowWorker-closing><a |
| 497 |
wakaba |
1.11 |
href="#closing">closing</a></code> attribute to true. |
| 498 |
|
|
|
| 499 |
|
|
<li> |
| 500 |
|
|
<p>For each <code>MessagePort</code> object that is entangled with |
| 501 |
|
|
another port and that has one (but only one) port whose <code |
| 502 |
|
|
title=dom-MessagePort-ownerWindow>ownerWindow</code> is the <code><a |
| 503 |
|
|
href="#windowworker">WindowWorker</a></code> object on which the method |
| 504 |
|
|
was invoked, run the following substeps:</p> |
| 505 |
|
|
|
| 506 |
|
|
<ol> |
| 507 |
|
|
<li> |
| 508 |
|
|
<p>Unentangle the two ports. |
| 509 |
|
|
|
| 510 |
|
|
<li> |
| 511 |
|
|
<p>Set both ports' <code title=dom-MessagePort-active>active</code> |
| 512 |
|
|
attribute to false. |
| 513 |
|
|
|
| 514 |
|
|
<li> |
| 515 |
|
|
<p>At the next available opportunity, after any scripts have finished |
| 516 |
|
|
executing<!-- XXX queue -->, <span>fire a simple event</span> called |
| 517 |
|
|
<code title=event-unload>unload</code> at the other port (the one |
| 518 |
|
|
whose <code title=dom-MessagePort-ownerWindow>ownerWindow</code> is |
| 519 |
|
|
not the <code><a href="#windowworker">WindowWorker</a></code> object |
| 520 |
wakaba |
1.13 |
on which the <code title=dom-WindowWorker-close><a |
| 521 |
wakaba |
1.11 |
href="#close">close()</a></code> method was called). |
| 522 |
|
|
</ol> |
| 523 |
|
|
</ol> |
| 524 |
|
|
|
| 525 |
wakaba |
1.13 |
<h3 id=creating><span class=secno>2.5 </span>Creating workers</h3> |
| 526 |
wakaba |
1.9 |
|
| 527 |
|
|
<pre |
| 528 |
|
|
class=idl>[NoInterfaceObject] interface <dfn id=windowworkercreators>WindowWorkerCreators</dfn> { |
| 529 |
wakaba |
1.13 |
<span>MessagePort</span> <a href="#createworker" title=dom-WindowWorkerCreators-createWorker>createWorker</a>(in DOMString scriptURL); |
| 530 |
|
|
<span>MessagePort</span> <a href="#createnamedworker" title=dom-WindowWorkerCreators-createNamedWorker>createNamedWorker</a>(in DOMString name, in DOMString scriptURL); |
| 531 |
wakaba |
1.9 |
};</pre> |
| 532 |
|
|
|
| 533 |
|
|
<p>Objects that implement the <code>Window</code> interface must also |
| 534 |
|
|
implement the <code><a |
| 535 |
|
|
href="#windowworkercreators">WindowWorkerCreators</a></code> interface. |
| 536 |
wakaba |
1.11 |
|
| 537 |
|
|
<hr> |
| 538 |
|
|
|
| 539 |
wakaba |
1.13 |
<p>When the <dfn id=createworker |
| 540 |
|
|
title=dom-WindowWorkerCreators-createWorker><code>createWorker(<var |
| 541 |
|
|
title="">scriptURL</var>)</code></dfn> method is invoked, the user agent |
| 542 |
|
|
must run the following steps: |
| 543 |
wakaba |
1.11 |
|
| 544 |
|
|
<ol> |
| 545 |
wakaba |
1.13 |
<li> |
| 546 |
|
|
<p><span title="resolve a url">Resolve</span> the <var |
| 547 |
|
|
title="">scriptURL</var> argument. |
| 548 |
|
|
|
| 549 |
|
|
<li> |
| 550 |
|
|
<p>If this fails, throw a <code>SYNTAX_ERR</code> exception. |
| 551 |
|
|
|
| 552 |
|
|
<li> |
| 553 |
|
|
<p>If the <span>origin</span> of the resulting <span>absolute URL</span> |
| 554 |
|
|
is not the <span title="same origin">same</span> as the origin of the |
| 555 |
|
|
script that invoked the method, then throw a <span>security |
| 556 |
|
|
exception</span>. |
| 557 |
|
|
|
| 558 |
|
|
<li> |
| 559 |
|
|
<p><a href="#create">Create a worker</a> from the resulting |
| 560 |
|
|
<span>absolute URL</span> whose name is the empty string. |
| 561 |
|
|
|
| 562 |
|
|
<li> |
| 563 |
|
|
<p>Return the <code>MessagePort</code> object returned from the <a |
| 564 |
|
|
href="#create">create a worker</a> algorithm. |
| 565 |
wakaba |
1.11 |
</ol> |
| 566 |
|
|
|
| 567 |
|
|
<hr> |
| 568 |
|
|
|
| 569 |
wakaba |
1.13 |
<p>When the <dfn id=createnamedworker |
| 570 |
|
|
title=dom-WindowWorkerCreators-createNamedWorker><code>createNamedWorker(<var |
| 571 |
|
|
title="">name</var>, <var title="">scriptURL</var>)</code></dfn> method is |
| 572 |
|
|
invoked, the user agent must run the following steps: |
| 573 |
wakaba |
1.11 |
|
| 574 |
|
|
<ol> |
| 575 |
wakaba |
1.13 |
<li> |
| 576 |
|
|
<p><span title="resolve a url">Resolve</span> the <var |
| 577 |
|
|
title="">scriptURL</var> argument. |
| 578 |
|
|
|
| 579 |
|
|
<li> |
| 580 |
|
|
<p>If this fails, throw a <code>SYNTAX_ERR</code> exception. |
| 581 |
|
|
|
| 582 |
|
|
<li> |
| 583 |
|
|
<p>If the <span>origin</span> of the resulting <span>absolute URL</span> |
| 584 |
|
|
is not the <span title="same origin">same</span> as the origin of the |
| 585 |
|
|
script that invoked the method, then throw a <span>security |
| 586 |
|
|
exception</span>. |
| 587 |
|
|
|
| 588 |
|
|
<li> |
| 589 |
|
|
<p>If the <var title="">name</var> argument is the empty string, <a |
| 590 |
|
|
href="#create">create a worker</a> from the resulting <span>absolute |
| 591 |
|
|
URL</span>, whose name is the empty string, and return the |
| 592 |
|
|
<code>MessagePort</code> object returned from the <a |
| 593 |
|
|
href="#create">create a worker</a> algorithm. Then, abort these steps. |
| 594 |
|
|
|
| 595 |
|
|
<li> |
| 596 |
|
|
<p>If there exists a worker whose <code title=dom-WindowWorker-closing><a |
| 597 |
|
|
href="#closing">closing</a></code> attribute is false, whose <code |
| 598 |
|
|
title=dom-WindowWorker-name><a href="#name">name</a></code> attribute is |
| 599 |
|
|
exactly equal to the <var title="">name</var> argument, and whose <code |
| 600 |
|
|
title=dom-WindowWorker-URL><a href="#url">URL</a></code> attribute has |
| 601 |
|
|
the <span>same origin</span> as the resulting <span>absolute URL</span>, |
| 602 |
|
|
then run these substeps:</p> |
| 603 |
|
|
|
| 604 |
|
|
<ol> |
| 605 |
|
|
<li> |
| 606 |
|
|
<p>If that worker's <code title=dom-WindowWorker-URL><a |
| 607 |
|
|
href="#url">URL</a></code> attribute is not exactly equal to the |
| 608 |
|
|
resulting <span>absolute URL</span>, then throw a |
| 609 |
|
|
<code>URL_MISMATCH_ERR</code> exception and abort these steps. <span |
| 610 |
|
|
class=big-issue>code 19</span> |
| 611 |
|
|
|
| 612 |
|
|
<li> |
| 613 |
|
|
<p><span>Create a new <code>MessagePort</code> object</span> owned by |
| 614 |
|
|
the <span>script execution context</span> of the script that invoked |
| 615 |
|
|
the method. |
| 616 |
|
|
|
| 617 |
|
|
<li> |
| 618 |
|
|
<p>Return that port. |
| 619 |
|
|
|
| 620 |
|
|
<li> |
| 621 |
|
|
<p>Asynchronously, <a href="#attach" title="attach to a |
| 622 |
|
|
worker">attach</a> to this preexisting worker, with the newly created |
| 623 |
|
|
port. |
| 624 |
|
|
</ol> |
| 625 |
|
|
|
| 626 |
|
|
<p>Otherwise, <a href="#create">create a worker</a> from the resulting |
| 627 |
|
|
<span>absolute URL</span>, whose name is the value of the <var |
| 628 |
|
|
title="">name</var> argument, and return the <code>MessagePort</code> |
| 629 |
|
|
object returned from the <a href="#create">create a worker</a> |
| 630 |
|
|
algorithm.</p> |
| 631 |
wakaba |
1.11 |
</ol> |
| 632 |
|
|
|
| 633 |
|
|
<hr> |
| 634 |
|
|
|
| 635 |
wakaba |
1.13 |
<p>The steps to <dfn id=create>create a worker</dfn> from a |
| 636 |
|
|
<span>URL</span> <var title="">url</var> and whose name is <var |
| 637 |
|
|
title="">name</var>, in the context of a method call, are as follows: |
| 638 |
wakaba |
1.11 |
|
| 639 |
|
|
<ol> |
| 640 |
wakaba |
1.13 |
<li> |
| 641 |
|
|
<p><span>Create a new <code>MessagePort</code> object</span> owned by the |
| 642 |
|
|
<span>script execution context</span> of the script that invoked the |
| 643 |
|
|
method. |
| 644 |
|
|
|
| 645 |
|
|
<li> |
| 646 |
|
|
<p>Return that port. |
| 647 |
|
|
|
| 648 |
|
|
<li> |
| 649 |
|
|
<p>In a parallel execution context (i.e. a separate thread or process or |
| 650 |
|
|
equivalent construct), <a href="#run-a">run a worker</a> named <var |
| 651 |
|
|
title="">name</var> for the script with <span>URL</span> <var |
| 652 |
|
|
title="">url</var>, with the <span>script browsing context</span> of the |
| 653 |
|
|
script that invoked the method as the <var title="">owner browsing |
| 654 |
|
|
context</var> and with the <span>script document context</span> of the |
| 655 |
|
|
script that invoked the method as the <var title="">owner |
| 656 |
|
|
document</var>.</p> |
| 657 |
|
|
|
| 658 |
|
|
<p>If that algorithm invokes the steps for <dfn id=success title="worker |
| 659 |
|
|
creation succeeded">success steps</dfn>, then <a href="#attach" |
| 660 |
|
|
title="attach to a worker">attach</a> to this new worker, with the newly |
| 661 |
|
|
created port.</p> |
| 662 |
|
|
|
| 663 |
|
|
<p>Otherwise, if the <dfn id=worker>worker creation failed</dfn>, then at |
| 664 |
|
|
the next available opportunity, after any scripts have finished |
| 665 |
|
|
executing<!-- XXX queue -->, <span>fire a simple event</span> called |
| 666 |
|
|
<code title=event-error>error</code> at the newly created port.</p> |
| 667 |
wakaba |
1.11 |
</ol> |
| 668 |
|
|
|
| 669 |
|
|
<hr> |
| 670 |
|
|
|
| 671 |
wakaba |
1.13 |
<p>The steps to <dfn id=attach>attach to a worker</dfn> given a |
| 672 |
|
|
<code>MessagePort</code> object <var title="">port</var> are as follows: |
| 673 |
wakaba |
1.11 |
|
| 674 |
|
|
<ol> |
| 675 |
wakaba |
1.13 |
<li> |
| 676 |
|
|
<p>If <var title="">port</var> would have been garbage collected, or if |
| 677 |
|
|
the <span>active document</span> of the <code |
| 678 |
|
|
title=dom-MessagePort-ownerWindow>ownerWindow</code> of <var |
| 679 |
|
|
title="">port</var> is no longer the same <code>Document</code> object |
| 680 |
|
|
as when <var title="">port</var> was created, then do nothing. Abort |
| 681 |
|
|
these steps. If the worker was just created, it'll get killed |
| 682 |
|
|
immediately.</p> |
| 683 |
|
|
|
| 684 |
|
|
<li> |
| 685 |
|
|
<p><span>Create a new <code>MessagePort</code> object</span> owned by the |
| 686 |
|
|
<code><a href="#windowworker">WindowWorker</a></code> of the worker. |
| 687 |
|
|
|
| 688 |
|
|
<li> |
| 689 |
|
|
<p><span>Entangle</span> this newly created port and the port <var |
| 690 |
|
|
title="">port</var> that was passed to these steps. |
| 691 |
|
|
|
| 692 |
|
|
<li> |
| 693 |
|
|
<p>Set the <code title=dom-MessagePort-active>active</code> attribute of |
| 694 |
|
|
both ports to true. |
| 695 |
|
|
|
| 696 |
|
|
<li> |
| 697 |
|
|
<p>At the next available opportunity, after any scripts have finished |
| 698 |
|
|
executing<!-- XXX queue -->, <span>fire a simple event</span> called |
| 699 |
|
|
<code title=event-load>load</code> at <var title="">port</var>. |
| 700 |
|
|
|
| 701 |
|
|
<li> |
| 702 |
|
|
<p>Create an event that uses the <code>MessageEvent</code> interface, |
| 703 |
|
|
with the name <code title=event-attach>attach</code>, which does not |
| 704 |
|
|
bubble, is cancelable, has no default action, has a <code |
| 705 |
|
|
title=dom-MessageEvent-data>data</code> attribute whose value is the |
| 706 |
|
|
empty string and has a <code |
| 707 |
|
|
title=dom-MessageEvent-messagePort>messagePort</code> attribute whose |
| 708 |
|
|
value is the newly created port, and add it to the worker's <code><a |
| 709 |
|
|
href="#windowworker">WindowWorker</a></code> object's <a |
| 710 |
|
|
href="#queue">queue of events</a>, targetted at the <code><a |
| 711 |
|
|
href="#windowworker">WindowWorker</a></code> object itself. |
| 712 |
wakaba |
1.11 |
</ol> |
| 713 |
wakaba |
1.9 |
|
| 714 |
wakaba |
1.13 |
<h2 id=apis-available><span class=secno>3. </span>APIs available to workers</h2> |
| 715 |
|
|
|
| 716 |
|
|
<p>Objects that implement the <code><a |
| 717 |
|
|
href="#windowworker">WindowWorker</a></code> interface must also implement |
| 718 |
|
|
the following interfaces: |
| 719 |
|
|
|
| 720 |
|
|
<ul> |
| 721 |
|
|
<li> |
| 722 |
|
|
<p>The <code>Window</code> interface, and interfaces that are required to |
| 723 |
|
|
be implemented by objects implementing that interface, including:</p> |
| 724 |
|
|
|
| 725 |
|
|
<ul> |
| 726 |
|
|
<li>The <code>WindowTimers</code> interface |
| 727 |
|
|
|
| 728 |
|
|
<li>The <code><a |
| 729 |
|
|
href="#windowworkercreators">WindowWorkerCreators</a></code> interface |
| 730 |
|
|
</ul> |
| 731 |
|
|
|
| 732 |
|
|
<li>The <code>EventTarget</code> interface. |
| 733 |
|
|
</ul> |
| 734 |
wakaba |
1.9 |
|
| 735 |
|
|
<h2 class=no-num id=references><span class=ja-translation lang=ja>参考文献</span></h2> |
| 736 |
wakaba |
1.1 |
|
| 737 |
|
|
<p class=big-issue><span class=ja-translation lang=ja>この章は将来の仕様案で執筆します。</span><h2 class=no-num id=acknowledgements><span class=ja-translation lang=ja>謝辞</span></h2> |
| 738 |
|
|
<!-- ACKS --> |
| 739 |
|
|
|
| 740 |
wakaba |
1.9 |
<p><span class=ja-translation lang=ja>Maciej Stachowiak, Mike Smith の有用かつ重要なコメントに感謝します。</span><p>Huge thanks to the whole Gears team, who pioneered this technology and |
| 741 |
|
|
whose experience has been a huge influence on this specification. |