| 1 |
wakaba |
1.1 |
|
| 2 |
|
|
<html lang=en-US-x-hixie> |
| 3 |
|
|
<head> |
| 4 |
|
|
<title>Web Workers</title> |
| 5 |
wakaba |
1.32 |
<link href=http://www.whatwg.org/style/specification rel=stylesheet> |
| 6 |
|
|
<link href=ja-style rel=stylesheet> |
| 7 |
|
|
<link href=only-ja-style rel="stylesheet" title="Show only Japanese text" id=style-only-ja> |
| 8 |
|
|
<link href=both-en-ja-style rel="alternate stylesheet" title="Show both English and Japanese texts" id=style-both-en-ja> |
| 9 |
wakaba |
1.35 |
<script src=ja-script defer async></script> |
| 10 |
wakaba |
1.31 |
<link href="/images/icon" rel=icon> |
| 11 |
wakaba |
1.1 |
|
| 12 |
wakaba |
1.16 |
<style> |
| 13 |
|
|
p > span:not([title=""]):not([class="big-issue"]), li > span:not([title=""]):not([class="big-issue"]) { border-bottom: solid #99CC99; } |
| 14 |
|
|
</style> |
| 15 |
|
|
|
| 16 |
wakaba |
1.1 |
<body class=draft> |
| 17 |
|
|
<div class=head> |
| 18 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="b20329e0f615f58f17900e708fa8dbaf"><span class=en-original lang=en><a class=logo href="http://www.whatwg.org/" rel=home><img alt=WHATWG |
| 19 |
|
|
src="/images/logo"></a></span></p> |
| 20 |
wakaba |
1.1 |
|
| 21 |
wakaba |
1.36 |
<h1 id=web-workers class="no-ja-translation" data-ja-hash="6cb7eb9696d986359fa3a78c4b8e60dc"><span class=en-original lang=en>Web Workers</span></h1> |
| 22 |
wakaba |
1.1 |
|
| 23 |
wakaba |
1.36 |
<h2 class="no-num no-toc has-ja-translation" data-ja-hash="1d9394e3fa85d967c53ca747b598736b" data-ja-real-hash="047930211cee9c8351b96cfbe8c231c2" id=draft><span class=en-original lang=en>Draft Recommendation — 27 August |
| 24 |
wakaba |
1.32 |
2008</span><span class=ja-translation lang=ja>勧告案<ins class=ja-note>の非公式和訳</ins> — |
| 25 |
wakaba |
1.29 |
<ins class=ja-note>(原文出版日)</ins> 2008年8月27日</span></h2> |
| 26 |
wakaba |
1.1 |
|
| 27 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="54759c46800b2712dd15f6097ee6ed63"><span class=en-original lang=en>You can take part in this work. <a |
| 28 |
wakaba |
1.31 |
href="http://www.whatwg.org/mailing-list">Join the working group's |
| 29 |
wakaba |
1.36 |
discussion list.</a></span></p> |
| 30 |
wakaba |
1.31 |
|
| 31 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="6a0ea97471522df19cf042a8869d7c52"><span class=en-original lang=en><strong>Web designers!</strong> We have a <a |
| 32 |
wakaba |
1.31 |
href="http://blog.whatwg.org/faq/">FAQ</a>, a <a |
| 33 |
|
|
href="http://forums.whatwg.org/">forum</a>, and a <a |
| 34 |
|
|
href="http://www.whatwg.org/mailing-list#help">help mailing list</a> for |
| 35 |
wakaba |
1.33 |
you!</span><span class=ja-translation lang=ja><strong>Web デザイナーのみなさん!</strong> みなさんのための <a |
| 36 |
wakaba |
1.32 |
href=http://blog.whatwg.org/faq/ lang=en>FAQ</a>、<a |
| 37 |
|
|
href=http://forums.whatwg.org/>掲示板</a>、<a |
| 38 |
|
|
href=http://www.whatwg.org/mailing-list#help>ヘルプ用メイリング・リスト</a>があります! |
| 39 |
|
|
|
| 40 |
|
|
</span><p> |
| 41 |
|
|
|
| 42 |
|
|
<!-- Japanese-translation-only notes --> |
| 43 |
wakaba |
1.33 |
<ins class="ja-note cover-ja-note" lang=ja> |
| 44 |
wakaba |
1.32 |
<p>この文書は、 WHATWG 仕様書の日本語訳です。 |
| 45 |
|
|
正式な仕様書は英語版だけであり、 |
| 46 |
|
|
この日本語訳はあくまで参考としてご利用ください。 |
| 47 |
|
|
|
| 48 |
|
|
<p lang=en>This document is a Japanese translation of |
| 49 |
|
|
the WHATWG HTML5 specification. Note that the only normative specification |
| 50 |
|
|
for the HTML5 is the original English version and this Japanese |
| 51 |
|
|
translation is non‐normative. |
| 52 |
|
|
|
| 53 |
|
|
<p>日本語訳は <a href="edit/" rel=edit>Web 界面</a>を使って編集できます。 |
| 54 |
|
|
編集結果はおよそ3時間おきに反映されます。 |
| 55 |
|
|
また、原文の変更には毎日自動的に追随しています。 |
| 56 |
|
|
|
| 57 |
|
|
<p lang=en>The Japanese text can be edited using the <a href=edit/ rel=edit>Web |
| 58 |
|
|
interface</a>. Any modifications will be reflected to this translation |
| 59 |
|
|
in about three hours. Note that any changes to the original specification |
| 60 |
|
|
will automatically be incorporated to this translation every day. |
| 61 |
|
|
|
| 62 |
|
|
<p><button type=button onclick=" |
| 63 |
|
|
document.getElementById ('style-only-ja').disabled = false; |
| 64 |
|
|
document.getElementById ('style-both-en-ja').disabled = true; |
| 65 |
wakaba |
1.33 |
">日本語訳だけ表示 <span lang=en>Show only Japanese translation</span></button> |
| 66 |
wakaba |
1.32 |
<p><button type=button onclick=" |
| 67 |
|
|
document.getElementById ('style-only-ja').disabled = true; |
| 68 |
|
|
document.getElementById ('style-both-en-ja').disabled = false; |
| 69 |
wakaba |
1.33 |
">英和対訳表示 <span lang=en>Show both English and Japanese texts</span></button> |
| 70 |
wakaba |
1.32 |
</ins> |
| 71 |
|
|
|
| 72 |
|
|
<p><span><!-- dummy --></span></p> |
| 73 |
wakaba |
1.1 |
|
| 74 |
|
|
<dl> |
| 75 |
wakaba |
1.36 |
<dt class="has-ja-translation" data-ja-hash="87b044fafc6f01197a9a700e6fa28a69"><span class=en-original lang=en>This version: |
| 76 |
wakaba |
1.32 |
|
| 77 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><ins class=ja-note>原文の</ins>この版</span><dd class="no-ja-translation" data-ja-hash="a713841c83aed89ce71b7ee6b51cb2cb"><span class=en-original lang=en><a |
| 78 |
wakaba |
1.13 |
href="http://www.whatwg.org/specs/web-workers/current-work/">http://whatwg.org/ww</a> |
| 79 |
wakaba |
1.1 |
|
| 80 |
wakaba |
1.36 |
</span><dt class="has-ja-translation" data-ja-hash="8866e8de2efa7275a5dc8e942c1613c2"><span class=en-original lang=en>Version history: |
| 81 |
wakaba |
1.32 |
|
| 82 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><ins class=ja-note>原文の</ins>改版履歴:</span><dd class="no-ja-translation" data-ja-hash="609cec19ff8d697eb0a9f7a0104e0bfb"><span class=en-original lang=en>Twitter messages (non-editorial changes only): <a |
| 83 |
wakaba |
1.31 |
href="http://twitter.com/WHATWG">http://twitter.com/WHATWG</a> |
| 84 |
|
|
|
| 85 |
wakaba |
1.36 |
</span><dd class="no-ja-translation" data-ja-hash="abaab2a9b4d1bd0f43a2293e5d1fff4d"><span class=en-original lang=en>Commit-Watchers mailing list: <a |
| 86 |
wakaba |
1.31 |
href="http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org">http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org</a> |
| 87 |
|
|
|
| 88 |
wakaba |
1.36 |
</span><dd class="has-ja-translation" data-ja-hash="5e1dbca74cface6f0d0ea523340e6a89" data-ja-real-hash="f82128f124c19a67cc2104420cc99c45"><span class=en-original lang=en>Interactive Web interface: <a |
| 89 |
wakaba |
1.32 |
href="http://html5.org/tools/web-workers-tracker">http://html5.org/tools/web-workers-tracker</a> |
| 90 |
|
|
|
| 91 |
wakaba |
1.36 |
</span><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 class="has-ja-translation" data-ja-hash="ea5cbdd06bfb529e4a1bcfeac9cfbd61" data-ja-real-hash="ae455a827d3d1e5b15fd14df54502cf5"><span class=en-original lang=en>Subversion interface: <a |
| 92 |
wakaba |
1.32 |
href="http://svn.whatwg.org/webworkers/">http://svn.whatwg.org/webworkers/</a> |
| 93 |
|
|
|
| 94 |
wakaba |
1.36 |
</span><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 class="has-ja-translation" data-ja-hash="8468b55db22971120cb71091ece7839e"><span class=en-original lang=en>Issues: |
| 95 |
wakaba |
1.32 |
|
| 96 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>問題:</span><dd class="no-ja-translation" data-ja-hash="72b4306377796146b832d635c9b791f4"><span class=en-original lang=en>To send feedback: <a |
| 97 |
wakaba |
1.31 |
href="http://www.whatwg.org/mailing-list">[email protected]</a> |
| 98 |
|
|
|
| 99 |
wakaba |
1.36 |
</span><dd class="no-ja-translation" data-ja-hash="7e3aaf1187bd798f9f71dd7e6e4fa9fe"><span class=en-original lang=en>To view and vote on feedback: <a |
| 100 |
wakaba |
1.31 |
href="http://www.whatwg.org/issues/">http://www.whatwg.org/issues/</a> |
| 101 |
|
|
|
| 102 |
wakaba |
1.36 |
</span><dt class="has-ja-translation" data-ja-hash="aa8d072dc59504320cfa92381f541a5f"><span class=en-original lang=en>Editor: |
| 103 |
wakaba |
1.32 |
|
| 104 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>編集者:</span><dd class="no-ja-translation" data-ja-hash="220fb2ab7924ad62bc8567b8b9c5f0f8"><span class=en-original lang=en>Ian Hickson, Google, [email protected] |
| 105 |
|
|
</span></dl> |
| 106 |
wakaba |
1.1 |
|
| 107 |
wakaba |
1.36 |
<p class="copyright no-ja-translation" data-ja-hash="01887da059d5ef35df4e1cc221f80391"><span class=en-original lang=en>© Copyright 2004-2008 Apple Computer, Inc., |
| 108 |
|
|
Mozilla Foundation, and Opera Software ASA.</span></p> |
| 109 |
wakaba |
1.1 |
|
| 110 |
wakaba |
1.36 |
<p class="copyright no-ja-translation" data-ja-hash="5419c8afab07265f61a6768f2680776d"><span class=en-original lang=en>You are granted a license to use, reproduce and create |
| 111 |
|
|
derivative works of this document.</span></p> |
| 112 |
wakaba |
1.1 |
</div> |
| 113 |
|
|
|
| 114 |
|
|
<hr> |
| 115 |
|
|
|
| 116 |
wakaba |
1.36 |
<h2 class="no-num no-toc has-ja-translation" data-ja-hash="e353dbe42c8654f33588d4da0b517469" id=abstract><span class=en-original lang=en>Abstract</span><span class=ja-translation lang=ja>概要</span></h2> |
| 117 |
wakaba |
1.1 |
|
| 118 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="a4f61aa99f0d87d5d87b6e07071a74da"><span class=en-original lang=en>This specification defines an API that allows Web application authors to |
| 119 |
wakaba |
1.32 |
spawn background workers running scripts in parallel to their main page. |
| 120 |
|
|
This allows for thread-like operation with message-passing as the |
| 121 |
|
|
coordination mechanism. |
| 122 |
|
|
|
| 123 |
|
|
</span><span class=ja-translation lang=ja>この仕様書は、 Web アプリケーションで、主たる頁とは並列に、 |
| 124 |
wakaba |
1.14 |
背景労働者スクリプトを走らせるための API を定義します。 |
| 125 |
wakaba |
1.36 |
これにより、メッセージ・パッシングによるスレッド的操作を協調機構として利用できるようになります。</span><h2 class="no-num no-toc has-ja-translation" data-ja-hash="c9bfd146532700356f3ff5ea6b1bf72e" id=status><span class=en-original lang=en>Status of this document</span><span class=ja-translation lang=ja>この文書の状態</span></h2> |
| 126 |
wakaba |
1.1 |
|
| 127 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="3f706d8337b443d9a959c36a9b3677a3"><span class=en-original lang=en><strong>This is a work in progress!</strong> This document is changing |
| 128 |
wakaba |
1.31 |
on a daily if not hourly basis in response to comments and as a general |
| 129 |
|
|
part of its development process. Comments are very welcome, please send |
| 130 |
|
|
them to <a href="mailto:[email protected]">[email protected]</a>. Thank |
| 131 |
|
|
you. |
| 132 |
|
|
|
| 133 |
wakaba |
1.36 |
</span><p class="has-ja-translation" data-ja-hash="5bb9ea777b965ca8d962ba2b6f663d46"><span class=en-original lang=en>The current focus is in developing a first draft proposal. |
| 134 |
wakaba |
1.32 |
|
| 135 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>現在の焦点は、第1案の開発です。</span><p class="no-ja-translation" data-ja-hash="75e78507b984cae37464af998b8dc8a2"><span class=en-original lang=en>Implementors should be aware that this specification is not stable. |
| 136 |
wakaba |
1.31 |
<strong>Implementors who are not taking part in the discussions are likely |
| 137 |
|
|
to find the specification changing out from under them in incompatible |
| 138 |
|
|
ways.</strong> Vendors interested in implementing this specification |
| 139 |
|
|
before it eventually reaches the call for implementations should join the |
| 140 |
|
|
<a href="/mailing-list">WHATWG mailing list</a> and take part in the |
| 141 |
|
|
discussions. |
| 142 |
|
|
|
| 143 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="410839ad8421121b3071c639986eb8df"><span class=en-original lang=en>This specification is also being produced by the <a |
| 144 |
wakaba |
1.31 |
href="http://www.w3.org/html/wg">W3C HTML WG</a>. The two specifications |
| 145 |
|
|
are identical from the table of contents onwards. |
| 146 |
|
|
|
| 147 |
wakaba |
1.36 |
</span><h2 class="no-num no-toc has-ja-translation" data-ja-hash="598b8ae10dfce818e73d3218daddbdae" id=contents><span class=en-original lang=en>Table of contents</span><span class=ja-translation lang=ja>目次 |
| 148 |
wakaba |
1.1 |
</span></h2> |
| 149 |
|
|
<!--begin-toc--> |
| 150 |
|
|
|
| 151 |
|
|
<ul class=toc> |
| 152 |
wakaba |
1.36 |
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="68d919e9ca0290e233107d49f2bd0973"><span class=en-original lang=en><a href="#introduction"><span class=secno>1. </span>Introduction</a> |
| 153 |
|
|
</span><ul class=toc> |
| 154 |
|
|
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="dbc00089b6907513414ccc5759c0aebe"><span class=en-original lang=en><a href="#tutorial"><span class=secno>1.1 </span>Tutorial</a> |
| 155 |
|
|
</span><ul class=toc> |
| 156 |
|
|
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="3d413918d0ec0996d5dc7bc207c69757"><span class=en-original lang=en><a href="#a-background"><span class=secno>1.1.1 </span>A |
| 157 |
wakaba |
1.23 |
background number-crunching worker</a> |
| 158 |
|
|
|
| 159 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="fc9510b1c40002104fa6a153dbf1ee03"><span class=en-original lang=en><a href="#a-worker"><span class=secno>1.1.2 </span>A worker for |
| 160 |
wakaba |
1.23 |
updating a client-side database</a> |
| 161 |
|
|
|
| 162 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="30028a4f210dae070d84439d4e9f835f"><span class=en-original lang=en><a href="#worker"><span class=secno>1.1.3 </span>Worker used for |
| 163 |
wakaba |
1.23 |
backgroud I/O</a> |
| 164 |
|
|
|
| 165 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="5320b0f38bcf4a77c557b8ca8a96a10a"><span class=en-original lang=en><a href="#shared"><span class=secno>1.1.4 </span>Shared |
| 166 |
wakaba |
1.23 |
workers</a> |
| 167 |
|
|
|
| 168 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="47309b31716571fa56acf4a7f626137b"><span class=en-original lang=en><a href="#delegation"><span class=secno>1.1.5 |
| 169 |
wakaba |
1.23 |
</span>Delegation</a> |
| 170 |
|
|
|
| 171 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="c20c95fa28bf20d6f93a6e1f61cc6364"><span class=en-original lang=en><a href="#providing"><span class=secno>1.1.6 </span>Providing |
| 172 |
wakaba |
1.28 |
libraries</a> |
| 173 |
wakaba |
1.36 |
</span></ul> |
| 174 |
wakaba |
1.1 |
|
| 175 |
wakaba |
1.36 |
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="f52c7ccb5bb4243123ae1ea2457583a8"><span class=en-original lang=en><a href="#conformance"><span class=secno>1.2 </span>Conformance |
| 176 |
wakaba |
1.1 |
requirements</a> |
| 177 |
wakaba |
1.36 |
</span><ul class=toc> |
| 178 |
|
|
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="8619e0a1e195d0ca9fae8f1318794847"><span class=en-original lang=en><a href="#dependencies"><span class=secno>1.2.1 |
| 179 |
wakaba |
1.1 |
</span>Dependencies</a> |
| 180 |
wakaba |
1.36 |
</span></ul> |
| 181 |
wakaba |
1.1 |
|
| 182 |
wakaba |
1.36 |
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="730d89342f815a1b4f8fc699ab5f1976"><span class=en-original lang=en><a href="#terminology"><span class=secno>1.3 </span>Terminology</a> |
| 183 |
|
|
</span></ul> |
| 184 |
wakaba |
1.9 |
|
| 185 |
wakaba |
1.36 |
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="22339fde584025951d7cb7d24876d946"><span class=en-original lang=en><a href="#infrastructure"><span class=secno>2. |
| 186 |
wakaba |
1.13 |
</span>Infrastructure</a> |
| 187 |
wakaba |
1.36 |
</span><ul class=toc> |
| 188 |
|
|
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="5763bf8b68038d9e7b7d492bd3ae7bab"><span class=en-original lang=en><a href="#the-global"><span class=secno>2.1 </span>The global |
| 189 |
wakaba |
1.29 |
scope</a> |
| 190 |
wakaba |
1.36 |
</span><ul class=toc> |
| 191 |
|
|
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="efb0edfb19efd26410cb99ab1525f948"><span class=en-original lang=en><a href="#the-workerglobalscope"><span class=secno>2.1.1 |
| 192 |
wakaba |
1.29 |
</span>The <code>WorkerGlobalScope</code> abstract interface</a> |
| 193 |
|
|
|
| 194 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="5f99bbc9217feadbd07b63a59fb5f291"><span class=en-original lang=en><a href="#dedicated"><span class=secno>2.1.2 </span>Dedicated |
| 195 |
wakaba |
1.29 |
workers and the <code>DedicatedWorkerGlobalScope</code> interface</a> |
| 196 |
|
|
|
| 197 |
|
|
|
| 198 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="ba3044d55b8091a7410ee51a58225f09"><span class=en-original lang=en><a href="#shared0"><span class=secno>2.1.3 </span>Shared workers |
| 199 |
wakaba |
1.29 |
and the <code>SharedWorkerGlobalScope</code> inteface</a> |
| 200 |
wakaba |
1.36 |
</span></ul> |
| 201 |
wakaba |
1.9 |
|
| 202 |
wakaba |
1.36 |
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="c2a16736e5155efbee09ceec52062868"><span class=en-original lang=en><a href="#base-urls"><span class=secno>2.2 </span>Base URLs and |
| 203 |
wakaba |
1.16 |
origins of workers</a> |
| 204 |
|
|
|
| 205 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="9381f86c38af340674795616ffa4729c"><span class=en-original lang=en><a href="#the-queue"><span class=secno>2.3 </span>The queue of |
| 206 |
wakaba |
1.9 |
events</a> |
| 207 |
|
|
|
| 208 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="9c88712c50f8e878f1e2900817520600"><span class=en-original lang=en><a href="#the-workers"><span class=secno>2.4 </span>The worker's |
| 209 |
wakaba |
1.11 |
ports</a> |
| 210 |
|
|
|
| 211 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="a6149718eb643990db06957bc18edefd"><span class=en-original lang=en><a href="#processing"><span class=secno>2.5 </span>Processing |
| 212 |
wakaba |
1.9 |
model</a> |
| 213 |
wakaba |
1.13 |
|
| 214 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="fdab759854cb648250afe4a81693b117"><span class=en-original lang=en><a href="#creating"><span class=secno>2.6 </span>Creating |
| 215 |
wakaba |
1.13 |
workers</a> |
| 216 |
wakaba |
1.36 |
</span><ul class=toc> |
| 217 |
|
|
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="77dfb5f9a16bd5b77a73bdd3617c760e"><span class=en-original lang=en><a href="#the-abstractworker"><span class=secno>2.6.1 </span>The |
| 218 |
wakaba |
1.29 |
<code>AbstractWorker</code> abstract interface</a> |
| 219 |
|
|
|
| 220 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="bbddb6f68afde611f94369aa5a0ad020"><span class=en-original lang=en><a href="#dedicated0"><span class=secno>2.6.2 </span>Dedicated |
| 221 |
wakaba |
1.29 |
workers and the <code>Worker</code> interface</a> |
| 222 |
|
|
|
| 223 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="1f5bc4a5d6e1eb7e6293adfe42e9818c"><span class=en-original lang=en><a href="#shared1"><span class=secno>2.6.3 </span>Shared workers |
| 224 |
wakaba |
1.29 |
and the <code>SharedWorker</code> interface</a> |
| 225 |
wakaba |
1.36 |
</span></ul> |
| 226 |
wakaba |
1.9 |
</ul> |
| 227 |
|
|
|
| 228 |
wakaba |
1.36 |
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="3d35781df14354dfc2fd4abccbffef0f"><span class=en-original lang=en><a href="#apis-available"><span class=secno>3. </span>APIs available |
| 229 |
wakaba |
1.13 |
to workers</a> |
| 230 |
wakaba |
1.36 |
</span><ul class=toc> |
| 231 |
|
|
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="72f3123f6e8b15f48de8a349c9982513"><span class=en-original lang=en><a href="#importing"><span class=secno>3.1 </span>Importing scripts |
| 232 |
wakaba |
1.22 |
and libraries</a> |
| 233 |
|
|
|
| 234 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="ea56a769d41d79030ee06c778b66eec8"><span class=en-original lang=en><a href="#apis-defined"><span class=secno>3.2 </span>APIs defined in |
| 235 |
wakaba |
1.22 |
other specifications</a> |
| 236 |
|
|
|
| 237 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="abf85892104e8b31ba276d5ea04756cb"><span class=en-original lang=en><a href="#interface"><span class=secno>3.3 </span>Interface objects |
| 238 |
wakaba |
1.22 |
and constructors</a> |
| 239 |
wakaba |
1.23 |
|
| 240 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="fef74b710ec14b1000a12c0272f2c6c9"><span class=en-original lang=en><a href="#worker0"><span class=secno>3.4 </span>Worker locations</a> |
| 241 |
wakaba |
1.23 |
|
| 242 |
wakaba |
1.36 |
</span></ul> |
| 243 |
wakaba |
1.1 |
|
| 244 |
wakaba |
1.36 |
<li class=no-num><p class="no-ja-translation ja-translation-inserted" data-ja-hash="e747237bceaf9dabea52363254fc5f16"><span class=en-original lang=en><a href="#references">References</a> |
| 245 |
wakaba |
1.1 |
|
| 246 |
wakaba |
1.36 |
</span><li class=no-num><p class="no-ja-translation ja-translation-inserted" data-ja-hash="f440038177834afbee04ac5e84ec86fe"><span class=en-original lang=en><a href="#acknowledgements">Acknowledgements</a> |
| 247 |
|
|
</span></ul> |
| 248 |
wakaba |
1.1 |
<!--end-toc--> |
| 249 |
|
|
|
| 250 |
|
|
<hr> |
| 251 |
|
|
|
| 252 |
wakaba |
1.36 |
<h2 id=introduction class="has-ja-translation" data-ja-hash="0b79795d3efc95b9976c7c5b933afce2"><span class=en-original lang=en><span class=secno>1. </span>Introduction</span><span class=ja-translation lang=ja><span class=secno>1. </span>はじめに</span></h2> |
| 253 |
wakaba |
1.32 |
|
| 254 |
wakaba |
1.36 |
<h3 id=tutorial class="has-ja-translation" data-ja-hash="368fe771261fcb18f7988833c9294a20"><span class=en-original lang=en><span class=secno>1.1 </span>Tutorial</span><span class=ja-translation lang=ja><span class=secno>1.1 </span>解説</span></h3> |
| 255 |
wakaba |
1.32 |
|
| 256 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="585b83d0801ae75a14554d8d2c737fb2"><span class=en-original lang=en><em>This section is non-normative.</em> |
| 257 |
wakaba |
1.32 |
|
| 258 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p class="has-ja-translation" data-ja-hash="c98bec741e84294c9feae0d581f897b6"><span class=en-original lang=en>There are a variety of uses that workers can be put to. The following |
| 259 |
wakaba |
1.32 |
subsections show various examples of this use. |
| 260 |
|
|
|
| 261 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>労働者は色々なことに使えます。次の各節では、色々な使い方の例を示します。</span><h4 id=a-background class="has-ja-translation" data-ja-hash="03100d1ee403be709f47c37e6b55c758"><span class=en-original lang=en><span class=secno>1.1.1 </span>A background |
| 262 |
wakaba |
1.32 |
number-crunching worker</span><span class=ja-translation lang=ja><span class=secno>1.1.1 </span>数値処理背景労働者</span></h4> |
| 263 |
|
|
|
| 264 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="585b83d0801ae75a14554d8d2c737fb2"><span class=en-original lang=en><em>This section is non-normative.</em> |
| 265 |
wakaba |
1.1 |
|
| 266 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p class="has-ja-translation" data-ja-hash="6656ef1c2fd445878e165388d704a723"><span class=en-original lang=en>The simplest use of workers is for performing a computationally |
| 267 |
wakaba |
1.32 |
expensive task without interrupting the user interface. |
| 268 |
wakaba |
1.1 |
|
| 269 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>労働者の一番単純な用法は、計算的に高価な仕事を利用者界面を中断させずに実行するというものです。</span><p class="has-ja-translation" data-ja-hash="14941a1ddb566828a9181bcecf3a815a"><span class=en-original lang=en>In this example, the main document spawns a worker to (naïvely) |
| 270 |
wakaba |
1.32 |
compute prime numbers, and progressively displays the most recently found |
| 271 |
|
|
prime number. |
| 272 |
wakaba |
1.23 |
|
| 273 |
wakaba |
1.32 |
</span><span class=ja-translation lang=ja>この例では、主たる文書が労働者を作って素数を (素朴な方法で) 計算させ、 |
| 274 |
wakaba |
1.36 |
新しく見つかった素数を順番に表示してゆきます。</span><p class="has-ja-translation" data-ja-hash="97bcf42c4070cbcef605cfa277d832fb"><span class=en-original lang=en>The main page is as follows: |
| 275 |
wakaba |
1.32 |
|
| 276 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>主たる頁は次の通りです。</span><pre class="no-ja-translation" data-ja-hash="e8bd10631ee762066326ed419261ed21"><span class=en-original lang=en><!DOCTYPE HTML> |
| 277 |
wakaba |
1.23 |
<html> |
| 278 |
|
|
<head> |
| 279 |
|
|
<title>Worker example: One-core computation</title> |
| 280 |
|
|
</head> |
| 281 |
|
|
<body> |
| 282 |
|
|
<p>The highest prime number discovered so far is: <output id="result"></output></p> |
| 283 |
|
|
<script> |
| 284 |
wakaba |
1.29 |
var worker = new Worker('worker.js'); |
| 285 |
|
|
worker.onmessage = function (event) { |
| 286 |
wakaba |
1.23 |
document.getElementById('result').textContent = event.message; |
| 287 |
|
|
}; |
| 288 |
|
|
</script> |
| 289 |
|
|
</body> |
| 290 |
wakaba |
1.36 |
</html></span></pre> |
| 291 |
wakaba |
1.23 |
|
| 292 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="e4adb9b72fb3bd211cbc81bffd5d4622"><span class=en-original lang=en>The <code title=dom-Worker><a href="#worker2">Worker()</a></code> |
| 293 |
wakaba |
1.30 |
constructor call creates a worker and returns a <code><a |
| 294 |
|
|
href="#worker1">Worker</a></code> object representing that worker, which |
| 295 |
|
|
is used to communicate with the worker. That object's <code |
| 296 |
|
|
title=handler-Worker-onmessage><a href="#onmessage0">onmessage</a></code> |
| 297 |
|
|
event handler attribute allows the code to receive messages from the |
| 298 |
|
|
worker. |
| 299 |
wakaba |
1.23 |
|
| 300 |
wakaba |
1.36 |
</span><p class="has-ja-translation" data-ja-hash="12a62a74d5156b6d85136f5fc41a4ee1"><span class=en-original lang=en>The worker itself is as follows: |
| 301 |
wakaba |
1.32 |
|
| 302 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>労働者自体は次の通りです。</span><pre class="no-ja-translation" data-ja-hash="35390f08d92125ad461fd6bb5969cb0c"><span class=en-original lang=en>var n = 1; |
| 303 |
wakaba |
1.23 |
search: while (true) { |
| 304 |
|
|
n += 1; |
| 305 |
|
|
for (var i = 2; i <= Math.sqrt(n); i += 1) |
| 306 |
|
|
if (n % i == 0) |
| 307 |
|
|
continue search; |
| 308 |
|
|
// found a prime! |
| 309 |
wakaba |
1.29 |
postMessage(n); |
| 310 |
wakaba |
1.36 |
}</span></pre> |
| 311 |
wakaba |
1.23 |
|
| 312 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="6cbc84e07a533681566aa4fdf838f852"><span class=en-original lang=en>The bulk of this code is simply an unoptimised search for a prime |
| 313 |
wakaba |
1.23 |
number. To send a message back to the page, the <code |
| 314 |
wakaba |
1.30 |
title=dom-DedicatedWorkerGlobalScope-postMessage><a |
| 315 |
|
|
href="#postmessage">postMessage()</a></code> method is used to post a |
| 316 |
|
|
message when a prime is found. |
| 317 |
wakaba |
1.23 |
|
| 318 |
wakaba |
1.36 |
</span><p class="has-ja-translation" data-ja-hash="add583522732edb8aca6202c451ddb27" data-ja-real-hash="fb1b85e403d4ca967bb53b221e757de8"><span class=en-original lang=en><a href="http://www.whatwg.org/demos/workers/primes/page.html">View this |
| 319 |
wakaba |
1.32 |
example online</a>. |
| 320 |
|
|
|
| 321 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><a href="http://www.whatwg.org/demos/workers/primes/page.html">この例をオンラインで表示する</a>。</span><h4 id=a-worker class="has-ja-translation" data-ja-hash="be08cb921deb5e88f7dcb3edbd9f0274"><span class=en-original lang=en><span class=secno>1.1.2 </span>A worker for updating a |
| 322 |
|
|
client-side database</span><span class=ja-translation lang=ja><span class=secno>1.1.2 </span>クライアント側データベースの更新のための労働者</span></h4> |
| 323 |
wakaba |
1.23 |
|
| 324 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="585b83d0801ae75a14554d8d2c737fb2"><span class=en-original lang=en><em>This section is non-normative.</em> |
| 325 |
wakaba |
1.32 |
|
| 326 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p class="no-ja-translation" data-ja-hash="e8e4acfb27dabd6fd72aa5a4af7b7d25"><span class=en-original lang=en>In this example, the main document spawns a worker whose only task is to |
| 327 |
wakaba |
1.23 |
listen for notifications from the server, and, when appropriate, either |
| 328 |
|
|
add or remove data from the client-side database. |
| 329 |
|
|
|
| 330 |
wakaba |
1.36 |
</span><p class="has-ja-translation" data-ja-hash="88e890f11b614dc40f4d2453a66ec94f"><span class=en-original lang=en>Since no communication occurs between the worker and the main page, the |
| 331 |
wakaba |
1.23 |
main page can start the worker by just doing: |
| 332 |
|
|
|
| 333 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>労働者と主たる頁の間に通信は発生しませんので、 |
| 334 |
|
|
主たる頁は単に次のようにするだけで労働者を開始できます。</span><pre class="no-ja-translation" data-ja-hash="1fa3b8ca6e1be5ba6915c7164f359cf2"><span class=en-original lang=en><script> |
| 335 |
wakaba |
1.30 |
new Worker('worker.js'); |
| 336 |
wakaba |
1.36 |
</script></span></pre> |
| 337 |
wakaba |
1.23 |
|
| 338 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="12a62a74d5156b6d85136f5fc41a4ee1"><span class=en-original lang=en>The worker itself is as follows: |
| 339 |
wakaba |
1.32 |
|
| 340 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>労働者自体は次の通りです。</span><pre class="no-ja-translation" data-ja-hash="814f799d67c5f0521f48e2da2bcdbb3f"><span class=en-original lang=en>var server = new WebSocket('ws://whatwg.org/database'); |
| 341 |
wakaba |
1.25 |
var database = openDatabase('demobase', '1.0', 'Demo Database', 10240); |
| 342 |
wakaba |
1.23 |
server.onmessage = function (event) { |
| 343 |
|
|
// data is in the format "command key value" |
| 344 |
|
|
var data = event.message.split(' '); |
| 345 |
|
|
switch (data[0]) { |
| 346 |
|
|
case '+': |
| 347 |
|
|
database.transaction(function(tx) { |
| 348 |
|
|
tx.executeSql('INSERT INTO pairs (key, value) VALUES (?, ?)', data[1], data[2]); |
| 349 |
|
|
}); |
| 350 |
|
|
case '-': |
| 351 |
|
|
database.transaction(function(tx) { |
| 352 |
|
|
tx.executeSql('DELETE FROM pairs WHERE key=? AND value=?', data[1], data[2]); |
| 353 |
|
|
}); |
| 354 |
|
|
} |
| 355 |
wakaba |
1.36 |
};</span></pre> |
| 356 |
wakaba |
1.23 |
|
| 357 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="a1cc8d58962bdce2c6a6e894760e8bf7"><span class=en-original lang=en>This connects to the server using the <code>WebSocket</code> mechanism |
| 358 |
wakaba |
1.23 |
and opens the local database (which, we presume, has been created |
| 359 |
|
|
earlier). The worker then just listens for messages from the worker and |
| 360 |
|
|
acts on them as appropriate, forever (or until the main page is closed). |
| 361 |
|
|
|
| 362 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="d47c2ada69bdfebeb58219610105a1d7"><span class=en-original lang=en><a |
| 363 |
wakaba |
1.23 |
href="http://www.whatwg.org/demos/workers/database-updater/page.html">View |
| 364 |
|
|
this example online</a>. (This example will not actually function, since |
| 365 |
|
|
the server does not actually exist and the database is not created by this |
| 366 |
|
|
sample code.) |
| 367 |
|
|
|
| 368 |
wakaba |
1.36 |
</span><h4 id=worker class="has-ja-translation" data-ja-hash="197e2193b05c0b9a50e860f5abfcf3f8"><span class=en-original lang=en><span class=secno>1.1.3 </span>Worker used for backgroud I/O</span><span class=ja-translation lang=ja><span class=secno>1.1.3 </span>背景入出力に使う労働者</span></h4> |
| 369 |
wakaba |
1.32 |
|
| 370 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="585b83d0801ae75a14554d8d2c737fb2"><span class=en-original lang=en><em>This section is non-normative.</em> |
| 371 |
wakaba |
1.23 |
|
| 372 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p class="has-ja-translation" data-ja-hash="eb288220a303d56acd4e151bca42fe6e"><span class=en-original lang=en>In this example, the main document uses two workers, one for fetching |
| 373 |
wakaba |
1.23 |
stock updates for at regular intervals, and one for fetching performing |
| 374 |
|
|
search queries that the user requests. |
| 375 |
|
|
|
| 376 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>この例では、主たる文書は2つの労働者を使います。 |
| 377 |
|
|
1つは一定間隔で株価の更新を取得するためのもので、もう1つは利用者の要求した検索の照会を行う取得のためのものです。</span><p class="has-ja-translation" data-ja-hash="97bcf42c4070cbcef605cfa277d832fb"><span class=en-original lang=en>The main page is as follows: |
| 378 |
wakaba |
1.32 |
|
| 379 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>主たる頁は次の通りです。</span><pre class="no-ja-translation" data-ja-hash="3c3d61b4acf5bdffe11e34cd3de14e1d"><span class=en-original lang=en><!DOCTYPE HTML> |
| 380 |
wakaba |
1.23 |
<html> |
| 381 |
|
|
<head> |
| 382 |
|
|
<title>Worker example: Stock ticker</title> |
| 383 |
|
|
<script> |
| 384 |
|
|
// TICKER |
| 385 |
|
|
var symbol = 'GOOG'; // default symbol to watch |
| 386 |
wakaba |
1.29 |
var ticker = new Worker('ticker.js'); |
| 387 |
wakaba |
1.23 |
|
| 388 |
|
|
// SEARCHER |
| 389 |
wakaba |
1.29 |
var searcher = new Worker('searcher.js'); |
| 390 |
wakaba |
1.23 |
function search(query) { |
| 391 |
wakaba |
1.29 |
searcher.postMessage(query); |
| 392 |
wakaba |
1.23 |
} |
| 393 |
|
|
|
| 394 |
|
|
// SYMBOL SELECTION UI |
| 395 |
|
|
function select(newSymbol) { |
| 396 |
|
|
symbol = newSymbol; |
| 397 |
wakaba |
1.29 |
ticker.postMessage(symbol); |
| 398 |
wakaba |
1.23 |
} |
| 399 |
|
|
</script> |
| 400 |
|
|
</head> |
| 401 |
|
|
<body> |
| 402 |
|
|
<p><output id="symbol"></output> <output id="value"></output></p> |
| 403 |
|
|
<script> |
| 404 |
wakaba |
1.29 |
ticker.onmessage = function (event) { |
| 405 |
wakaba |
1.23 |
var data = event.message.split(' '); |
| 406 |
|
|
document.getElementById('symbol').textContent = data[0]; |
| 407 |
|
|
document.getElementById('value').textContent = data[1]; |
| 408 |
|
|
}; |
| 409 |
wakaba |
1.29 |
ticker.postMessage(symbol); |
| 410 |
wakaba |
1.23 |
</script> |
| 411 |
|
|
<p><label>Search: <input type="text" oninput="search(this.value)"></label></p> |
| 412 |
|
|
<ul id="results"></ul> |
| 413 |
|
|
<script> |
| 414 |
wakaba |
1.29 |
searcher.onmessage = function (event) { |
| 415 |
wakaba |
1.23 |
var data = event.message.split(' '); |
| 416 |
|
|
var results = document.getElementById('results'); |
| 417 |
|
|
while (results.hasChildNodes()) // clear previous results |
| 418 |
|
|
results.removeChild(results.firstChild); |
| 419 |
|
|
for (var i = 0; i < data.length; i += 1) { |
| 420 |
|
|
// add a list item with a button for each result |
| 421 |
|
|
var li = document.createElement('li'); |
| 422 |
|
|
var button = document.createElement('button'); |
| 423 |
|
|
button.value = data[i]; |
| 424 |
|
|
button.type = 'button'; |
| 425 |
|
|
button.onclick = function () { select(this.value); }; |
| 426 |
|
|
button.textContent = data[i]; |
| 427 |
|
|
li.appendChild(button); |
| 428 |
|
|
results.appendChild(li); |
| 429 |
|
|
} |
| 430 |
|
|
}; |
| 431 |
|
|
</script> |
| 432 |
|
|
<p>(The data in this example is not real. Try searching for "Google" or "Apple".)</p> |
| 433 |
|
|
</body> |
| 434 |
wakaba |
1.36 |
</html></span></pre> |
| 435 |
wakaba |
1.23 |
|
| 436 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="4cc7e781e44db82f8bd32020954bb94a"><span class=en-original lang=en>The two workers use a common library for performing the actual network |
| 437 |
wakaba |
1.23 |
calls. This library is as follows: |
| 438 |
|
|
|
| 439 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>両労働者は実際のネットワークの呼び出しを行う共通のライブラリーを使います。 |
| 440 |
|
|
このライブラリーは次の通りです。</span><pre class="no-ja-translation" data-ja-hash="764d750a19834bf904d276466724339c"><span class=en-original lang=en>function get(url) { |
| 441 |
wakaba |
1.29 |
try { |
| 442 |
|
|
var xhr = new XMLHttpRequest(); |
| 443 |
|
|
xhr.open('GET', url, false); |
| 444 |
|
|
xhr.send(); |
| 445 |
|
|
return xhr.responseText; |
| 446 |
|
|
} catch (e) { |
| 447 |
|
|
return ''; // turn all errors into empty results |
| 448 |
|
|
} |
| 449 |
wakaba |
1.36 |
}</span></pre> |
| 450 |
wakaba |
1.23 |
|
| 451 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="ee10423864c33d68e8676bf88cb75046"><span class=en-original lang=en>The stock updater worker is as follows: |
| 452 |
wakaba |
1.23 |
|
| 453 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>株価更新者の労働者は次の通りです。</span><pre class="no-ja-translation" data-ja-hash="7a20f63d28ecc1a3ebed633b0dfeb633"><span class=en-original lang=en>importScripts('io.js'); |
| 454 |
wakaba |
1.23 |
var timer; |
| 455 |
|
|
var symbol; |
| 456 |
|
|
function update() { |
| 457 |
wakaba |
1.29 |
postMessage(symbol + ' ' + get('stock.cgi?' + symbol)); |
| 458 |
wakaba |
1.23 |
timer = setTimeout(update, 10000); |
| 459 |
|
|
} |
| 460 |
wakaba |
1.29 |
onmessage = function (event) { |
| 461 |
wakaba |
1.23 |
if (timer) |
| 462 |
|
|
clearTimeout(timer); |
| 463 |
|
|
symbol = event.message; |
| 464 |
|
|
update(); |
| 465 |
wakaba |
1.36 |
};</span></pre> |
| 466 |
wakaba |
1.23 |
|
| 467 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="aa6a78ceb7b91cdf90925cc36c6c6676"><span class=en-original lang=en>The search query worker is as follows: |
| 468 |
wakaba |
1.23 |
|
| 469 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>検索の照会の労働者は次の通りです。</span><pre class="no-ja-translation" data-ja-hash="b9632108e06f2a95a7d6f27a8d5ddb2b"><span class=en-original lang=en>importScripts('io.js'); |
| 470 |
wakaba |
1.29 |
onmessage = function (event) { |
| 471 |
|
|
postMessage(get('search.cgi?' + event.message)); |
| 472 |
wakaba |
1.36 |
};</span></pre> |
| 473 |
wakaba |
1.23 |
|
| 474 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="add583522732edb8aca6202c451ddb27" data-ja-real-hash="9b529b56f810a73a138b067e5dfe89cd"><span class=en-original lang=en><a href="http://www.whatwg.org/demos/workers/stocks/page.html">View this |
| 475 |
wakaba |
1.32 |
example online</a>. |
| 476 |
wakaba |
1.23 |
|
| 477 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><a href="http://www.whatwg.org/demos/workers/stocks/page.html">この例をオンラインで表示する</a>。</span><h4 id=shared class="has-ja-translation" data-ja-hash="634755c2f50b08b49a82f30428b1a961"><span class=en-original lang=en><span class=secno>1.1.4 </span>Shared workers</span><span class=ja-translation lang=ja><span class=secno>1.1.4 </span>共有労働者</span></h4> |
| 478 |
wakaba |
1.32 |
|
| 479 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="585b83d0801ae75a14554d8d2c737fb2"><span class=en-original lang=en><em>This section is non-normative.</em> |
| 480 |
wakaba |
1.32 |
|
| 481 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p class="has-ja-translation" data-ja-hash="b476f90148996ef66922f03da98ee7ec"><span class=en-original lang=en>In this example, multiple windows (viewers) can be opened that are all |
| 482 |
wakaba |
1.23 |
viewing the same map. All the windows share the same map information, with |
| 483 |
|
|
a single worker coordinating all the viewers. Each viewer can move around |
| 484 |
|
|
idependently, but if they set any data on the map, all the viewers are |
| 485 |
|
|
updated. |
| 486 |
|
|
|
| 487 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>この例では、複数の窓 (表示器) を開いて、そのすべてで同じ地図を表示することができます。 |
| 488 |
|
|
すべての窓は、すべての表示器の間の調整を行う1つの労働者により、同じ地図情報を共有します。 |
| 489 |
|
|
各表示器は独立して移動することができますが、 |
| 490 |
|
|
いずれかの表示器が地図上にデータを設定すると、 |
| 491 |
|
|
すべての表示器が更新されます。</span><p class="has-ja-translation" data-ja-hash="2bf6969d7d27e56c707ae9970fdd476f"><span class=en-original lang=en>The main page isn't interesting, it merely provides a way to open the |
| 492 |
wakaba |
1.23 |
viewers: |
| 493 |
|
|
|
| 494 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>主たる頁は特に何もなく、単に表示器を開くためだけのものです。</span><pre class="no-ja-translation" data-ja-hash="55a104a8ba6c7596b2ca462c2ffb1f0a"><span class=en-original lang=en><!DOCTYPE HTML> |
| 495 |
wakaba |
1.23 |
<html> |
| 496 |
|
|
<head> |
| 497 |
|
|
<title>Workers example: Multiviewer</title> |
| 498 |
|
|
<script> |
| 499 |
|
|
function openViewer() { |
| 500 |
|
|
window.open('viewer.html'); |
| 501 |
|
|
} |
| 502 |
|
|
</script> |
| 503 |
|
|
</head> |
| 504 |
|
|
<body> |
| 505 |
|
|
<p><button type=button onclick="openViewer()">Open a new |
| 506 |
|
|
viewer</button></p> |
| 507 |
|
|
<p>Each viewer opens in a new window. You can have as many viewers |
| 508 |
|
|
as you like, they all view the same data.</p> |
| 509 |
|
|
</body> |
| 510 |
wakaba |
1.36 |
</html></span></pre> |
| 511 |
wakaba |
1.23 |
|
| 512 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="cee02afe1e87e7182f5219ccf54757ca"><span class=en-original lang=en>The viewer is more involved: |
| 513 |
wakaba |
1.23 |
|
| 514 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>表示器はもっと色々しています。</span><pre class="no-ja-translation" data-ja-hash="62097120b73be5f6ec8054ee2395c4f7"><span class=en-original lang=en><!DOCTYPE HTML> |
| 515 |
wakaba |
1.23 |
<html> |
| 516 |
|
|
<head> |
| 517 |
|
|
<title>Workers example: Multiviewer viewer</title> |
| 518 |
|
|
<script> |
| 519 |
wakaba |
1.29 |
var worker = new SharedWorker('worker.js', 'core'); |
| 520 |
wakaba |
1.23 |
|
| 521 |
|
|
// CONFIGURATION |
| 522 |
|
|
function configure(event) { |
| 523 |
|
|
if (event.message.substr(0, 4) != 'cfg ') return; |
| 524 |
|
|
var name = event.message.substr(4).split(' ', 1); |
| 525 |
|
|
// update display to mention our name is name |
| 526 |
|
|
document.getElementsByTagName('h1')[0].textContent += ' ' + name; |
| 527 |
|
|
// no longer need this listener |
| 528 |
wakaba |
1.25 |
worker.port.removeEventListener('message', configure, false); |
| 529 |
wakaba |
1.23 |
} |
| 530 |
wakaba |
1.30 |
worker.port.addEventListener('message', configure, false); |
| 531 |
wakaba |
1.23 |
|
| 532 |
|
|
// MAP |
| 533 |
|
|
function paintMap(event) { |
| 534 |
|
|
if (event.message.substr(0, 4) != 'map ') return; |
| 535 |
|
|
var data = event.message.substr(4).split(','); |
| 536 |
|
|
// display tiles data[0] .. data[8] |
| 537 |
|
|
var canvas = document.getElementById('map'); |
| 538 |
|
|
var context = canvas.getContext('2d'); |
| 539 |
|
|
for (var y = 0; y < 3; y += 1) { |
| 540 |
|
|
for (var x = 0; x < 3; x += 1) { |
| 541 |
|
|
var tile = data[y * 3 + x]; |
| 542 |
|
|
if (tile == '0') |
| 543 |
|
|
context.fillStyle = 'green'; |
| 544 |
|
|
else |
| 545 |
|
|
context.fillStyle = 'maroon'; |
| 546 |
|
|
fillRect(x * 50, y * 50, 50, 50); |
| 547 |
|
|
} |
| 548 |
|
|
} |
| 549 |
|
|
} |
| 550 |
wakaba |
1.30 |
worker.port.addEventListener('message', paintMap, false); |
| 551 |
wakaba |
1.23 |
|
| 552 |
|
|
// PUBLIC CHAT |
| 553 |
|
|
function updatePublicChat(event) { |
| 554 |
|
|
if (event.message.substr(0, 4) != 'txt ') return; |
| 555 |
|
|
var name = event.message.substr(4).split(' ', 1); |
| 556 |
|
|
var message = event.message.substr(4 + length(name) + 1); |
| 557 |
|
|
// display "<name> message" in public chat |
| 558 |
|
|
var dialog = document.getElementById('public'); |
| 559 |
|
|
var dt = document.createElement('dt'); |
| 560 |
|
|
dt.textContent = name; |
| 561 |
|
|
dialog.appendChild(dt); |
| 562 |
|
|
var dd = document.createElement('dd'); |
| 563 |
|
|
dd.textContent = message; |
| 564 |
|
|
dialog.appendChild(dd); |
| 565 |
|
|
} |
| 566 |
wakaba |
1.30 |
worker.port.addEventListener('message', updatePublicChat, false); |
| 567 |
wakaba |
1.23 |
|
| 568 |
|
|
// PRIVATE CHAT |
| 569 |
|
|
function startPrivateChat(event) { |
| 570 |
|
|
if (event.message.substr(0, 4) != 'msg ') return; |
| 571 |
|
|
var name = event.message.substr(4).split(' ', 1); |
| 572 |
|
|
var port = event.port; |
| 573 |
|
|
// display a private chat UI |
| 574 |
|
|
var ul = document.getElementById('private'); |
| 575 |
|
|
var li = document.createElement('li'); |
| 576 |
|
|
var h3 = document.createElement('h3'); |
| 577 |
|
|
h3.textContent = 'Private chat with ' + name; |
| 578 |
|
|
li.appendChild(h3); |
| 579 |
|
|
var dialog = document.createElement('dialog'); |
| 580 |
|
|
var addMessage = function(name, message) { |
| 581 |
|
|
var dt = document.createElement('dt'); |
| 582 |
|
|
dt.textContent = name; |
| 583 |
|
|
dialog.appendChild(dt); |
| 584 |
|
|
var dd = document.createElement('dd'); |
| 585 |
|
|
dd.textContent = message; |
| 586 |
|
|
dialog.appendChild(dd); |
| 587 |
|
|
}; |
| 588 |
|
|
port.onmessage = function (event) { |
| 589 |
|
|
addMessage(name, event.message); |
| 590 |
|
|
}; |
| 591 |
|
|
li.appendChild(dialog); |
| 592 |
|
|
var form = document.createElement('form'); |
| 593 |
|
|
var p = document.createElement('p'); |
| 594 |
|
|
var input = document.createElement('input'); |
| 595 |
|
|
input.size = 50; |
| 596 |
|
|
p.appendChild(input); |
| 597 |
|
|
p.appendChild(document.createTextNode(' ')); |
| 598 |
|
|
var button = document.createElement('button'); |
| 599 |
|
|
button.textContent = 'Post'; |
| 600 |
|
|
p.appendChild(button); |
| 601 |
|
|
form.onsubmit = function () { |
| 602 |
|
|
port.postMessage(input.value); |
| 603 |
|
|
addMessage('me', input.value); |
| 604 |
|
|
input.value = ''; |
| 605 |
|
|
return false; |
| 606 |
|
|
}; |
| 607 |
|
|
form.appendChild(p); |
| 608 |
|
|
li.appendChild(form); |
| 609 |
|
|
} |
| 610 |
wakaba |
1.30 |
worker.port.addEventListener('message', startPrivateChat, false); |
| 611 |
wakaba |
1.23 |
</script> |
| 612 |
|
|
</head> |
| 613 |
wakaba |
1.29 |
<body> |
| 614 |
wakaba |
1.23 |
<h1>Viewer</h1> |
| 615 |
|
|
<h2>Map</h2> |
| 616 |
|
|
<p><canvas id="map" height=150 width=150></canvas></p> |
| 617 |
|
|
<p> |
| 618 |
wakaba |
1.30 |
<button type=button onclick="worker.port.postMessage('mov left')">Left</button> |
| 619 |
|
|
<button type=button onclick="worker.port.postMessage('mov up')">Up</button> |
| 620 |
|
|
<button type=button onclick="worker.port.postMessage('mov down')">Down</button> |
| 621 |
|
|
<button type=button onclick="worker.port.postMessage('mov right')">Right</button> |
| 622 |
|
|
<button type=button onclick="worker.port.postMessage('set 0')">Set 0</button> |
| 623 |
|
|
<button type=button onclick="worker.port.postMessage('set 1')">Set 1</button> |
| 624 |
wakaba |
1.23 |
</p> |
| 625 |
|
|
<h2>Public Chat</h2> |
| 626 |
|
|
<dialog id="public"></dialog> |
| 627 |
wakaba |
1.30 |
<form onsubmit="worker.port.postMessage('txt ' + message.value); message.value = ''; return false;"> |
| 628 |
wakaba |
1.23 |
<p> |
| 629 |
|
|
<input type="text" name="message" size="50"> |
| 630 |
|
|
<button>Post</button> |
| 631 |
|
|
</p> |
| 632 |
|
|
</form> |
| 633 |
|
|
<h2>Private Chat</h2> |
| 634 |
|
|
<ul id="private"></ul> |
| 635 |
|
|
</body> |
| 636 |
wakaba |
1.25 |
</html> |
| 637 |
wakaba |
1.36 |
</span></pre> |
| 638 |
wakaba |
1.23 |
|
| 639 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="397850dab731150b72d5f0276dab0081"><span class=en-original lang=en>There are several key things worth noting about the way the viewer is |
| 640 |
wakaba |
1.23 |
written. |
| 641 |
|
|
|
| 642 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>表示器の書き方についていくつか注意したい重要な点があります。</span><p class="has-ja-translation" data-ja-hash="8bc9c1f9e0e102128838ea8c31c51306"><span class=en-original lang=en><strong>Multiple listeners</strong>. Instead of a single message |
| 643 |
wakaba |
1.23 |
processing function, the code here attaches multiple event listeners, each |
| 644 |
|
|
one performing a quick check to see if it is relevant for the message. In |
| 645 |
|
|
this example it doesn't make much difference, but if multiple authors |
| 646 |
|
|
wanted to collaborate using a single port to communicate with a worker, it |
| 647 |
|
|
would allow for independent code instead of changes having to all be made |
| 648 |
|
|
to a single event handling function. |
| 649 |
|
|
|
| 650 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><strong>複数の聴取器</strong>。この符号では、メッセージ処理関数を1つ用意する代わりに、 |
| 651 |
|
|
複数の事象聴取器を付与し、それぞれが、それがメッセージに関連するかどうかを見るためにさらりと検査を行っています。 |
| 652 |
|
|
この例では大きな違いにはなりませんが、複数の著者が労働者と通信するために1つのポートを使って協調したい場合には、 |
| 653 |
|
|
独立した符号にできるので変更がある度に1つの事象取扱関数をいじらざるを得なくて済みます。</span><p class="no-ja-translation" data-ja-hash="ce2f17c1c25589a0d4507c6fa9c1f532"><span class=en-original lang=en>Registering event listeners in this way also allows you to unregister |
| 654 |
wakaba |
1.23 |
specific listeners when you are done with them, as is done with the <code |
| 655 |
|
|
title="">configure()</code> method in this example. |
| 656 |
|
|
|
| 657 |
wakaba |
1.36 |
</span><p class="has-ja-translation" data-ja-hash="4eb1fa2095f65662225da4c52db274f1"><span class=en-original lang=en>Finally, the worker: |
| 658 |
wakaba |
1.23 |
|
| 659 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>最後に、労働者は次のようになります。</span><pre class="no-ja-translation" data-ja-hash="23b4ed66594b3fe83759b319e2e43a8c"><span class=en-original lang=en> |
| 660 |
wakaba |
1.23 |
var nextName = 0; |
| 661 |
|
|
function getNextName() { |
| 662 |
|
|
// this could use more friendly names |
| 663 |
|
|
// but for now just return a number |
| 664 |
|
|
return nextName++; |
| 665 |
|
|
} |
| 666 |
|
|
|
| 667 |
|
|
var map = [ |
| 668 |
|
|
[0, 0, 0, 0, 0, 0, 0], |
| 669 |
|
|
[1, 1, 0, 1, 0, 1, 1], |
| 670 |
|
|
[0, 1, 0, 1, 0, 0, 0], |
| 671 |
|
|
[0, 1, 0, 1, 0, 1, 1], |
| 672 |
|
|
[0, 0, 0, 1, 0, 0, 0], |
| 673 |
|
|
[1, 0, 0, 1, 1, 1, 1], |
| 674 |
|
|
[1, 1, 0, 1, 1, 0, 1], |
| 675 |
|
|
]; |
| 676 |
|
|
|
| 677 |
|
|
function wrapX(x) { |
| 678 |
|
|
if (x < 0) return wrapX(x + map[0].length); |
| 679 |
|
|
if (x >= map[0].length) return wrapX(x - map[0].length); |
| 680 |
|
|
return x; |
| 681 |
|
|
} |
| 682 |
|
|
|
| 683 |
|
|
function wrapY(y) { |
| 684 |
|
|
if (y < 0) return wrapY(y + map.length); |
| 685 |
|
|
if (y >= map[0].length) return wrapY(y - map.length); |
| 686 |
|
|
return y; |
| 687 |
|
|
} |
| 688 |
|
|
|
| 689 |
wakaba |
1.29 |
function sendMapData(callback) { |
| 690 |
wakaba |
1.23 |
var data = ''; |
| 691 |
|
|
for (var y = viewer.y-1; y <= viewer.y+1; y += 1) { |
| 692 |
|
|
for (var x = viewer.x-1; x <= viewer.x+1; x += 1) { |
| 693 |
|
|
if (data != '') |
| 694 |
|
|
data += ','; |
| 695 |
|
|
data += map[y][x]; |
| 696 |
|
|
} |
| 697 |
|
|
} |
| 698 |
wakaba |
1.29 |
callback('map ' + data); |
| 699 |
wakaba |
1.23 |
} |
| 700 |
|
|
|
| 701 |
|
|
var viewers = {}; |
| 702 |
|
|
onconnect = function (event) { |
| 703 |
|
|
event.port._name = getNextName(); |
| 704 |
|
|
event.port._data = { port: event.port, x: 0, y: 0, }; |
| 705 |
|
|
viewers[event.port._name] = event.port._data; |
| 706 |
|
|
event.port.postMessage('cfg ' + name); |
| 707 |
|
|
event.port.onmessage = getMessage; |
| 708 |
wakaba |
1.29 |
sendMapData(event.port.postMessage); |
| 709 |
wakaba |
1.23 |
}; |
| 710 |
|
|
|
| 711 |
|
|
function getMessage(event) { |
| 712 |
|
|
switch (event.message.substr(0, 4)) { |
| 713 |
|
|
case 'mov ': |
| 714 |
|
|
var direction = event.message.substr(4); |
| 715 |
|
|
var dx = 0; |
| 716 |
|
|
var dy = 0; |
| 717 |
|
|
switch (direction) { |
| 718 |
|
|
case 'up': dy = -1; break; |
| 719 |
|
|
case 'down': dy = 1; break; |
| 720 |
|
|
case 'left': dx = -1; break; |
| 721 |
|
|
case 'right': dx = 1; break; |
| 722 |
|
|
} |
| 723 |
|
|
event.target._data.x = wrapX(event.target._data.x + dx); |
| 724 |
|
|
event.target._data.y = wrapY(event.target._data.y + dy); |
| 725 |
wakaba |
1.29 |
sendMapData(event.target.postMessage); |
| 726 |
wakaba |
1.23 |
break; |
| 727 |
|
|
case 'set ': |
| 728 |
|
|
var value = event.message.substr(4); |
| 729 |
|
|
map[event.target._data.y][event.target._data.x] = value; |
| 730 |
|
|
for (var viewer in viewers) |
| 731 |
wakaba |
1.29 |
sendMapData(viewers[viewer].port.postMessage); |
| 732 |
wakaba |
1.23 |
break; |
| 733 |
|
|
case 'txt ': |
| 734 |
|
|
var name = event.target._name; |
| 735 |
|
|
var message = event.message.substr(4); |
| 736 |
|
|
for (var viewer in viewers) |
| 737 |
|
|
viewers[viewer].port.postMessage('txt ' + name + ' ' + message); |
| 738 |
|
|
break; |
| 739 |
|
|
case 'msg ': |
| 740 |
|
|
var party1 = event._data; |
| 741 |
|
|
var party2 = viewers[event.message.substr(4).split(' ', 1)]; |
| 742 |
|
|
if (party2) { |
| 743 |
|
|
var channel = new MessageChannel(); |
| 744 |
|
|
party1.port.postMessage('msg ' + party2.name, channel.port1); |
| 745 |
|
|
party2.port.postMessage('msg ' + party1.name, channel.port2); |
| 746 |
|
|
} |
| 747 |
|
|
break; |
| 748 |
|
|
} |
| 749 |
wakaba |
1.36 |
}</span></pre> |
| 750 |
wakaba |
1.23 |
|
| 751 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="b0014972506b918202f48b09f30424bd"><span class=en-original lang=en><strong>Connecting to multiple pages</strong>. The script uses the <code |
| 752 |
wakaba |
1.30 |
title=handler-SharedWorkerGlobalScope-onconnect><a |
| 753 |
|
|
href="#onconnect">onconnect</a></code> event listener to listen for |
| 754 |
|
|
multiple connections. |
| 755 |
wakaba |
1.23 |
|
| 756 |
wakaba |
1.36 |
</span><p class="has-ja-translation" data-ja-hash="5ce666b6338718b46fb0dee22dbea88c"><span class=en-original lang=en><strong>Direct channels</strong>. When the worker receives a "msg" |
| 757 |
wakaba |
1.23 |
message from one viewer naming another viewer, it sets up a direct |
| 758 |
|
|
connection between the two, so that the two viewers can communicate |
| 759 |
|
|
directly without the worker having to proxy all the messages. |
| 760 |
|
|
|
| 761 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><strong>直接通信路</strong>。労働者がある閲覧器から他の閲覧器を名指した「msg」メッセージを受信した時は、 |
| 762 |
|
|
両者間の直接の接続を設定し、労働者がすべてのメッセージを仲介せずとも両閲覧器が直接通信できるようにします。</span><p class="has-ja-translation" data-ja-hash="add583522732edb8aca6202c451ddb27" data-ja-real-hash="4c5ed82f8da671a56292686cc3a60981"><span class=en-original lang=en><a href="http://www.whatwg.org/demos/workers/multiviewer/page.html">View |
| 763 |
wakaba |
1.32 |
this example online</a>. |
| 764 |
|
|
|
| 765 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><a href="http://www.whatwg.org/demos/workers/multiviewer/page.html">この例をオンラインで表示する</a>。</span><h4 id=delegation class="has-ja-translation" data-ja-hash="57b11d3816e9f83adb4dd2ecb2a311b5"><span class=en-original lang=en><span class=secno>1.1.5 </span>Delegation</span><span class=ja-translation lang=ja><span class=secno>1.1.5 </span>委譲</span></h4> |
| 766 |
wakaba |
1.23 |
|
| 767 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="585b83d0801ae75a14554d8d2c737fb2"><span class=en-original lang=en><em>This section is non-normative.</em> |
| 768 |
wakaba |
1.32 |
|
| 769 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p class="no-ja-translation" data-ja-hash="318b797bf0c9a2cdaa476f36993911b4"><span class=en-original lang=en>With multicore CPUs becoming prevalent, one way to obtain better |
| 770 |
wakaba |
1.23 |
performance is to split computationally expensive tasks amongst multiple |
| 771 |
|
|
workers. In this example, a computationally expensive task that is to be |
| 772 |
|
|
performed for every number from 1 to 10,000,000 is farmed out to ten |
| 773 |
|
|
subworkers. |
| 774 |
|
|
|
| 775 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="c5074121435848ef6ad420f030cb5060"><span class=en-original lang=en>The main page is as follows, it just reports the result: |
| 776 |
wakaba |
1.23 |
|
| 777 |
wakaba |
1.36 |
</span><pre class="no-ja-translation" data-ja-hash="e8bd10631ee762066326ed419261ed21"><span class=en-original lang=en><!DOCTYPE HTML> |
| 778 |
wakaba |
1.23 |
<html> |
| 779 |
|
|
<head> |
| 780 |
|
|
<title>Worker example: One-core computation</title> |
| 781 |
|
|
</head> |
| 782 |
|
|
<body> |
| 783 |
|
|
<p>The highest prime number discovered so far is: <output id="result"></output></p> |
| 784 |
|
|
<script> |
| 785 |
wakaba |
1.29 |
var worker = new Worker('worker.js'); |
| 786 |
|
|
worker.onmessage = function (event) { |
| 787 |
wakaba |
1.23 |
document.getElementById('result').textContent = event.message; |
| 788 |
|
|
}; |
| 789 |
|
|
</script> |
| 790 |
|
|
</body> |
| 791 |
wakaba |
1.36 |
</html></span></pre> |
| 792 |
wakaba |
1.23 |
|
| 793 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="12a62a74d5156b6d85136f5fc41a4ee1"><span class=en-original lang=en>The worker itself is as follows: |
| 794 |
wakaba |
1.32 |
|
| 795 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>労働者自体は次の通りです。</span><pre class="no-ja-translation" data-ja-hash="d71b424305ee63bc663d41e1ea819176"><span class=en-original lang=en>// settings |
| 796 |
wakaba |
1.23 |
var num_workers = 10; |
| 797 |
|
|
var items_per_worker = 1000000; |
| 798 |
|
|
|
| 799 |
|
|
// start the workers |
| 800 |
|
|
var result = 0; |
| 801 |
|
|
var pending_workers = num_workers; |
| 802 |
|
|
for (var i = 0; i < num_workers; i += 1) { |
| 803 |
wakaba |
1.29 |
var worker = new Worker('core.js'); |
| 804 |
|
|
worker.postMessage(i * items_per_worker); |
| 805 |
|
|
worker.postMessage((i+1) * items_per_worker); |
| 806 |
|
|
worker.onmessage = storeResult; |
| 807 |
wakaba |
1.23 |
} |
| 808 |
|
|
|
| 809 |
|
|
// handle the results |
| 810 |
|
|
function storeResult(event) { |
| 811 |
|
|
result += 1*event.message; |
| 812 |
|
|
pending_workers -= 1; |
| 813 |
|
|
if (pending_workers <= 0) |
| 814 |
wakaba |
1.29 |
postMessage(result); // finished! |
| 815 |
wakaba |
1.36 |
}</span></pre> |
| 816 |
wakaba |
1.23 |
|
| 817 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="f9236b42d2a99d988b848353511797fc"><span class=en-original lang=en>It consists of a loop to start the subworkers, and then a handler that |
| 818 |
wakaba |
1.23 |
waits for all the subworkers to respond. |
| 819 |
|
|
|
| 820 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>これは部分労働者を開始するループと、 |
| 821 |
|
|
すべての部分労働者が応答するのを待つ取扱器から成っています。</span><p class="has-ja-translation" data-ja-hash="53f3483f6fffa25f7c6963e58d683f43"><span class=en-original lang=en>The subworkers are implemented as follows: |
| 822 |
wakaba |
1.23 |
|
| 823 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>部分労働者は次のように実装します。</span><pre class="no-ja-translation" data-ja-hash="5e94721625bb121502ab771976eae899"><span class=en-original lang=en>var start; |
| 824 |
wakaba |
1.23 |
onmessage = getStart; |
| 825 |
|
|
function getStart(event) { |
| 826 |
|
|
start = 1*event.message; |
| 827 |
|
|
onmessage = getEnd; |
| 828 |
|
|
} |
| 829 |
|
|
|
| 830 |
|
|
var end; |
| 831 |
|
|
function getEnd(event) { |
| 832 |
|
|
end = 1*event.message; |
| 833 |
|
|
onmessage = null; |
| 834 |
|
|
do(); |
| 835 |
|
|
} |
| 836 |
|
|
|
| 837 |
|
|
function do() { |
| 838 |
|
|
var result = 0; |
| 839 |
|
|
for (var i = start; i < end; i += 1) { |
| 840 |
|
|
// perform some complex calculation here |
| 841 |
|
|
result += 1; |
| 842 |
|
|
} |
| 843 |
wakaba |
1.29 |
postMessage(result); |
| 844 |
|
|
close(); |
| 845 |
wakaba |
1.36 |
}</span></pre> |
| 846 |
wakaba |
1.23 |
|
| 847 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="fbf1b083b03c85854a8e892ef8add172"><span class=en-original lang=en>They receive two numbers in two events, perform the computation for the |
| 848 |
wakaba |
1.23 |
range of numbers thus specified, and then report the result back to the |
| 849 |
|
|
parent. |
| 850 |
|
|
|
| 851 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>部分労働者は2つの事象で2つの数を受信し、指定された数の範囲の計算を行った後、 |
| 852 |
|
|
結果を親に報告します。 |
| 853 |
|
|
</span><p class="has-ja-translation" data-ja-hash="add583522732edb8aca6202c451ddb27" data-ja-real-hash="c560664d07d84902d5e9e6c68ffc2f01"><span class=en-original lang=en><a href="http://www.whatwg.org/demos/workers/multicore/page.html">View |
| 854 |
wakaba |
1.32 |
this example online</a>. |
| 855 |
|
|
|
| 856 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><a href="http://www.whatwg.org/demos/workers/multicore/page.html">この例をオンラインで表示する</a>。</span><h4 id=providing class="has-ja-translation" data-ja-hash="6c37218e175bff77f69bd84b1ab5da58"><span class=en-original lang=en><span class=secno>1.1.6 </span>Providing libraries</span><span class=ja-translation lang=ja><span class=secno>1.1.6 </span>ライブラリーの提供</span></h4> |
| 857 |
wakaba |
1.28 |
|
| 858 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="585b83d0801ae75a14554d8d2c737fb2"><span class=en-original lang=en><em>This section is non-normative.</em> |
| 859 |
wakaba |
1.32 |
|
| 860 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><em>この節は規定の一部ではありません。</em></span><p class="no-ja-translation" data-ja-hash="12371907fb7e8389f76fabaf7a5f8303"><span class=en-original lang=en>Suppose that a cryptography library is made available that provides |
| 861 |
wakaba |
1.28 |
three tasks: |
| 862 |
|
|
|
| 863 |
wakaba |
1.36 |
</span><dl> |
| 864 |
|
|
<dt class="no-ja-translation" data-ja-hash="6ea027035e660e254aba77f4bd9cb6e7"><span class=en-original lang=en>Generate a public/private key pair |
| 865 |
wakaba |
1.28 |
|
| 866 |
wakaba |
1.36 |
</span><dd class="no-ja-translation" data-ja-hash="cf9020803baa896d8a183fe324563704"><span class=en-original lang=en>Takes a port, on which it will send two messages, first the public key |
| 867 |
wakaba |
1.28 |
and then the private key. |
| 868 |
|
|
|
| 869 |
wakaba |
1.36 |
</span><dt class="no-ja-translation" data-ja-hash="fb7dd035a8141087578088ce61f9db22"><span class=en-original lang=en>Given a plaintext and a public key, return the corresponding |
| 870 |
wakaba |
1.28 |
cyphertext |
| 871 |
|
|
|
| 872 |
wakaba |
1.36 |
</span><dd class="no-ja-translation" data-ja-hash="1d31efc883e22a218f807161c65291f0"><span class=en-original lang=en>Takes a port, to which any number of messages can be sent, the first |
| 873 |
wakaba |
1.28 |
giving the public key, and the remainder giving the plaintext, each of |
| 874 |
|
|
which is encrypted and then sent on that same channel as the cyphertext. |
| 875 |
|
|
The user can close the port when it is done encrypting content. |
| 876 |
|
|
|
| 877 |
wakaba |
1.36 |
</span><dt class="no-ja-translation" data-ja-hash="11ea02c6f203744166e5a89e81a81337"><span class=en-original lang=en>Given a cyphertext and a private key, return the corresponding |
| 878 |
wakaba |
1.28 |
plaintext |
| 879 |
|
|
|
| 880 |
wakaba |
1.36 |
</span><dd class="no-ja-translation" data-ja-hash="c157fe0e540c248dc1db29edbd80ff82"><span class=en-original lang=en>Takes a port, to which any number of messages can be sent, the first |
| 881 |
wakaba |
1.28 |
giving the private key, and the remainder giving the cyphertext, each of |
| 882 |
|
|
which is decrypted and then sent on that same channel as the plaintext. |
| 883 |
|
|
The user can close the port when it is done decrypting content. |
| 884 |
wakaba |
1.36 |
</span></dl> |
| 885 |
wakaba |
1.28 |
|
| 886 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="0e39ac88e71e60206c341926e3785dcd"><span class=en-original lang=en>The library itself is as follows: |
| 887 |
wakaba |
1.28 |
|
| 888 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>ライブラリー自体は次のようになります。</span><pre class="no-ja-translation" data-ja-hash="0551beafb3a838f32aa5f1cec86a33d2"><span class=en-original lang=en>function handleMessage(e) { |
| 889 |
wakaba |
1.28 |
if (e.message == "genkeys") |
| 890 |
|
|
genkeys(e.port); |
| 891 |
|
|
else if (e.message == "encrypt") |
| 892 |
|
|
encrypt(e.port); |
| 893 |
|
|
else if (e.message == "decrypt") |
| 894 |
|
|
decrypt(e.port); |
| 895 |
|
|
} |
| 896 |
|
|
|
| 897 |
|
|
function genkeys(p) { |
| 898 |
|
|
var keys = _generateKeyPair(); |
| 899 |
|
|
p.postMessage(keys[0]); |
| 900 |
|
|
p.postMessage(keys[1]); |
| 901 |
|
|
} |
| 902 |
|
|
|
| 903 |
|
|
function encrypt(p) { |
| 904 |
|
|
var key, state = 0; |
| 905 |
|
|
p.onmessage = function (e) { |
| 906 |
|
|
if (state == 0) { |
| 907 |
|
|
key = e.message; |
| 908 |
|
|
state = 1; |
| 909 |
|
|
} else { |
| 910 |
|
|
p.postMessage(_encrypt(key, e.message)); |
| 911 |
|
|
} |
| 912 |
|
|
}; |
| 913 |
|
|
} |
| 914 |
|
|
|
| 915 |
|
|
function decrypt(p) { |
| 916 |
|
|
var key, state = 0; |
| 917 |
|
|
p.onmessage = function (e) { |
| 918 |
|
|
if (state == 0) { |
| 919 |
|
|
key = e.message; |
| 920 |
|
|
state = 1; |
| 921 |
|
|
} else { |
| 922 |
|
|
p.postMessage(_decrypt(key, e.message)); |
| 923 |
|
|
} |
| 924 |
|
|
}; |
| 925 |
|
|
} |
| 926 |
|
|
|
| 927 |
wakaba |
1.29 |
// support being used as a shared worker as well as a dedicated worker |
| 928 |
|
|
if (this.onmessage) // dedicated worker |
| 929 |
|
|
onmessage = handleMessage; |
| 930 |
|
|
else // shared worker |
| 931 |
|
|
onconnect = function (e) { e.port.onmessage = handleMessage; } |
| 932 |
wakaba |
1.28 |
|
| 933 |
|
|
|
| 934 |
|
|
// the "crypto" functions: |
| 935 |
|
|
|
| 936 |
|
|
function _generateKeyPair() { |
| 937 |
|
|
return [Math.random(), Math.random()]; |
| 938 |
|
|
} |
| 939 |
|
|
|
| 940 |
|
|
function _encrypt(k, s) { |
| 941 |
|
|
return 'encrypted-' + k + ' ' + s; |
| 942 |
|
|
} |
| 943 |
|
|
|
| 944 |
|
|
function _decrypt(k, s) { |
| 945 |
|
|
return s.substr(s.indexOf(' ')+1); |
| 946 |
wakaba |
1.36 |
}</span></pre> |
| 947 |
wakaba |
1.28 |
|
| 948 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="e6e3003b829ed060f5926d1763f29c2e"><span class=en-original lang=en>Note that the crypto functions here are just stubs and don't do real |
| 949 |
wakaba |
1.28 |
cryptography. |
| 950 |
|
|
|
| 951 |
wakaba |
1.36 |
</span><p class="has-ja-translation" data-ja-hash="76f1d5866d92bc1036d1198cf4eda428"><span class=en-original lang=en>This library could be used as follows: |
| 952 |
wakaba |
1.28 |
|
| 953 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>このライブラリーは次のように使うことができます。</span><pre class="no-ja-translation" data-ja-hash="f803a00b08b056a583c9531dfe8885b9"><span class=en-original lang=en><!DOCTYPE HTML> |
| 954 |
wakaba |
1.28 |
<html> |
| 955 |
|
|
<head> |
| 956 |
|
|
<title>Worker example: Crypto library</title> |
| 957 |
|
|
<script> |
| 958 |
wakaba |
1.29 |
var crytoLib = new Worker('libcrypto-v1.js'); // or could use 'libcrypto-v2.js' |
| 959 |
wakaba |
1.28 |
function getKeys() { |
| 960 |
|
|
var state = 0; |
| 961 |
wakaba |
1.29 |
cryptoLib.startConversation("genkeys").onmessage = function (e) { |
| 962 |
wakaba |
1.28 |
if (state == 0) |
| 963 |
|
|
document.getElementById('public').value = e.message; |
| 964 |
|
|
else if (state == 1) |
| 965 |
|
|
document.getElementById('private').value = e.message; |
| 966 |
|
|
state += 1; |
| 967 |
|
|
}; |
| 968 |
|
|
} |
| 969 |
|
|
function enc() { |
| 970 |
wakaba |
1.29 |
var port = cryptoLib.startConversation("encrypt"); |
| 971 |
|
|
port.postMessage(document.getElementById('public').value); |
| 972 |
|
|
port.postMessage(document.getElementById('input').value); |
| 973 |
|
|
port.onmessage = function (e) { |
| 974 |
wakaba |
1.28 |
document.getElementById('input').value = e.message; |
| 975 |
wakaba |
1.29 |
port.close(); |
| 976 |
wakaba |
1.28 |
}; |
| 977 |
|
|
} |
| 978 |
|
|
function dec() { |
| 979 |
wakaba |
1.29 |
var port = cryptoLib.startConversation("decrypt"); |
| 980 |
|
|
port.postMessage(document.getElementById('private').value); |
| 981 |
|
|
port.postMessage(document.getElementById('input').value); |
| 982 |
|
|
port.onmessage = function (e) { |
| 983 |
wakaba |
1.28 |
document.getElementById('input').value = e.message; |
| 984 |
wakaba |
1.29 |
port.close(); |
| 985 |
wakaba |
1.28 |
}; |
| 986 |
|
|
} |
| 987 |
|
|
</script> |
| 988 |
|
|
<style> |
| 989 |
|
|
textarea { display: block; } |
| 990 |
|
|
</style> |
| 991 |
|
|
</head> |
| 992 |
|
|
<body onload="getKeys()"> |
| 993 |
|
|
<fieldset> |
| 994 |
|
|
<legend>Keys</legend> |
| 995 |
wakaba |
1.29 |
<p><label>Public Key: <textarea id="public"></textarea></label></p> |
| 996 |
|
|
<p><label>Private Key: <textarea id="private"></textarea></label></p> |
| 997 |
wakaba |
1.28 |
</fieldset> |
| 998 |
wakaba |
1.29 |
<p><label>Input: <textarea id="input"></textarea></label></p> |
| 999 |
wakaba |
1.28 |
<p><button onclick="enc()">Encrypt</button> <button onclick="dec()">Decrypt</button></p> |
| 1000 |
|
|
</body> |
| 1001 |
wakaba |
1.36 |
</html></span></pre> |
| 1002 |
wakaba |
1.28 |
|
| 1003 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="13181de825fa0e152c5a954e55715a15"><span class=en-original lang=en>A later version of the API, though, might want to offload all the crypto |
| 1004 |
wakaba |
1.28 |
work onto subworkers. This could be done as follows: |
| 1005 |
|
|
|
| 1006 |
wakaba |
1.36 |
</span><pre class="no-ja-translation" data-ja-hash="c3d170ca77e59a8de30c833efd7a11ac"><span class=en-original lang=en>function handleMessage(e) { |
| 1007 |
wakaba |
1.28 |
if (e.message == "genkeys") |
| 1008 |
|
|
genkeys(e.port); |
| 1009 |
|
|
else if (e.message == "encrypt") |
| 1010 |
|
|
encrypt(e.port); |
| 1011 |
|
|
else if (e.message == "decrypt") |
| 1012 |
|
|
decrypt(e.port); |
| 1013 |
|
|
} |
| 1014 |
|
|
|
| 1015 |
|
|
function genkeys(p) { |
| 1016 |
wakaba |
1.29 |
var generator = new Worker('libcrypto-v2-generator.js'); |
| 1017 |
wakaba |
1.28 |
generator.postMessage('', p); |
| 1018 |
|
|
} |
| 1019 |
|
|
|
| 1020 |
|
|
function encrypt(p) { |
| 1021 |
|
|
p.onmessage = function (e) { |
| 1022 |
|
|
var key = e.message; |
| 1023 |
wakaba |
1.29 |
var encryptor = new Worker('libcrypto-v2-encryptor.js'); |
| 1024 |
wakaba |
1.28 |
encryptor.postMessage(key, p); |
| 1025 |
|
|
}; |
| 1026 |
|
|
} |
| 1027 |
|
|
|
| 1028 |
|
|
function encrypt(p) { |
| 1029 |
|
|
p.onmessage = function (e) { |
| 1030 |
|
|
var key = e.message; |
| 1031 |
wakaba |
1.29 |
var decryptor = new Worker('libcrypto-v2-decryptor.js'); |
| 1032 |
wakaba |
1.28 |
decryptor.postMessage(key, p); |
| 1033 |
|
|
}; |
| 1034 |
|
|
} |
| 1035 |
|
|
|
| 1036 |
wakaba |
1.29 |
// support being used as a shared worker as well as a dedicated worker |
| 1037 |
|
|
if (this.onmessage) // dedicated worker |
| 1038 |
|
|
onmessage = handleMessage; |
| 1039 |
|
|
else // shared worker |
| 1040 |
|
|
onconnect = function (e) { e.port.onmessage = handleMessage; } |
| 1041 |
wakaba |
1.36 |
</span></pre> |
| 1042 |
wakaba |
1.28 |
|
| 1043 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="fc1d14c413a94a9015153067739845e7"><span class=en-original lang=en>The little subworkers would then be as follows. |
| 1044 |
wakaba |
1.28 |
|
| 1045 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>小部分労働者は次の通りです。</span><p class="has-ja-translation" data-ja-hash="66f9c4d246b0081919ced7e46c4a9db2"><span class=en-original lang=en>For generating key pairs: |
| 1046 |
wakaba |
1.28 |
|
| 1047 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>鍵組の生成用:</span><pre class="no-ja-translation" data-ja-hash="69e6e4b66305b1a92aee9fcc2372196d"><span class=en-original lang=en>onmessage = function (e) { |
| 1048 |
wakaba |
1.29 |
var k = _generateKeyPair(); |
| 1049 |
|
|
e.port.postMessage(k[0]); |
| 1050 |
|
|
e.port.postMessage(k[1]); |
| 1051 |
wakaba |
1.28 |
close(); |
| 1052 |
|
|
} |
| 1053 |
wakaba |
1.29 |
|
| 1054 |
|
|
function _generateKeyPair() { |
| 1055 |
|
|
return [Math.random(), Math.random()]; |
| 1056 |
wakaba |
1.36 |
}</span></pre> |
| 1057 |
wakaba |
1.28 |
|
| 1058 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="1f07f24df05f20de47483db4dfde2017"><span class=en-original lang=en>For encrypting: |
| 1059 |
wakaba |
1.28 |
|
| 1060 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>暗号化用:</span><pre class="no-ja-translation" data-ja-hash="ba42dc47294452a0e7be06888d992a23"><span class=en-original lang=en>onmessage = function (e) { |
| 1061 |
wakaba |
1.28 |
var key = e.message; |
| 1062 |
|
|
e.port.onmessage = function (e) { |
| 1063 |
|
|
var s = e.message; |
| 1064 |
wakaba |
1.29 |
postMessage(_encrypt(key, s)); |
| 1065 |
wakaba |
1.28 |
} |
| 1066 |
wakaba |
1.29 |
e.port.onclose = function (e) { |
| 1067 |
wakaba |
1.28 |
close(); |
| 1068 |
|
|
} |
| 1069 |
wakaba |
1.29 |
} |
| 1070 |
|
|
|
| 1071 |
|
|
function _encrypt(k, s) { |
| 1072 |
|
|
return 'encrypted-' + k + ' ' + s; |
| 1073 |
wakaba |
1.36 |
}</span></pre> |
| 1074 |
wakaba |
1.28 |
|
| 1075 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="abf884f40593747f458e7d7400b1eb21"><span class=en-original lang=en>For decrypting: |
| 1076 |
wakaba |
1.28 |
|
| 1077 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>解読用:</span><pre class="no-ja-translation" data-ja-hash="c376b687a0af1f710d51ddf4eac84085"><span class=en-original lang=en>onmessage = function (e) { |
| 1078 |
wakaba |
1.28 |
var key = e.message; |
| 1079 |
|
|
e.port.onmessage = function (e) { |
| 1080 |
|
|
var s = e.message; |
| 1081 |
wakaba |
1.29 |
postMessage(_decrypt(key, s)); |
| 1082 |
wakaba |
1.28 |
} |
| 1083 |
wakaba |
1.29 |
e.port.onclose = function (e) { |
| 1084 |
wakaba |
1.28 |
close(); |
| 1085 |
|
|
} |
| 1086 |
wakaba |
1.29 |
} |
| 1087 |
|
|
|
| 1088 |
|
|
function _decrypt(k, s) { |
| 1089 |
|
|
return s.substr(s.indexOf(' ')+1); |
| 1090 |
wakaba |
1.36 |
}</span></pre> |
| 1091 |
wakaba |
1.28 |
|
| 1092 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="c8da0ee0afd0a36dc51fa6bebbb8a3e9"><span class=en-original lang=en>Notice how the users of the API don't have to even know that this is |
| 1093 |
wakaba |
1.28 |
happening — the API hasn't changed; the library can delegate to |
| 1094 |
|
|
subworkers without changing its API, even though it is accepting data |
| 1095 |
|
|
using message channels. |
| 1096 |
|
|
|
| 1097 |
wakaba |
1.36 |
</span><p class="has-ja-translation" data-ja-hash="add583522732edb8aca6202c451ddb27" data-ja-real-hash="268a742b1731b3f55fd4ab398fa56d34"><span class=en-original lang=en><a href="http://www.whatwg.org/demos/workers/crypto/page.html">View this |
| 1098 |
wakaba |
1.32 |
example online</a>. |
| 1099 |
|
|
|
| 1100 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><a href="http://www.whatwg.org/demos/workers/crypto/page.html">この例をオンラインで表示する</a>。</span><h3 id=conformance class="has-ja-translation" data-ja-hash="05644f41fb2fbf61aaab52464b2edf3b"><span class=en-original lang=en><span class=secno>1.2 </span>Conformance requirements</span><span class=ja-translation lang=ja><span class=secno>1.2 </span>適合性要件</span></h3> |
| 1101 |
wakaba |
1.1 |
|
| 1102 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="8b0f72fe04577949924ab1e2997e0d8b"><span class=en-original lang=en>All diagrams, examples, and notes in this specification are |
| 1103 |
wakaba |
1.32 |
non-normative, as are all sections explicitly marked non-normative. |
| 1104 |
|
|
Everything else in this specification is normative. |
| 1105 |
|
|
|
| 1106 |
|
|
</span><span class=ja-translation lang=ja>この仕様書のすべての図、例示、注意書き、ならびに規定の一部ではないと明記したすべての節は、 |
| 1107 |
wakaba |
1.1 |
規定の一部ではありません。 |
| 1108 |
wakaba |
1.36 |
この仕様書のそれ以外の部分はすべて規定の一部です。</span><p class="no-ja-translation" data-ja-hash="6b9cae822cc27a0168c340eee0cff438"><span class=en-original lang=en>The key words "MUST", "MUST NOT", "REQUIRED", <!--"SHALL", "SHALL |
| 1109 |
wakaba |
1.31 |
NOT",--> |
| 1110 |
|
|
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the |
| 1111 |
|
|
normative parts of this document are to be interpreted as described in |
| 1112 |
|
|
RFC2119. For readability, these words do not appear in all uppercase |
| 1113 |
wakaba |
1.36 |
letters in this specification. <a href="#refsRFC2119">[RFC2119]</a></span></p> |
| 1114 |
wakaba |
1.1 |
<!-- XXX but they should be |
| 1115 |
|
|
marked up --> |
| 1116 |
|
|
|
| 1117 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="63dc4357c416e0e0f292a5f662ca71ab"><span class=en-original lang=en>Requirements phrased in the imperative as part of algorithms (such as |
| 1118 |
wakaba |
1.32 |
"strip any leading space characters" or "return false and abort these |
| 1119 |
|
|
steps") are to be interpreted with the meaning of the key word ("must", |
| 1120 |
|
|
"should", "may", etc) used in introducing the algorithm. |
| 1121 |
|
|
|
| 1122 |
|
|
</span><span class=ja-translation lang=ja>算法の一部として<ins class=ja-note>動作の指示の形で (原文では</ins>命令形で<ins class=ja-note>) </ins>記述された要件 |
| 1123 |
wakaba |
1.1 |
(例えば「先頭の間隔文字をすべて除去します」や「偽を返し、これらの段階を停止します」) |
| 1124 |
wakaba |
1.24 |
は、算法を紹介するに当たって使われたキーワード (<em class=rfc2119 title="MUST">しなければなりません</em>、 |
| 1125 |
wakaba |
1.36 |
<em class=rfc2119 title="SHOULD">するべきです</em>、<em class=rfc2119 title="MAY">して構いません</em>など) の意味により解釈します。</span><p class="has-ja-translation" data-ja-hash="a5a0db584980ce3f2448983d6188b2d1"><span class=en-original lang=en>Some conformance requirements are phrased as requirements on attributes, |
| 1126 |
wakaba |
1.32 |
methods or objects. Such requirements are to be interpreted as |
| 1127 |
|
|
requirements on user agents. |
| 1128 |
|
|
|
| 1129 |
|
|
</span><span class=ja-translation lang=ja>いくつかの適合性要件は属性やメソッドやオブジェクトの要件として説明されています。 |
| 1130 |
wakaba |
1.36 |
そのような要件は、利用者エージェントに関する要件として解釈します。</span><p class="has-ja-translation" data-ja-hash="27386c326b98d878b3c408c60b6095b0"><span class=en-original lang=en>Conformance requirements phrased as algorithms or specific steps may be |
| 1131 |
wakaba |
1.32 |
implemented in any manner, so long as the end result is equivalent. (In |
| 1132 |
|
|
particular, the algorithms defined in this specification are intended to |
| 1133 |
|
|
be easy to follow, and not intended to be performant.) |
| 1134 |
|
|
|
| 1135 |
|
|
</span><span class=ja-translation lang=ja>算法や特定の段階として説明されている適合性要件は、 |
| 1136 |
wakaba |
1.1 |
最終的な結果が等価である限り、任意の方法で実装して<em class=rfc2119 title="MAY">構いません</em>。 |
| 1137 |
|
|
(特に、この仕様書で定義されている算法は追うのを簡単にしており、 |
| 1138 |
wakaba |
1.36 |
高性能であることを目指してはいません。)</span><p class="has-ja-translation" data-ja-hash="e42931a32a5e7ad458e3ca1b87d741d9"><span class=en-original lang=en>The only conformance class defined by this specification is user agents. |
| 1139 |
wakaba |
1.32 |
|
| 1140 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>この仕様書で定義する唯一の適合性の級は利用者エージェントです。</span><p class="has-ja-translation" data-ja-hash="57959e6c42e8d5141b11e501bf60cc2f"><span class=en-original lang=en>User agents may impose implementation-specific limits on otherwise |
| 1141 |
wakaba |
1.32 |
unconstrained inputs, e.g. to prevent denial of service attacks, to guard |
| 1142 |
|
|
against running out of memory, or to work around platform-specific |
| 1143 |
|
|
limitations. |
| 1144 |
|
|
|
| 1145 |
|
|
</span><span class=ja-translation lang=ja>利用者エージェントは、サービス拒否攻撃を防ぐため、 |
| 1146 |
wakaba |
1.1 |
記憶容量を使い尽くすことを防ぐため、 |
| 1147 |
|
|
あるいは環境特有の制限に対応するためなどの目的で、 |
| 1148 |
wakaba |
1.36 |
別段の制約のない入力に対して実装特有の制限を設けて<em class=rfc2119 title="MAY">構いません</em>。</span><h4 id=dependencies class="has-ja-translation" data-ja-hash="896f4eaa4f12972b56ed9cdd9a90b949"><span class=en-original lang=en><span class=secno>1.2.1 </span>Dependencies</span><span class=ja-translation lang=ja><span class=secno>1.2.1 </span>依存性</span></h4> |
| 1149 |
wakaba |
1.1 |
|
| 1150 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="8dc27a34324d9e41d25c6bbbc2d2551c"><span class=en-original lang=en>This specification relies on several other underlying specifications. |
| 1151 |
wakaba |
1.32 |
|
| 1152 |
|
|
</span><span class=ja-translation lang=ja>この仕様書は、他のいくつかの下位の仕様書に依存しています。</span><dl> |
| 1153 |
wakaba |
1.36 |
<dt class="no-ja-translation" data-ja-hash="6bff62b10d884fb77428cfe168cd783d"><span class=en-original lang=en>HTML5 |
| 1154 |
wakaba |
1.1 |
|
| 1155 |
wakaba |
1.36 |
</span><dd> |
| 1156 |
|
|
<p class="no-ja-translation" data-ja-hash="692ef0a750fa95ddb11f05608021ff02"><span class=en-original lang=en>Many fundamental concepts from HTML5 are used by this specification. |
| 1157 |
|
|
<a href="#refsHTML5">[HTML5]</a></span></p> |
| 1158 |
wakaba |
1.1 |
|
| 1159 |
wakaba |
1.36 |
<dt class="no-ja-translation" data-ja-hash="760145493119c1b42cb6fe0bbde08987"><span class=en-original lang=en>ECMAScript |
| 1160 |
wakaba |
1.1 |
|
| 1161 |
wakaba |
1.36 |
</span><dd> |
| 1162 |
|
|
<p class="no-ja-translation" data-ja-hash="9fbcf32dffdec6694cf4ea145ef5db36"><span class=en-original lang=en>This specification is intended to be used with JavaScript as the |
| 1163 |
|
|
scripting language. <a href="#refsJS">[JS]</a></span></p> |
| 1164 |
wakaba |
1.1 |
|
| 1165 |
wakaba |
1.36 |
<dt class="no-ja-translation" data-ja-hash="21838f6e93b1a2157b16dcb6281ff225"><span class=en-original lang=en>WebIDL |
| 1166 |
wakaba |
1.1 |
|
| 1167 |
wakaba |
1.36 |
</span><dd> |
| 1168 |
|
|
<p class="no-ja-translation" data-ja-hash="f0d2498c8bb497932f36ddf86e0cf1e4"><span class=en-original lang=en>The IDL blocks in this specification use the semantics of the WebIDL |
| 1169 |
|
|
specification. <a href="#refsWebIDL">[WebIDL]</a></span></p> |
| 1170 |
wakaba |
1.1 |
</dl> |
| 1171 |
|
|
|
| 1172 |
wakaba |
1.36 |
<h3 id=terminology class="has-ja-translation" data-ja-hash="e182a8a3f2adf774fb1c959df71b8600"><span class=en-original lang=en><span class=secno>1.3 </span>Terminology</span><span class=ja-translation lang=ja><span class=secno>1.3 </span>用語</span></h3> |
| 1173 |
wakaba |
1.32 |
|
| 1174 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="a8b72c8eb10ed78401c92b2b0eb7d5ec"><span class=en-original lang=en>For simplicity, terms such as <em>shown</em>, <em>displayed</em>, and |
| 1175 |
wakaba |
1.32 |
<em>visible</em> might sometimes be used when referring to the way a |
| 1176 |
|
|
document is rendered to the user. These terms are not meant to imply a |
| 1177 |
|
|
visual medium; they must be considered to apply to other media in |
| 1178 |
|
|
equivalent ways. |
| 1179 |
wakaba |
1.1 |
|
| 1180 |
wakaba |
1.32 |
</span><span class=ja-translation lang=ja>簡単のため、文書が利用者に対してレンダリングされる方法に言及する時に<em>示す</em>、 |
| 1181 |
wakaba |
1.24 |
<em>表示する</em>、<em>可視</em>などの用語を使うことがあります。 |
| 1182 |
|
|
このような用語は特に視覚媒体を暗示しているわけではありません。 |
| 1183 |
wakaba |
1.36 |
他の媒体であってもこれらの用語が等価な方法で適用されるものと考えなければ<em class=rfc2119 title="MUST">なりません</em>。</span><p class="has-ja-translation" data-ja-hash="f99630e4a7f12f2c4ecb88e02bf4a644"><span class=en-original lang=en>The construction "a <code title="">Foo</code> object", where <code |
| 1184 |
wakaba |
1.32 |
title="">Foo</code> is actually an interface, is sometimes used instead of |
| 1185 |
|
|
the more accurate "an object implementing the interface <code |
| 1186 |
|
|
title="">Foo</code>". |
| 1187 |
|
|
|
| 1188 |
|
|
</span><span class=ja-translation lang=ja>「<code title="">Foo</code> オブジェクト」という構文 (<code title="">Foo</code> |
| 1189 |
wakaba |
1.10 |
は実際には界面) を時々使いますが、より正確な「界面 <code title="">Foo</code> |
| 1190 |
wakaba |
1.36 |
を実装しているオブジェクト」の代わりに用いています。</span><p class="no-ja-translation" data-ja-hash="eb827c696acddeb1a8d0447095c94e07"><span class=en-original lang=en>The term DOM is used to refer to the API set made available to scripts |
| 1191 |
wakaba |
1.31 |
in Web applications, and does not necessarily imply the existence of an |
| 1192 |
|
|
actual <code>Document</code> object or of any other <code>Node</code> |
| 1193 |
|
|
objects as defined in the DOM Core specifications. <a |
| 1194 |
|
|
href="#refsDOM3CORE">[DOM3CORE]</a> |
| 1195 |
|
|
|
| 1196 |
wakaba |
1.36 |
</span><p class="has-ja-translation" data-ja-hash="5b9242da79aeab74bccc57781ac3103e"><span class=en-original lang=en>A DOM attribute is said to be <em>getting</em> when its value is being |
| 1197 |
wakaba |
1.32 |
retrieved (e.g. by author script), and is said to be <em>setting</em> when |
| 1198 |
|
|
a new value is assigned to it. |
| 1199 |
|
|
|
| 1200 |
|
|
</span><span class=ja-translation lang=ja>DOM 属性は、その値が (例えば著者のスクリプトにより) 取り出される時<em>取得される</em>といい、 |
| 1201 |
wakaba |
1.36 |
新しい値がその属性に割り当てられる時<em>設定される</em>といいます。</span><p class="has-ja-translation" data-ja-hash="3bc657beddfe2afa99ec418903cab1b0"><span class=en-original lang=en>If a DOM object is said to be <dfn id="en-live">live</dfn>, then that means |
| 1202 |
wakaba |
1.32 |
that any attributes returning that object must always return the same |
| 1203 |
|
|
object (not a new object each time), and the attributes and methods on |
| 1204 |
|
|
that object must operate on the actual underlying data, not a snapshot of |
| 1205 |
|
|
the data. |
| 1206 |
|
|
|
| 1207 |
|
|
</span><span class=ja-translation lang=ja>DOM オブジェクトが<dfn id=live>生きている</dfn>という場合、 |
| 1208 |
wakaba |
1.1 |
そのオブジェクトを返す属性は常に同じオブジェクトを返さなければ<em class=rfc2119 title="MUST">ならない</em> |
| 1209 |
|
|
(毎回新しいオブジェクトを返すのではなく) 上に、 |
| 1210 |
|
|
そのオブジェクトの属性やメソッドがそのオブジェクトの裏にある実際のデータのスナップ写真ではなく、 |
| 1211 |
wakaba |
1.36 |
データそのものに対して操作されなければ<em class=rfc2119 title="MUST">ならない</em>ことを意味します。</span><h2 id=infrastructure class="has-ja-translation" data-ja-hash="cba4f4cee5c6a3e6d8be8da68fa1234e"><span class=en-original lang=en><span class=secno>2. </span>Infrastructure</span><span class=ja-translation lang=ja><span class=secno>2. </span>基盤</span></h2> |
| 1212 |
wakaba |
1.9 |
|
| 1213 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="3084903b8fbd98a324781019e6ab7daf"><span class=en-original lang=en>There are two kinds of workers; dedicated workers, and shared workers. |
| 1214 |
wakaba |
1.29 |
Dedicated workers, once created, and are linked to their creator; but |
| 1215 |
|
|
message ports can be used to communicate from a dedicated worker to |
| 1216 |
|
|
multple other browsing contexts or workers. Shared workers, on the other |
| 1217 |
|
|
hand, are named, and once created any script running in the same |
| 1218 |
|
|
<span>origin</span> can obtain a reference to that worker and communicate |
| 1219 |
|
|
with it. |
| 1220 |
|
|
|
| 1221 |
wakaba |
1.36 |
</span><h3 id=the-global class="has-ja-translation" data-ja-hash="16d7670f16b3aaf6130252e8f11702eb"><span class=en-original lang=en><span class=secno>2.1 </span>The global scope</span><span class=ja-translation lang=ja><span class=secno>2.1 </span>大域作用域</span></h3> |
| 1222 |
wakaba |
1.29 |
|
| 1223 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="216dee088449fef485a489ea8a7432f4"><span class=en-original lang=en>The global scope is the "inside" of a worker. |
| 1224 |
wakaba |
1.29 |
|
| 1225 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>大域作用域は労働者の「内側」です。</span><h4 id=the-workerglobalscope class="has-ja-translation" data-ja-hash="fe5227371e801f4ac588d0d07472a900" data-ja-real-hash="cc17376e4eee7e97d5ab420959bcac76"><span class=en-original lang=en><span class=secno>2.1.1 </span>The <code><a |
| 1226 |
|
|
href="#workerglobalscope">WorkerGlobalScope</a></code> abstract interface</span><span class=ja-translation lang=ja><span class=secno>2.1.1 </span><code><a href="#workerglobalscope">WorkerGlobalScope</a></code> 抽象界面</span></h4> |
| 1227 |
wakaba |
1.9 |
|
| 1228 |
|
|
<pre |
| 1229 |
wakaba |
1.36 |
class="idl no-ja-translation" data-ja-hash="1f1989e0e082e4bbc1332cd5504df8d6"><span class=en-original lang=en>[NoInterfaceObject] interface <dfn id=workerglobalscope>WorkerGlobalScope</dfn> { |
| 1230 |
wakaba |
1.22 |
readonly attribute <a href="#workerglobalscope">WorkerGlobalScope</a> <a href="#self" title=dom-WorkerGlobalScope-self>self</a>; |
| 1231 |
wakaba |
1.23 |
readonly attribute <a href="#workerlocation">WorkerLocation</a> <a href="#location" title=dom-WorkerGlobalScope-location>location</a>; |
| 1232 |
wakaba |
1.29 |
// also implements everything on <a href="#workerutils">WorkerUtils</a> |
| 1233 |
|
|
|
| 1234 |
wakaba |
1.22 |
void <a href="#close" title=dom-WorkerGlobalScope-close>close</a>(); |
| 1235 |
wakaba |
1.29 |
attribute <span>EventListener</span> <a href="#onclose" title=handler-WorkerGlobalScope-onclose>onclose</a>; |
| 1236 |
wakaba |
1.36 |
};</span></pre> |
| 1237 |
wakaba |
1.9 |
|
| 1238 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="1e1e10859388e2e768f00f3173b402ef"><span class=en-original lang=en>Objects implementing the <code><a |
| 1239 |
wakaba |
1.29 |
href="#workerglobalscope">WorkerGlobalScope</a></code> interface it must |
| 1240 |
|
|
also implement the <code>EventTarget</code> interface. |
| 1241 |
wakaba |
1.23 |
|
| 1242 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="087af626d2f79d49dcf366c0227c32c0"><span class=en-original lang=en>The <dfn id=self |
| 1243 |
wakaba |
1.22 |
title=dom-WorkerGlobalScope-self><code>self</code></dfn> attribute must |
| 1244 |
|
|
return the <code><a href="#workerglobalscope">WorkerGlobalScope</a></code> |
| 1245 |
|
|
object itself. |
| 1246 |
|
|
|
| 1247 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="8e9bf18a7820b4401892ba71daf05527"><span class=en-original lang=en>The <dfn id=location |
| 1248 |
wakaba |
1.23 |
title=dom-WorkerGlobalScope-location><code>location</code></dfn> attribute |
| 1249 |
|
|
must return the <code><a href="#workerlocation">WorkerLocation</a></code> |
| 1250 |
|
|
object created for the <code><a |
| 1251 |
|
|
href="#workerglobalscope">WorkerGlobalScope</a></code> object when the |
| 1252 |
|
|
worker was created. It represents the <span>absolute URL</span> of the |
| 1253 |
|
|
script that was used to initialize the worker. |
| 1254 |
wakaba |
1.22 |
|
| 1255 |
wakaba |
1.36 |
</span><hr> |
| 1256 |
wakaba |
1.29 |
|
| 1257 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="4613c16766e1a2533e8acb2824c6f9fe"><span class=en-original lang=en>When a script invokes the <dfn id=close |
| 1258 |
wakaba |
1.29 |
title=dom-WorkerGlobalScope-close><code>close()</code></dfn> method on a |
| 1259 |
|
|
<code><a href="#workerglobalscope">WorkerGlobalScope</a></code> object, |
| 1260 |
|
|
the user agent must run the following steps: |
| 1261 |
|
|
|
| 1262 |
wakaba |
1.36 |
</span><ol> |
| 1263 |
wakaba |
1.29 |
<li> |
| 1264 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="b0aabb71ba9d59702ebab2ddd8d5e874"><span class=en-original lang=en>Create an <code>Event</code> object with the event name <code |
| 1265 |
wakaba |
1.29 |
title=event-close>close</code>, which does not bubble and is not |
| 1266 |
|
|
cancelable, and add it to the <code><a |
| 1267 |
|
|
href="#workerglobalscope">WorkerGlobalScope</a></code> object's <a |
| 1268 |
|
|
href="#queue">queue of events</a>, targetted at the <code><a |
| 1269 |
|
|
href="#workerglobalscope">WorkerGlobalScope</a></code> object itself. |
| 1270 |
|
|
|
| 1271 |
wakaba |
1.36 |
</span><li> |
| 1272 |
|
|
<p class="no-ja-translation" data-ja-hash="6243c3e4951724a3633743634fccb06e"><span class=en-original lang=en>Set the worker's <code><a |
| 1273 |
wakaba |
1.29 |
href="#workerglobalscope">WorkerGlobalScope</a></code> object's <a |
| 1274 |
|
|
href="#closing" title=dom-WorkerGlobalScope-closing>closing</a> flag to |
| 1275 |
|
|
true. |
| 1276 |
|
|
|
| 1277 |
wakaba |
1.36 |
</span><li> |
| 1278 |
|
|
<p class="no-ja-translation" data-ja-hash="23294ec8206dcdfff40f0f9dab0db01a"><span class=en-original lang=en>For each <code>MessagePort</code> object that is entangled with |
| 1279 |
wakaba |
1.29 |
another port and that has one (but only one) port whose owner is the |
| 1280 |
|
|
<code><a href="#workerglobalscope">WorkerGlobalScope</a></code> object |
| 1281 |
|
|
on which the method was invoked (this would include, for instance, the |
| 1282 |
|
|
implicit port in used for dedicated workers), run the following |
| 1283 |
wakaba |
1.36 |
substeps:</span></p> |
| 1284 |
wakaba |
1.29 |
|
| 1285 |
|
|
<ol> |
| 1286 |
|
|
<li> |
| 1287 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="788aa9e1f63682ac05822b3d8b0aad62"><span class=en-original lang=en>Unentangle the two ports. |
| 1288 |
wakaba |
1.32 |
|
| 1289 |
|
|
</span><span class=ja-translation lang=ja>2つのポートをほどきます。</span><li> |
| 1290 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="6a67dae4e1af3f08dd5d82d5ee59c9a5"><span class=en-original lang=en>At the next available opportunity, after any scripts have finished |
| 1291 |
wakaba |
1.29 |
executing<!-- XXX queue -->, <span>fire a simple event</span> called |
| 1292 |
|
|
<code title=event-close>close</code> at the other port (the one whose |
| 1293 |
|
|
owner is not the <code><a |
| 1294 |
|
|
href="#workerglobalscope">WorkerGlobalScope</a></code> object on which |
| 1295 |
|
|
the <code title=dom-WorkerGlobalScope-close><a |
| 1296 |
|
|
href="#close">close()</a></code> method was called). |
| 1297 |
wakaba |
1.36 |
</span></ol> |
| 1298 |
wakaba |
1.29 |
</ol> |
| 1299 |
wakaba |
1.9 |
|
| 1300 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="3df99fd92cbc7213b4f00b8953997403"><span class=en-original lang=en>The following are the <span>event handler DOM attributes</span> that |
| 1301 |
wakaba |
1.22 |
must be supported by objects implementing the <code><a |
| 1302 |
|
|
href="#workerglobalscope">WorkerGlobalScope</a></code> interface: |
| 1303 |
|
|
|
| 1304 |
wakaba |
1.36 |
</span><dl> |
| 1305 |
|
|
<dt class="no-ja-translation" data-ja-hash="96d62a92c59fca4cd2589c560425090f"><span class=en-original lang=en><dfn id=onclose |
| 1306 |
wakaba |
1.29 |
title=handler-WorkerGlobalScope-onclose><code>onclose</code></dfn> |
| 1307 |
wakaba |
1.11 |
|
| 1308 |
wakaba |
1.36 |
</span><dd> |
| 1309 |
|
|
<p class="has-ja-translation" data-ja-hash="91a2ce3a21f7ed687afe756baa5387d8" data-ja-real-hash="1388215c8f7c8c11b36e9c90d06b48e3"><span class=en-original lang=en>Must be invoked whenever a <code title=event-close>close</code> event |
| 1310 |
wakaba |
1.32 |
is targeted at or bubbles through the <code><a |
| 1311 |
|
|
href="#workerglobalscope">WorkerGlobalScope</a></code> object. |
| 1312 |
|
|
</span><span class=ja-translation lang=ja><code title=event-close>close</code> 事象が当該 <code><a href="#workerglobalscope">WorkerGlobalScope</a></code> オブジェクトを対象としているか、泡立って当該オブジェクトを通過する時に、 |
| 1313 |
wakaba |
1.29 |
呼び出されなければなりません。</span></dl> |
| 1314 |
|
|
|
| 1315 |
wakaba |
1.36 |
<h4 id=dedicated class="no-ja-translation" data-ja-hash="01e2b66319613f26fcb4ea361d2009e4"><span class=en-original lang=en><span class=secno>2.1.2 </span>Dedicated workers and the |
| 1316 |
wakaba |
1.29 |
<code><a |
| 1317 |
|
|
href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> |
| 1318 |
wakaba |
1.36 |
interface</span></h4> |
| 1319 |
wakaba |
1.29 |
|
| 1320 |
|
|
<pre |
| 1321 |
wakaba |
1.36 |
class="idl no-ja-translation" data-ja-hash="62f0863119ac9b7fc0427a9c34b4929e"><span class=en-original lang=en>[NoInterfaceObject] interface <dfn id=dedicatedworkerglobalscope>DedicatedWorkerGlobalScope</dfn> : <a href="#workerglobalscope">WorkerGlobalScope</a> { |
| 1322 |
wakaba |
1.30 |
void <a href="#postmessage" title=dom-DedicatedWorkerGlobalScope-postMessage>postMessage</a>(in DOMString message); |
| 1323 |
|
|
void <a href="#postmessage" title=dom-DedicatedWorkerGlobalScope-postMessage>postMessage</a>(in DOMString message, in <span>MessagePort</span> messagePort); |
| 1324 |
wakaba |
1.29 |
<span>MessagePort</span> <a href="#startconversation" title=dom-DedicatedWorkerGlobalScope-startConversation>startConversation</a>(in DOMString message); |
| 1325 |
|
|
attribute <span>EventListener</span> <a href="#onmessage" title=handler-DedicatedWorkerGlobalScope-onmessage>onmessage</a>; |
| 1326 |
wakaba |
1.36 |
};</span></pre> |
| 1327 |
wakaba |
1.29 |
|
| 1328 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="c6ea7d83d489d6962a5dafa4cb9883ac"><span class=en-original lang=en><code><a |
| 1329 |
wakaba |
1.29 |
href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> |
| 1330 |
|
|
objects act as if they had an implicit <code>MessagePort</code> associated |
| 1331 |
|
|
with them. This port is part of a channel that is set up when the worker |
| 1332 |
|
|
is created, but it is not exposed. This object must never be garbage |
| 1333 |
|
|
collected before the <code><a |
| 1334 |
|
|
href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> |
| 1335 |
|
|
object. |
| 1336 |
|
|
|
| 1337 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="cd46f0a484fa815888d26bffc00cd30a"><span class=en-original lang=en>All messages received by that port must immediately be retargetted at |
| 1338 |
wakaba |
1.29 |
the <code><a |
| 1339 |
|
|
href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> |
| 1340 |
|
|
object. |
| 1341 |
|
|
|
| 1342 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="e75eb4eabcb239bed307bd55adbcb794"><span class=en-original lang=en>The <dfn id=postmessage |
| 1343 |
wakaba |
1.29 |
title=dom-DedicatedWorkerGlobalScope-postMessage><code>postMessage()</code></dfn> |
| 1344 |
|
|
and <dfn id=startconversation |
| 1345 |
|
|
title=dom-DedicatedWorkerGlobalScope-startConversation><code>startConversation()</code></dfn> |
| 1346 |
|
|
methods on <code><a |
| 1347 |
|
|
href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> |
| 1348 |
|
|
objects must act as if, when invoked, they immediately invoked the method |
| 1349 |
wakaba |
1.30 |
of the same name on the port, with the same arguments, and returned the |
| 1350 |
|
|
same return value. |
| 1351 |
wakaba |
1.29 |
|
| 1352 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="a1ce69c9e43bed80103920cd0e52253e"><span class=en-original lang=en>The following are the <span>event handler DOM attributes</span> that |
| 1353 |
wakaba |
1.29 |
must be supported by objects implementing the <code><a |
| 1354 |
|
|
href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> |
| 1355 |
|
|
interface: |
| 1356 |
|
|
|
| 1357 |
wakaba |
1.36 |
</span><dl> |
| 1358 |
|
|
<dt class="no-ja-translation" data-ja-hash="160334ee188f54bd11cad6927542df5d"><span class=en-original lang=en><dfn id=onmessage |
| 1359 |
wakaba |
1.29 |
title=handler-DedicatedWorkerGlobalScope-onmessage><code>onmessage</code></dfn> |
| 1360 |
wakaba |
1.11 |
|
| 1361 |
wakaba |
1.36 |
</span><dd> |
| 1362 |
|
|
<p class="has-ja-translation" data-ja-hash="91a2ce3a21f7ed687afe756baa5387d8" data-ja-real-hash="693bf14ecd01b81e9953c2197c4ce97b"><span class=en-original lang=en>Must be invoked whenever a <code |
| 1363 |
wakaba |
1.32 |
title=event-DedicatedWorkerGlobalScope-message>message</code> event is |
| 1364 |
|
|
targeted at or bubbles through the <code><a |
| 1365 |
|
|
href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> |
| 1366 |
|
|
object. |
| 1367 |
|
|
</span><span class=ja-translation lang=ja><code title=event-DedicatedWorkerGlobalScope-message>message</code> 事象が当該 <code><a href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> オブジェクトを対象としているか、泡立って当該オブジェクトを通過する時に、 |
| 1368 |
wakaba |
1.12 |
呼び出されなければなりません。</span></dl> |
| 1369 |
wakaba |
1.11 |
|
| 1370 |
wakaba |
1.36 |
<h4 id=shared0 class="no-ja-translation" data-ja-hash="da49a2eed6f0ff2e53a41e7fe6e36a3a"><span class=en-original lang=en><span class=secno>2.1.3 </span>Shared workers and the |
| 1371 |
wakaba |
1.29 |
<code><a |
| 1372 |
|
|
href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> |
| 1373 |
wakaba |
1.36 |
inteface</span></h4> |
| 1374 |
wakaba |
1.29 |
|
| 1375 |
|
|
<pre |
| 1376 |
wakaba |
1.36 |
class="idl no-ja-translation" data-ja-hash="186ecc4f854426c568d67e4a78529172"><span class=en-original lang=en>[NoInterfaceObject] interface <dfn id=sharedworkerglobalscope>SharedWorkerGlobalScope</dfn> : <a href="#workerglobalscope">WorkerGlobalScope</a> { |
| 1377 |
wakaba |
1.29 |
readonly attribute DOMString <a href="#name" title=dom-SharedWorkerGlobalScope-name>name</a>; |
| 1378 |
|
|
attribute <span>EventListener</span> <a href="#onconnect" title=handler-SharedWorkerGlobalScope-onconnect>onconnect</a>; |
| 1379 |
wakaba |
1.36 |
};</span></pre> |
| 1380 |
wakaba |
1.29 |
|
| 1381 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="9d344498c69a5ed60029b76fb274beb2"><span class=en-original lang=en>Shared workers receive message ports through <code |
| 1382 |
wakaba |
1.29 |
title=event-WorkerGlobalScope-connect>connect</code> events on their |
| 1383 |
|
|
global object for each connection. |
| 1384 |
|
|
|
| 1385 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>共有労働者は、各接続について大域オブジェクトの <code |
| 1386 |
|
|
title=event-WorkerGlobalScope-connect>connect</code> 事象を通じてメッセージ・ポートを受信します。</span><p class="no-ja-translation" data-ja-hash="2cefcb206282ea1a0a38229d76567b14"><span class=en-original lang=en>The <dfn id=name |
| 1387 |
wakaba |
1.29 |
title=dom-SharedWorkerGlobalScope-name><code>name</code></dfn> attribute |
| 1388 |
|
|
must return the value it was assigned when the <code><a |
| 1389 |
|
|
href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> object |
| 1390 |
|
|
was created by the "<a href="#run-a">run a worker</a>" algorithm. Its |
| 1391 |
|
|
value represents the name that can be used to obtain a reference to the |
| 1392 |
|
|
worker using the <code><a href="#sharedworker">SharedWorker</a></code> |
| 1393 |
|
|
constructor. |
| 1394 |
|
|
|
| 1395 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="586e890e429389a63f2656c2d194935f"><span class=en-original lang=en>The following are the <span>event handler DOM attributes</span> that |
| 1396 |
wakaba |
1.29 |
must be supported by objects implementing the <code><a |
| 1397 |
|
|
href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> |
| 1398 |
|
|
interface: |
| 1399 |
|
|
|
| 1400 |
wakaba |
1.36 |
</span><dl> |
| 1401 |
|
|
<dt class="no-ja-translation" data-ja-hash="bb403ab8991a4f893a1ad1d0ffad30b0"><span class=en-original lang=en><dfn id=onconnect |
| 1402 |
wakaba |
1.29 |
title=handler-SharedWorkerGlobalScope-onconnect><code>onconnect</code></dfn> |
| 1403 |
|
|
|
| 1404 |
wakaba |
1.36 |
</span><dd> |
| 1405 |
|
|
<p class="has-ja-translation" data-ja-hash="91a2ce3a21f7ed687afe756baa5387d8" data-ja-real-hash="848b5a001778cd88e138b16d00959122"><span class=en-original lang=en>Must be invoked whenever a <code |
| 1406 |
wakaba |
1.32 |
title=event-SharedWorkerGlobalScope-connect>connect</code> event is |
| 1407 |
|
|
targeted at or bubbles through the <code><a |
| 1408 |
|
|
href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> |
| 1409 |
|
|
object. |
| 1410 |
|
|
</span><span class=ja-translation lang=ja><code title=event-SharedWorkerGlobalScope-connect>connect</code> 事象が当該 <code><a href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> オブジェクトを対象としているか、泡立って当該オブジェクトを通過する時に、 |
| 1411 |
wakaba |
1.29 |
呼び出されなければなりません。</span></dl> |
| 1412 |
wakaba |
1.23 |
|
| 1413 |
wakaba |
1.36 |
<h3 id=base-urls class="has-ja-translation" data-ja-hash="87cf5066db3fe786def6b713cf422c90"><span class=en-original lang=en><span class=secno>2.2 </span>Base URLs and origins of |
| 1414 |
wakaba |
1.32 |
workers</span><span class=ja-translation lang=ja><span class=secno>2.2 </span>労働者の基底 URL と起源</span></h3> |
| 1415 |
wakaba |
1.16 |
|
| 1416 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="bf28ef3029c1da544fc7a8e139c0bc54"><span class=en-original lang=en>The <span>base URL</span> of a <span>URL</span> passed to an API in a |
| 1417 |
wakaba |
1.23 |
worker is the <span>absolute URL</span> given that the worker's <code |
| 1418 |
|
|
title=dom-WorkerGlobalScope-location><a |
| 1419 |
|
|
href="#location">location</a></code> attribute represents. |
| 1420 |
wakaba |
1.22 |
|
| 1421 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="e474e44f65024b5ce02379030cdc0d69"><span class=en-original lang=en>Both the <span>origin</span> and <span>effective script origin</span> of |
| 1422 |
wakaba |
1.22 |
scripts running in workers are the <span>origin</span> of the |
| 1423 |
wakaba |
1.23 |
<span>absolute URL</span> given that the worker's <code |
| 1424 |
|
|
title=dom-WorkerGlobalScope-location><a |
| 1425 |
|
|
href="#location">location</a></code> attribute represents. |
| 1426 |
wakaba |
1.22 |
|
| 1427 |
wakaba |
1.36 |
</span><h3 id=the-queue class="has-ja-translation" data-ja-hash="e751d78f82cd9be78d5bd5c2d9103080"><span class=en-original lang=en><span class=secno>2.3 </span>The queue of events</span><span class=ja-translation lang=ja><span class=secno>2.3 </span>事象の待ち行列</span></h3> |
| 1428 |
wakaba |
1.22 |
|
| 1429 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="12214089c473ab5dd6a5968e61a2c2d0"><span class=en-original lang=en>Each <code><a href="#workerglobalscope">WorkerGlobalScope</a></code> |
| 1430 |
wakaba |
1.22 |
object is asssociated with a <dfn id=queue>queue of events</dfn>, which is |
| 1431 |
|
|
initially empty. |
| 1432 |
wakaba |
1.9 |
|
| 1433 |
wakaba |
1.36 |
</span><p class="has-ja-translation" data-ja-hash="a97955fbeead17cee9d1dce89f3c8c47"><span class=en-original lang=en>An event in the queue can be a DOM event or a timeout callback. |
| 1434 |
wakaba |
1.32 |
|
| 1435 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>待ち行列中の事象は、 DOM 事象か小休止呼び戻しのいずれかです。</span><p class="no-ja-translation" data-ja-hash="39828d766dc86fb82a3becb9bb4a60a9"><span class=en-original lang=en>All asynchronous callbacks and events that would be called or dispatched |
| 1436 |
wakaba |
1.31 |
in the worker must be added to the worker's queue, with the "<a |
| 1437 |
|
|
href="#run-a">run a worker</a>" processing model below taking care of |
| 1438 |
|
|
actually calling the callbacks or dispatching the events. |
| 1439 |
|
|
|
| 1440 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="3c5a8b0b9b710969e93d11ed5ae2ce7e"><span class=en-original lang=en>Each <code><a href="#workerglobalscope">WorkerGlobalScope</a></code> |
| 1441 |
wakaba |
1.29 |
object also has a <dfn id=closing |
| 1442 |
|
|
title=dom-WorkerGlobalScope-closing>closing</dfn> flag, which must |
| 1443 |
|
|
initially be false, but which can get set to true by the algorithms in the |
| 1444 |
|
|
processing model section below. |
| 1445 |
|
|
|
| 1446 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="380183121af051c0c214ce71e89ba1cf"><span class=en-original lang=en>Once the <code><a |
| 1447 |
wakaba |
1.29 |
href="#workerglobalscope">WorkerGlobalScope</a></code>'s <a |
| 1448 |
|
|
href="#closing" title=dom-WorkerGlobalScope-closing>closing</a> flag is |
| 1449 |
|
|
set to true, the queue must discard anything else that would be added to |
| 1450 |
|
|
it. Effectively, once the <a href="#closing" |
| 1451 |
|
|
title=dom-WorkerGlobalScope-closing>closing</a> flag is true, timers stop |
| 1452 |
|
|
firing, notifications for all pending asynchronous operations are dropped, |
| 1453 |
|
|
etc. |
| 1454 |
wakaba |
1.22 |
|
| 1455 |
wakaba |
1.36 |
</span><h3 id=the-workers class="has-ja-translation" data-ja-hash="b0a758845322b24463d7ebe35160f526"><span class=en-original lang=en><span class=secno>2.4 </span>The worker's ports</span><span class=ja-translation lang=ja><span class=secno>2.4 </span>労働者のポート</span></h3> |
| 1456 |
wakaba |
1.11 |
|
| 1457 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="15eb0638e0de7d0e159c1214c48ba569"><span class=en-original lang=en>Workers communicate with other workers and with <span title="browsing |
| 1458 |
wakaba |
1.32 |
context">browsing contexts</span> through <span title="channel |
| 1459 |
|
|
messaging">message channels</span> and their <code>MessagePort</code> |
| 1460 |
|
|
objects. |
| 1461 |
|
|
|
| 1462 |
|
|
</span><span class=ja-translation lang=ja>労働者は、メッセージ通信路とその <code>MessagePort</code> |
| 1463 |
wakaba |
1.36 |
オブジェクトを通じて、他の労働者や閲覧文脈と通信します。</span><p class="no-ja-translation" data-ja-hash="4d6d153cd07151306ae96dade3133b0f"><span class=en-original lang=en>Each <code><a href="#workerglobalscope">WorkerGlobalScope</a></code> |
| 1464 |
wakaba |
1.29 |
<var title="">worker global scope</var> has a list of <dfn |
| 1465 |
|
|
id=the-workers0>the worker's ports</dfn>, which consists of all the |
| 1466 |
|
|
<code>MessagePort</code> objects that are entangled with another port and |
| 1467 |
|
|
that have one (but only one) port owned by <var title="">worker global |
| 1468 |
|
|
scope</var>. This list includes all the <code>MessagePort</code> objects |
| 1469 |
|
|
that are in events pending in the <a href="#queue">queue of events</a>, as |
| 1470 |
|
|
well as the implicit <code>MessagePort</code> in the case of <a |
| 1471 |
|
|
href="#dedicatedworkerglobalscope" |
| 1472 |
|
|
title=DedicatedWorkerGlobalScope>dedicated workers</a>. |
| 1473 |
wakaba |
1.16 |
|
| 1474 |
wakaba |
1.36 |
</span><hr> |
| 1475 |
wakaba |
1.16 |
|
| 1476 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="26f978b46778a94d4ba398e774af8b16"><span class=en-original lang=en>A worker is said to be a <dfn id=permissible>permissible worker</dfn> if |
| 1477 |
wakaba |
1.23 |
either: |
| 1478 |
|
|
|
| 1479 |
wakaba |
1.36 |
</span><ul> |
| 1480 |
|
|
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="1408e830059dcfb69df672a38b4b1286"><span class=en-original lang=en>at some point past or present a <code>MessagePort</code> owned by the |
| 1481 |
wakaba |
1.23 |
worker was entangled with a <code>MessagePort</code> <var |
| 1482 |
|
|
title="">p</var> whose owner is a <code>Window</code> object whose |
| 1483 |
|
|
<span>active document</span> is the <code>Document</code> that was that |
| 1484 |
|
|
<span>browsing context</span>'s <span>active document</span> when <var |
| 1485 |
|
|
title="">p</var> was created, and that <code>Document</code> is |
| 1486 |
|
|
<span>fully active</span>, or |
| 1487 |
|
|
|
| 1488 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="d7437726a136144eb08d9f005783cfee"><span class=en-original lang=en>at some point past or present a <code>MessagePort</code> owned by the |
| 1489 |
wakaba |
1.23 |
worker was entangled with a <code>MessagePort</code> owned by another |
| 1490 |
|
|
worker that is currently a <a href="#permissible">permissible worker</a>. |
| 1491 |
wakaba |
1.36 |
</span></ul> |
| 1492 |
wakaba |
1.23 |
|
| 1493 |
|
|
<hr> |
| 1494 |
|
|
|
| 1495 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="236c5cb878bfd9b9303cc296c82764ac"><span class=en-original lang=en>A worker is said to be a <dfn id="en-protected">protected worker</dfn> if |
| 1496 |
wakaba |
1.23 |
either: |
| 1497 |
|
|
|
| 1498 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>労働者は、次のいずれかの場合、<dfn id=protected>保護労働者</dfn>であるといいます。</span><ul> |
| 1499 |
|
|
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="899d42932a6bc9aca806a2e046053691"><span class=en-original lang=en>it has outstanding timers, database transactions, or network |
| 1500 |
wakaba |
1.23 |
connections, and is a <a href="#permissible">permissible worker</a>, or: |
| 1501 |
|
|
|
| 1502 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="d7509b8da81775bedb5ee6522497f03d"><span class=en-original lang=en>there is a <a href="#protected">protected worker</a> that at some |
| 1503 |
wakaba |
1.23 |
point past or present owned a <code>MessagePort</code> that was entangled |
| 1504 |
|
|
with a <code>MessagePort</code> owned by this worker. |
| 1505 |
wakaba |
1.36 |
</span></ul> |
| 1506 |
wakaba |
1.23 |
|
| 1507 |
|
|
<hr> |
| 1508 |
|
|
|
| 1509 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="dfc82489e5358f7b62384576218af90c"><span class=en-original lang=en>A worker is said to be an <dfn id=active>active needed worker</dfn> if |
| 1510 |
wakaba |
1.23 |
either: |
| 1511 |
|
|
|
| 1512 |
wakaba |
1.36 |
</span><ul> |
| 1513 |
|
|
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="96d00b9fb7eefe6bb33e07260d2353f9"><span class=en-original lang=en>the worker is a <a href="#protected">protected worker</a>, or |
| 1514 |
wakaba |
1.23 |
|
| 1515 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="2699a98205d3a6b47ed37910f9896717"><span class=en-original lang=en>at least one of the <a href="#the-workers0">the worker's ports</a> is |
| 1516 |
wakaba |
1.23 |
entangled with a <code>MessagePort</code> <var title="">p</var> whose |
| 1517 |
|
|
owner is a <code>Window</code> object whose <span>active document</span> |
| 1518 |
|
|
is the <code>Document</code> that was that <span>browsing |
| 1519 |
|
|
context</span>'s <span>active document</span> when that |
| 1520 |
|
|
<code>MessagePort</code> <var title="">p</var> was created, and that |
| 1521 |
|
|
<code>Document</code> is <span>fully active</span>, or |
| 1522 |
wakaba |
1.22 |
|
| 1523 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="67f1204baba1d8bcbbfab28233d2b0d9"><span class=en-original lang=en>at least one of the <a href="#the-workers0">the worker's ports</a> has |
| 1524 |
wakaba |
1.22 |
an entangled <code>MessagePort</code> owned by a <code><a |
| 1525 |
|
|
href="#workerglobalscope">WorkerGlobalScope</a></code> object that is |
| 1526 |
wakaba |
1.23 |
itself an <a href="#active">active needed worker</a>. |
| 1527 |
wakaba |
1.36 |
</span></ul> |
| 1528 |
wakaba |
1.22 |
|
| 1529 |
|
|
<hr> |
| 1530 |
|
|
|
| 1531 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="7642aaede09c23a089220c1421edcbec"><span class=en-original lang=en>A worker is said to be a <dfn id=suspendable>suspendable worker</dfn> if |
| 1532 |
wakaba |
1.23 |
it is not an <a href="#active">active needed worker</a> but either: |
| 1533 |
wakaba |
1.22 |
|
| 1534 |
wakaba |
1.36 |
</span><ul> |
| 1535 |
|
|
<li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="960ae661864050c379756482359cf786"><span class=en-original lang=en>at least one of the <a href="#the-workers0">the worker's ports</a> has |
| 1536 |
wakaba |
1.23 |
an entangled <code>MessagePort</code> owned by a <code>Window</code> |
| 1537 |
|
|
object, or |
| 1538 |
|
|
|
| 1539 |
wakaba |
1.36 |
</span><li><p class="no-ja-translation ja-translation-inserted" data-ja-hash="c6381c6ecda2bf8a5113dcf88b55f65f"><span class=en-original lang=en>at least one of the <a href="#the-workers0">the worker's ports</a> has |
| 1540 |
wakaba |
1.22 |
an entangled <code>MessagePort</code> owned by a <code><a |
| 1541 |
|
|
href="#workerglobalscope">WorkerGlobalScope</a></code> object that is |
| 1542 |
wakaba |
1.23 |
itself a <span>needed worker</span>. |
| 1543 |
wakaba |
1.36 |
</span></ul> |
| 1544 |
wakaba |
1.16 |
|
| 1545 |
wakaba |
1.36 |
<h3 id=processing class="has-ja-translation" data-ja-hash="4eeffb677544f6c8799408c6b9021b4c"><span class=en-original lang=en><span class=secno>2.5 </span>Processing model</span><span class=ja-translation lang=ja><span class=secno>2.5 </span>処理モデル</span></h3> |
| 1546 |
wakaba |
1.12 |
|
| 1547 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="afec947263d09d9f2e0ae3ae9d2a5a48"><span class=en-original lang=en>When a user agent is to <dfn id="en-run-a">run a worker</dfn> for a script |
| 1548 |
wakaba |
1.29 |
with <span>URL</span> <var title="">url</var>, a browsing context <var |
| 1549 |
|
|
title="">owner browsing context</var>, a <code>Document</code> <var |
| 1550 |
|
|
title="">owner document</var>, and with global scope <var title="">worker |
| 1551 |
wakaba |
1.30 |
global scope</var>, it must run the following steps: |
| 1552 |
wakaba |
1.29 |
|
| 1553 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>利用者エージェントが <span>URL</span> <var title="">url</var>、閲覧文脈 <var |
| 1554 |
|
|
title="">owner browsing context</var>、 <code>Document</code> <var |
| 1555 |
|
|
title="">owner document</var>、大域作用域 <var title="">worker |
| 1556 |
|
|
global scope</var> をもってスクリプトのために<dfn id=run-a>労働者を走らせる</dfn>という時には、次の段階を走らせなければ<em class=rfc2119 title="MUST">なりません</em>。</span><ol> |
| 1557 |
wakaba |
1.12 |
<li> |
| 1558 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="6fdced8613c508a9db62b2a4bec3fba3"><span class=en-original lang=en>Create a completely separate and parallel execution environment (i.e. |
| 1559 |
wakaba |
1.30 |
a separate thread or process or equivalent construct), and run the rest |
| 1560 |
wakaba |
1.36 |
of these steps asychronously in that context.</span><span class=ja-translation lang=ja>完全に分離された並列の実行環境 (すなわち、別のスレッドやプロセスや等価な構造体) を作り、 |
| 1561 |
|
|
その文脈で非同期にこれらの段階の残りを走らせます。</span></p> |
| 1562 |
wakaba |
1.30 |
|
| 1563 |
|
|
<li> |
| 1564 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="224b109aab7dec5a65f7db20a27a6ebe"><span class=en-original lang=en>Attempt to <span>fetch</span><!-- XXX --> the resource identified by |
| 1565 |
wakaba |
1.32 |
<var title="">url</var>.</span><span class=ja-translation lang=ja><var title="">url</var> で識別される資源を取って来ようと試みます。</span></p> |
| 1566 |
wakaba |
1.12 |
|
| 1567 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="35afd3bf1c15de2f7bd9a914bdce905c"><span class=en-original lang=en>If the attempt fails, then, at the next available opportunity, after |
| 1568 |
wakaba |
1.29 |
any scripts have finished executing<!-- XXX queue -->, <span>fire a |
| 1569 |
|
|
simple event</span> called <code title=event-error>error</code> at all |
| 1570 |
|
|
<code><a href="#worker1">Worker</a></code> or <code><a |
| 1571 |
|
|
href="#sharedworker">SharedWorker</a></code> objects associated with |
| 1572 |
wakaba |
1.36 |
<var title="">worker global scope</var>. Abort these steps.</span></p> |
| 1573 |
wakaba |
1.12 |
|
| 1574 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="9f4294dc22071991ed41be40c61ad885"><span class=en-original lang=en>If the attempt succeeds, then let <var title="">script</var> be the |
| 1575 |
wakaba |
1.32 |
resource that was obtained.</span><span class=ja-translation lang=ja>この試みが成功した場合、 <var title="">script</var> |
| 1576 |
wakaba |
1.12 |
を得られた資源とします。</span></p> |
| 1577 |
|
|
|
| 1578 |
wakaba |
1.36 |
<p class="note has-ja-translation" data-ja-hash="5ba762159d9de3f8bd326fe0bcfac206"><span class=en-original lang=en>As with <code>script</code> elements, the MIME type of the |
| 1579 |
wakaba |
1.32 |
script is ignored. Unlike with <code>script</code> elements, there is no |
| 1580 |
|
|
way to override the type. It's always assumed to be JavaScript.</span><span class=ja-translation lang=ja><code>script</code> 要素と同様に、スクリプトの MIME 型は無視します。 |
| 1581 |
wakaba |
1.12 |
<code>script</code> 要素とは異なり、 |
| 1582 |
|
|
型を上書きする方法はありません。スクリプトは常に JavaScript |
| 1583 |
|
|
と仮定します。</span></p> |
| 1584 |
wakaba |
1.11 |
<!-- XXX people will complain about |
| 1585 |
|
|
this. I guess we might want to examine the MIME type... --> |
| 1586 |
|
|
|
| 1587 |
|
|
|
| 1588 |
|
|
<li> |
| 1589 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="85f303cd5cc426e5c9e4264accc8331c"><span class=en-original lang=en>Create a new <code><a href="#workerlocation">WorkerLocation</a></code> |
| 1590 |
wakaba |
1.23 |
object for the <code title=dom-WorkerGlobalScope-location><a |
| 1591 |
wakaba |
1.29 |
href="#location">location</a></code> attribute of <var title="">worker |
| 1592 |
wakaba |
1.36 |
global scope</var>, representing <var title="">url</var>.</span></p> |
| 1593 |
wakaba |
1.23 |
|
| 1594 |
|
|
<li> |
| 1595 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="57f2fa250f68b2d7999150599c6d6662"><span class=en-original lang=en>Let <var title="">script</var>'s <span>script execution context</span> |
| 1596 |
wakaba |
1.29 |
(and thus also <span>global object</span>) be <var title="">worker |
| 1597 |
wakaba |
1.36 |
global scope</var>.</span></p> |
| 1598 |
wakaba |
1.9 |
|
| 1599 |
|
|
<li> |
| 1600 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="6746ae7821139d79deeb7bea1d752b6e"><span class=en-original lang=en>Let <var title="">script</var>'s <span>script browsing context</span> |
| 1601 |
|
|
be <var title="">owner browsing context</var>.</span><span class=ja-translation lang=ja><var title="">script</var> のスクリプト閲覧文脈を、 |
| 1602 |
|
|
<var title="">owner browsing context</var> |
| 1603 |
wakaba |
1.12 |
とします。</span></p> |
| 1604 |
wakaba |
1.9 |
|
| 1605 |
|
|
<li> |
| 1606 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="39336ed04b59d4c3873caf9f760b064e"><span class=en-original lang=en>Let <var title="">script</var>'s <span>script document context</span> |
| 1607 |
|
|
be <var title="">owner document</var>.</span><span class=ja-translation lang=ja><var title="">script</var> のスクリプト文書文脈を、 |
| 1608 |
|
|
<var title="">owner document</var> |
| 1609 |
wakaba |
1.12 |
とします。</span></p> |
| 1610 |
wakaba |
1.9 |
|
| 1611 |
|
|
<li> |
| 1612 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="e398ac96f2c6a566febdc580065b9d53"><span class=en-original lang=en><strong>Closing orphan workers</strong>: Start monitoring the worker |
| 1613 |
wakaba |
1.29 |
such that as soon as it stops being either an <a href="#active">active |
| 1614 |
|
|
needed worker</a> or a <a href="#suspendable">suspendable worker</a>, |
| 1615 |
|
|
the <var title="">worker global scope</var>'s <a href="#closing" |
| 1616 |
|
|
title=dom-WorkerGlobalScope-closing>closing</a> flag is set to true and |
| 1617 |
|
|
an event named <code title=event-close>close</code>, which uses the |
| 1618 |
wakaba |
1.25 |
<code>Event</code> object, which does not bubble, and which is not |
| 1619 |
wakaba |
1.29 |
cancelable, is added it to <var title="">worker global scope</var>'s |
| 1620 |
|
|
<code><a href="#workerglobalscope">WorkerGlobalScope</a></code> object's |
| 1621 |
|
|
<a href="#queue">queue of events</a>, targetted at the <var |
| 1622 |
wakaba |
1.36 |
title="">worker global scope</var> itself.</span></p> |
| 1623 |
wakaba |
1.29 |
|
| 1624 |
|
|
<li> |
| 1625 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="1b813b96af4f3c66b891e7626ca59b7e"><span class=en-original lang=en><strong>Suspending workers</strong>: Start monitoring the worker, such |
| 1626 |
wakaba |
1.29 |
that whenever the <var title="">worker global scope</var>'s <a |
| 1627 |
|
|
href="#closing" title=dom-WorkerGlobalScope-closing>closing</a> flag is |
| 1628 |
|
|
false and the worker is a <a href="#suspendable">suspendable worker</a>, |
| 1629 |
|
|
the user agent suspends execution of script in that worker until such |
| 1630 |
|
|
time as either the <a href="#closing" |
| 1631 |
|
|
title=dom-WorkerGlobalScope-closing>closing</a> flag switches to true or |
| 1632 |
wakaba |
1.36 |
the worker stops being a <a href="#suspendable">suspendable worker</a>.</span></p> |
| 1633 |
wakaba |
1.29 |
|
| 1634 |
|
|
<li> |
| 1635 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="9d0567ebd1e84fc79b01e38719d99393"><span class=en-original lang=en>Run <var title="">script</var> until it either returns, fails to catch |
| 1636 |
wakaba |
1.29 |
an exception, or gets prematurely aborted by the "<a href="#kill-a">kill |
| 1637 |
wakaba |
1.30 |
a worker</a>" or "<a href="#terminate">terminate a worker</a>" |
| 1638 |
wakaba |
1.36 |
algorithms defined below.</span></p> |
| 1639 |
wakaba |
1.11 |
|
| 1640 |
wakaba |
1.36 |
<p class="note no-ja-translation" data-ja-hash="50ce1d183cf3d8f1223c77ef60fe049a"><span class=en-original lang=en>If the script gets aborted by the "<a href="#kill-a">kill a |
| 1641 |
wakaba |
1.23 |
worker</a>" algorithm, then that same algorithm will cause there to only |
| 1642 |
|
|
be a single event in the <a href="#queue">queue of events</a> at the |
| 1643 |
wakaba |
1.29 |
next step, namely the <code title=message-close>close</code> event. The |
| 1644 |
wakaba |
1.30 |
"<a href="#terminate">terminate a worker</a>" algorithm removes all the |
| 1645 |
wakaba |
1.36 |
events.</span></p> |
| 1646 |
wakaba |
1.9 |
|
| 1647 |
|
|
<li> |
| 1648 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="ccb4de5e34d7648e416879951c4cd633"><span class=en-original lang=en><i>Event loop</i>: Wait until either there is an event in the <a |
| 1649 |
wakaba |
1.29 |
href="#queue">queue of events</a> associated with <var title="">worker |
| 1650 |
|
|
global scope</var> or the <var title="">worker global scope</var>'s <a |
| 1651 |
|
|
href="#closing" title=dom-WorkerGlobalScope-closing>closing</a> flag is |
| 1652 |
wakaba |
1.36 |
set to true.</span></p> |
| 1653 |
wakaba |
1.9 |
|
| 1654 |
|
|
<li> |
| 1655 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="cee49ba92341c5640585c60b4ee41a04"><span class=en-original lang=en>Dispatch the oldest event or callback in the <a href="#queue">queue of |
| 1656 |
wakaba |
1.29 |
events</a>, if any. The handling of this event or the execution of this |
| 1657 |
|
|
callback might get prematurely aborted by the "<a href="#kill-a">kill a |
| 1658 |
wakaba |
1.30 |
worker</a>" or "<a href="#terminate">terminate a worker</a>" algorithms |
| 1659 |
wakaba |
1.36 |
defined below.</span></p> |
| 1660 |
wakaba |
1.9 |
|
| 1661 |
|
|
<li> |
| 1662 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="2dc7477f5e517d12d701596ab83d6b6d"><span class=en-original lang=en>If there are any more events in the <a href="#queue">queue of |
| 1663 |
wakaba |
1.29 |
events</a> or if the <var title="">worker global scope</var>'s <a |
| 1664 |
|
|
href="#closing" title=dom-WorkerGlobalScope-closing>closing</a> flag is |
| 1665 |
|
|
set to false, then jump back to the step above labeled <i>event |
| 1666 |
wakaba |
1.36 |
loop</i>.</span></p> |
| 1667 |
wakaba |
1.9 |
|
| 1668 |
|
|
<li> |
| 1669 |
wakaba |
1.36 |
<p class="big-issue no-ja-translation" data-ja-hash="b78b7b4b40826886318de59b818deb99"><span class=en-original lang=en>timers, intervals, XMLHttpRequests, database |
| 1670 |
|
|
transactions, etc, must be killed; ports must be unentangled</span></p> |
| 1671 |
wakaba |
1.25 |
|
| 1672 |
|
|
<li> |
| 1673 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="9134442891a5c1176a5f8704b230b682"><span class=en-original lang=en>At the next available opportunity, after any scripts have finished |
| 1674 |
wakaba |
1.25 |
executing<!-- XXX queue -->, <span>fire a simple event</span> called |
| 1675 |
wakaba |
1.29 |
<code title=event-close>close</code> at all <code><a |
| 1676 |
|
|
href="#worker1">Worker</a></code> or <code><a |
| 1677 |
|
|
href="#sharedworker">SharedWorker</a></code> objects associated with |
| 1678 |
wakaba |
1.36 |
this worker.</span></p> |
| 1679 |
wakaba |
1.9 |
</ol> |
| 1680 |
|
|
|
| 1681 |
|
|
<hr> |
| 1682 |
|
|
|
| 1683 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="f73768ff3e63480f0df2f7a5a6b8f919"><span class=en-original lang=en>When a user agent is to <dfn id=kill-a>kill a worker</dfn> it must run |
| 1684 |
wakaba |
1.29 |
the following steps in parallel with the worker's main loop (the "<a |
| 1685 |
|
|
href="#run-a">run a worker</a>" processing model defined above): |
| 1686 |
|
|
|
| 1687 |
wakaba |
1.36 |
</span><ol> |
| 1688 |
wakaba |
1.14 |
<li> |
| 1689 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="90e045f17a39aa8e713406c196a30ec3"><span class=en-original lang=en>Create an <code>Event</code> object with the event name <code |
| 1690 |
wakaba |
1.29 |
title=event-close>close</code>, which does not bubble and is not |
| 1691 |
wakaba |
1.22 |
cancelable, and add it to the worker's <code><a |
| 1692 |
|
|
href="#workerglobalscope">WorkerGlobalScope</a></code> object's <a |
| 1693 |
|
|
href="#queue">queue of events</a>, targetted at the <code><a |
| 1694 |
|
|
href="#workerglobalscope">WorkerGlobalScope</a></code> object itself. |
| 1695 |
wakaba |
1.36 |
</span></li> |
| 1696 |
wakaba |
1.23 |
<!-- XXX shouldn't add one if closing is |
| 1697 |
wakaba |
1.29 |
already true, assuming close has already been added to the queue |
| 1698 |
wakaba |
1.23 |
(?) --> |
| 1699 |
wakaba |
1.22 |
|
| 1700 |
|
|
<li> |
| 1701 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="6243c3e4951724a3633743634fccb06e"><span class=en-original lang=en>Set the worker's <code><a |
| 1702 |
wakaba |
1.29 |
href="#workerglobalscope">WorkerGlobalScope</a></code> object's <a |
| 1703 |
|
|
href="#closing" title=dom-WorkerGlobalScope-closing>closing</a> flag to |
| 1704 |
|
|
true. |
| 1705 |
wakaba |
1.22 |
|
| 1706 |
wakaba |
1.36 |
</span><li> |
| 1707 |
|
|
<p class="no-ja-translation" data-ja-hash="922d3b59e2016de5b33298ba10ada993"><span class=en-original lang=en>Wait a user-agent-defined amount of time. If the "<a href="#run-a">run |
| 1708 |
wakaba |
1.23 |
a worker</a>" processing model defined above immediately starts running |
| 1709 |
wakaba |
1.29 |
event listeners registered for the <code title=event-close>close</code> |
| 1710 |
|
|
event, this time should not be zero — the idea is that the <code |
| 1711 |
|
|
title=event-close>close</code> event can be used to clean up when |
| 1712 |
|
|
shutting down unexpectedly. |
| 1713 |
|
|
|
| 1714 |
wakaba |
1.36 |
</span><li> |
| 1715 |
|
|
<p class="no-ja-translation" data-ja-hash="cf1e94de0050557afbc1148079de691d"><span class=en-original lang=en>If there are any events in the <a href="#queue">queue of events</a> |
| 1716 |
wakaba |
1.29 |
other than the <code title=event-close>close</code> event that this |
| 1717 |
|
|
algorithm just added, discard them without dispatching them. |
| 1718 |
|
|
|
| 1719 |
wakaba |
1.36 |
</span><li> |
| 1720 |
|
|
<p class="has-ja-translation" data-ja-hash="4351b65cdb5de9c9cdfd3c2a04ad9b6e"><span class=en-original lang=en>If the <code title=event-close>close</code> event that this algorithm |
| 1721 |
wakaba |
1.29 |
just added hasn't yet been dispatched, then abort the script currently |
| 1722 |
|
|
running in the worker. |
| 1723 |
wakaba |
1.23 |
|
| 1724 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>この算法が追加したばかりの <code title=event-close>close</code> |
| 1725 |
|
|
事象がまだ発送されていなければ、労働者中で現在走っているスクリプトを停止します。</span><li> |
| 1726 |
|
|
<p class="has-ja-translation" data-ja-hash="a53f0acde0e4a21781c4b31d5a0f110a"><span class=en-original lang=en>Wait a user-agent-defined amount of time. |
| 1727 |
wakaba |
1.32 |
|
| 1728 |
|
|
</span><span class=ja-translation lang=ja>利用者エージェント定義の時間、待ちます。</span><li> |
| 1729 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="6f55d58072eaadf9aaac96514d919df8"><span class=en-original lang=en>Abort the script currently running in the worker (if any script is |
| 1730 |
wakaba |
1.29 |
running, then it will be a handler for the <code |
| 1731 |
|
|
title=event-close>close</code> event). |
| 1732 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>労働者中で現在走っているスクリプトを停止します |
| 1733 |
|
|
(何かスクリプトが走っているとすれば、それは <code |
| 1734 |
|
|
title=event-close>close</code> |
| 1735 |
|
|
事象の取扱器のはずです)。</span></ol> |
| 1736 |
wakaba |
1.9 |
|
| 1737 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="dbf283f17afc05f538d29f85dc0a52bf"><span class=en-original lang=en>User agents may invoke the "<a href="#kill-a">kill a worker</a>" |
| 1738 |
wakaba |
1.22 |
processing model on a worker at any time, e.g. in response to user |
| 1739 |
|
|
requests, in response to CPU quota management, or when a worker stops |
| 1740 |
wakaba |
1.23 |
being an <a href="#active">active needed worker</a> if the worker |
| 1741 |
wakaba |
1.29 |
continues executing even after its <a href="#closing" |
| 1742 |
|
|
title=dom-WorkerGlobalScope-closing>closing</a> flag was set to true. |
| 1743 |
wakaba |
1.16 |
|
| 1744 |
wakaba |
1.36 |
</span><hr> |
| 1745 |
wakaba |
1.11 |
|
| 1746 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="6e6259fd5536a6ce6726b7f1f7ec2c72"><span class=en-original lang=en>When a user agent is to <dfn id=terminate>terminate a worker</dfn> it |
| 1747 |
wakaba |
1.30 |
must run the following steps in parallel with the worker's main loop (the |
| 1748 |
|
|
"<a href="#run-a">run a worker</a>" processing model defined above): |
| 1749 |
wakaba |
1.22 |
|
| 1750 |
wakaba |
1.36 |
</span><ol> |
| 1751 |
wakaba |
1.22 |
<li> |
| 1752 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="6243c3e4951724a3633743634fccb06e"><span class=en-original lang=en>Set the worker's <code><a |
| 1753 |
wakaba |
1.22 |
href="#workerglobalscope">WorkerGlobalScope</a></code> object's <a |
| 1754 |
wakaba |
1.29 |
href="#closing" title=dom-WorkerGlobalScope-closing>closing</a> flag to |
| 1755 |
|
|
true. |
| 1756 |
wakaba |
1.22 |
|
| 1757 |
wakaba |
1.36 |
</span><li> |
| 1758 |
|
|
<p class="no-ja-translation" data-ja-hash="cf1e94de0050557afbc1148079de691d"><span class=en-original lang=en>If there are any events in the <a href="#queue">queue of events</a> |
| 1759 |
wakaba |
1.29 |
other than the <code title=event-close>close</code> event that this |
| 1760 |
|
|
algorithm just added, discard them without dispatching them. |
| 1761 |
wakaba |
1.22 |
|
| 1762 |
wakaba |
1.36 |
</span><li> |
| 1763 |
|
|
<p class="has-ja-translation" data-ja-hash="fcb471f3c8cace3a86095dcb29d25515"><span class=en-original lang=en>Abort the script currently running in the worker. |
| 1764 |
|
|
</span><span class=ja-translation lang=ja>労働者中で現在走っているスクリプトを停止します。</span></ol> |
| 1765 |
wakaba |
1.11 |
|
| 1766 |
wakaba |
1.36 |
<h3 id=creating class="has-ja-translation" data-ja-hash="f0a4732d38d01e3d103b68468f9fe234"><span class=en-original lang=en><span class=secno>2.6 </span>Creating workers</span><span class=ja-translation lang=ja><span class=secno>2.6 </span>労働者の作成</span></h3> |
| 1767 |
wakaba |
1.9 |
|
| 1768 |
wakaba |
1.36 |
<h4 id=the-abstractworker class="has-ja-translation" data-ja-hash="fe5227371e801f4ac588d0d07472a900" data-ja-real-hash="9a7040b26903cb67873e70582b2e3a5b"><span class=en-original lang=en><span class=secno>2.6.1 </span>The <code><a |
| 1769 |
|
|
href="#abstractworker">AbstractWorker</a></code> abstract interface</span><span class=ja-translation lang=ja><span class=secno>2.6.1 </span><code><a href="#abstractworker">AbstractWorker</a></code> 抽象界面</span></h4> |
| 1770 |
wakaba |
1.29 |
|
| 1771 |
wakaba |
1.9 |
<pre |
| 1772 |
wakaba |
1.36 |
class="idl no-ja-translation" data-ja-hash="ca053e27763a221f744b59e28b9f1149"><span class=en-original lang=en>[NoInterfaceObject] interface <dfn id=abstractworker>AbstractWorker</dfn> { |
| 1773 |
wakaba |
1.29 |
attribute <span>EventListener</span> <a href="#onerror" title=handler-AbstractWorker-onerror>onerror</a>; |
| 1774 |
|
|
attribute <span>EventListener</span> <a href="#onclose0" title=handler-AbstractWorker-onclose>onclose</a>; |
| 1775 |
wakaba |
1.36 |
};</span></pre> |
| 1776 |
wakaba |
1.29 |
|
| 1777 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="4f7356effb9eccb6268b11a363b0c51d"><span class=en-original lang=en>The following are the <span>event handler DOM attributes</span> that |
| 1778 |
wakaba |
1.29 |
must be supported by objects implementing the <code><a |
| 1779 |
|
|
href="#abstractworker">AbstractWorker</a></code> interface: |
| 1780 |
|
|
|
| 1781 |
wakaba |
1.36 |
</span><dl> |
| 1782 |
|
|
<dt class="no-ja-translation" data-ja-hash="ca77fdf585a46daf6ec6823b345faf98"><span class=en-original lang=en><dfn id=onerror |
| 1783 |
wakaba |
1.29 |
title=handler-AbstractWorker-onerror><code>onerror</code></dfn> |
| 1784 |
|
|
|
| 1785 |
wakaba |
1.36 |
</span><dd> |
| 1786 |
|
|
<p class="no-ja-translation" data-ja-hash="3998f6cd6a9193846f5e07b04202500c"><span class=en-original lang=en>Must be invoked whenever an <code title=event-error>error</code> event |
| 1787 |
wakaba |
1.29 |
is targeted at or bubbles through the <code><a |
| 1788 |
|
|
href="#abstractworker">AbstractWorker</a></code> object. |
| 1789 |
|
|
|
| 1790 |
wakaba |
1.36 |
</span><dt class="no-ja-translation" data-ja-hash="a66f8d800a45cc2273dc71888c78ecd0"><span class=en-original lang=en><dfn id=onclose0 |
| 1791 |
wakaba |
1.29 |
title=handler-AbstractWorker-onclose><code>onclose</code></dfn> |
| 1792 |
|
|
|
| 1793 |
wakaba |
1.36 |
</span><dd> |
| 1794 |
|
|
<p class="no-ja-translation" data-ja-hash="90325fa5f5171b4f558eabaeac83bba8"><span class=en-original lang=en>Must be invoked whenever an <code title=event-close>close</code> event |
| 1795 |
wakaba |
1.29 |
is targeted at or bubbles through the <code><a |
| 1796 |
|
|
href="#abstractworker">AbstractWorker</a></code> object. |
| 1797 |
wakaba |
1.36 |
</span></dl> |
| 1798 |
wakaba |
1.25 |
|
| 1799 |
wakaba |
1.36 |
<h4 id=dedicated0 class="no-ja-translation" data-ja-hash="a19aaade72c8a5d27a02c8d16642f277"><span class=en-original lang=en><span class=secno>2.6.2 </span>Dedicated workers and the |
| 1800 |
|
|
<code><a href="#worker1">Worker</a></code> interface</span></h4> |
| 1801 |
wakaba |
1.25 |
|
| 1802 |
wakaba |
1.36 |
<pre class="idl no-ja-translation" data-ja-hash="ce77c4526d92d4c2e29fb7cece2b8abe"><span class=en-original lang=en>[NoInterfaceObject, |
| 1803 |
wakaba |
1.29 |
<a href="#worker2" title=dom-Worker>Constructor</a>(in DOMString scriptURL)] |
| 1804 |
|
|
interface <dfn id=worker1>Worker</dfn> : <a href="#abstractworker">AbstractWorker</a> { |
| 1805 |
|
|
void <a href="#close0" title=dom-Worker-close>close</a>(); |
| 1806 |
|
|
|
| 1807 |
wakaba |
1.30 |
void <a href="#postmessage0" title=dom-Worker-postMessage>postMessage</a>(in DOMString message); |
| 1808 |
|
|
void <a href="#postmessage0" title=dom-Worker-postMessage>postMessage</a>(in DOMString message, in <span>MessagePort</span> messagePort); |
| 1809 |
wakaba |
1.29 |
<span>MessagePort</span> <a href="#startconversation0" title=dom-Worker-startConversation>startConversation</a>(in DOMString message); |
| 1810 |
|
|
attribute <span>EventListener</span> <a href="#onmessage0" title=handler-Worker-onmessage>onmessage</a>; |
| 1811 |
wakaba |
1.36 |
};</span></pre> |
| 1812 |
wakaba |
1.9 |
|
| 1813 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="1933f2f577f44af49e0b7a4d5f7165d8"><span class=en-original lang=en>The <dfn id=close0 title=dom-Worker-close><code>close()</code></dfn> |
| 1814 |
wakaba |
1.30 |
method, when invoked, must cause the "<a href="#terminate">terminate a |
| 1815 |
|
|
worker</a>" algorithm to be run on the worker with with the object is |
| 1816 |
|
|
associated. |
| 1817 |
wakaba |
1.29 |
|
| 1818 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="5bc910b7c194db663b68f5a7d4c10a61"><span class=en-original lang=en><code><a href="#worker1">Worker</a></code> objects act as if they had an |
| 1819 |
wakaba |
1.29 |
implicit <code>MessagePort</code> associated with them. This port is part |
| 1820 |
|
|
of a channel that is set up when the worker is created, but it is not |
| 1821 |
|
|
exposed. This object must never be garbage collected before the <code><a |
| 1822 |
|
|
href="#worker1">Worker</a></code> object. |
| 1823 |
|
|
|
| 1824 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="6913e4a1e1b8f864b65900e6b4f480ed"><span class=en-original lang=en>All messages received by that port must immediately be retargetted at |
| 1825 |
wakaba |
1.29 |
the <code><a href="#worker1">Worker</a></code> object. |
| 1826 |
|
|
|
| 1827 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="c57acdd450f644141077711c82b838a0"><span class=en-original lang=en>The <dfn id=postmessage0 |
| 1828 |
wakaba |
1.29 |
title=dom-Worker-postMessage><code>postMessage()</code></dfn> and <dfn |
| 1829 |
|
|
id=startconversation0 |
| 1830 |
|
|
title=dom-Worker-startConversation><code>startConversation()</code></dfn> |
| 1831 |
|
|
methods on <code><a href="#worker1">Worker</a></code> objects must act as |
| 1832 |
|
|
if, when invoked, they immediately invoked the method of the same name on |
| 1833 |
wakaba |
1.30 |
the port, with the same arguments, and returned the same return value. |
| 1834 |
wakaba |
1.29 |
|
| 1835 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="e5b4a11fecaff5acef7e63837606f9a6"><span class=en-original lang=en>The following are the <span>event handler DOM attributes</span> that |
| 1836 |
wakaba |
1.29 |
must be supported by objects implementing the <code><a |
| 1837 |
|
|
href="#worker1">Worker</a></code> interface: |
| 1838 |
|
|
|
| 1839 |
wakaba |
1.36 |
</span><dl> |
| 1840 |
|
|
<dt class="no-ja-translation" data-ja-hash="1e7efb7f0b77ed1e6f543f6c9cc3387e"><span class=en-original lang=en><dfn id=onmessage0 |
| 1841 |
wakaba |
1.29 |
title=handler-Worker-onmessage><code>onmessage</code></dfn> |
| 1842 |
|
|
|
| 1843 |
wakaba |
1.36 |
</span><dd> |
| 1844 |
|
|
<p class="has-ja-translation" data-ja-hash="91a2ce3a21f7ed687afe756baa5387d8" data-ja-real-hash="c68f92321aa3d122a0022259f645a1d2"><span class=en-original lang=en>Must be invoked whenever a <code |
| 1845 |
wakaba |
1.32 |
title=event-Worker-message>message</code> event is targeted at or |
| 1846 |
|
|
bubbles through the <code><a href="#worker1">Worker</a></code> object. |
| 1847 |
|
|
</span><span class=ja-translation lang=ja><code title=event-Worker-message>message</code> 事象が当該 <code><a href="#worker1">Worker</a></code> オブジェクトを対象としているか、泡立って当該オブジェクトを通過する時に、 |
| 1848 |
wakaba |
1.29 |
呼び出されなければなりません。</span></dl> |
| 1849 |
wakaba |
1.22 |
|
| 1850 |
|
|
<hr> |
| 1851 |
wakaba |
1.13 |
|
| 1852 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="82fcc98f85490bca63805a347135340d"><span class=en-original lang=en>When the <dfn id=worker2 title=dom-Worker><code>Worker(<var |
| 1853 |
wakaba |
1.29 |
title="">scriptURL</var>)</code></dfn> constructor is invoked, the user |
| 1854 |
|
|
agent must run the following steps: |
| 1855 |
|
|
|
| 1856 |
wakaba |
1.36 |
</span><ol> |
| 1857 |
wakaba |
1.13 |
<li> |
| 1858 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="3219e42f1040482201a693e248f580cb"><span class=en-original lang=en><span title="resolve a url">Resolve</span> the <var |
| 1859 |
wakaba |
1.32 |
title="">scriptURL</var> argument. |
| 1860 |
|
|
|
| 1861 |
|
|
</span><span class=ja-translation lang=ja><var |
| 1862 |
wakaba |
1.15 |
title="">scriptURL</var> 引数を<span title="resolve a url">解決</span>します。</span><li> |
| 1863 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="160444b5a61c1e71f39825a01936237f"><span class=en-original lang=en>If this fails, throw a <code>SYNTAX_ERR</code> exception. |
| 1864 |
wakaba |
1.32 |
|
| 1865 |
|
|
</span><span class=ja-translation lang=ja>これが失敗した場合、 <code>SYNTAX_ERR</code> |
| 1866 |
wakaba |
1.15 |
例外を投げます。</span><li> |
| 1867 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="b087dd24bd7b57655bef9f719db30b9a"><span class=en-original lang=en>If the <span>origin</span> of the resulting <span>absolute URL</span> |
| 1868 |
wakaba |
1.29 |
is not the <span title="same origin">same</span> as the origin of the |
| 1869 |
|
|
script that invoked the constructor, then throw a <span>security |
| 1870 |
|
|
exception</span>. |
| 1871 |
|
|
|
| 1872 |
wakaba |
1.36 |
</span><li> |
| 1873 |
|
|
<p class="no-ja-translation" data-ja-hash="d7b9bc07a489235fdd4d6ecb508f1a86"><span class=en-original lang=en><span>Create a new <code><a |
| 1874 |
wakaba |
1.29 |
href="#dedicatedworkerglobalscope">DedicatedWorkerGlobalScope</a></code> |
| 1875 |
|
|
object</span>. Let this be the <var title="">worker global scope</var>. |
| 1876 |
|
|
|
| 1877 |
wakaba |
1.36 |
</span><li> |
| 1878 |
|
|
<p class="no-ja-translation" data-ja-hash="925e7c1609162a4bcadfcf3e85572a16"><span class=en-original lang=en>Create a new <code><a href="#worker1">Worker</a></code> object, |
| 1879 |
wakaba |
1.29 |
associated with <var title="">worker global scope</var>. Let this |
| 1880 |
|
|
<code><a href="#worker1">Worker</a></code> object be <var |
| 1881 |
|
|
title="">worker</var>. |
| 1882 |
|
|
|
| 1883 |
wakaba |
1.36 |
</span><li> |
| 1884 |
|
|
<p class="no-ja-translation" data-ja-hash="07cc057567324a83e25ec6344dc011a7"><span class=en-original lang=en><span>Create a <code>MessagePort</code> object</span> owned by the |
| 1885 |
wakaba |
1.29 |
<span>script execution context</span> of the script that invoked the |
| 1886 |
|
|
method. Let this be the <var title="">outside port</var>. |
| 1887 |
|
|
|
| 1888 |
wakaba |
1.36 |
</span><li> |
| 1889 |
|
|
<p class="has-ja-translation" data-ja-hash="91024eaaebdc23ea683ace1b3e316962"><span class=en-original lang=en>Associate the <var title="">outside port</var> with <var |
| 1890 |
wakaba |
1.29 |
title="">worker</var>. |
| 1891 |
|
|
|
| 1892 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><var title="">outside port</var> を <var |
| 1893 |
|
|
title="">worker</var> に関連付けます。</span><li> |
| 1894 |
|
|
<p class="no-ja-translation" data-ja-hash="e87b6ef3fda022b070571262147c6f22"><span class=en-original lang=en><span>Create a <code>MessagePort</code> object</span> owned by the |
| 1895 |
wakaba |
1.29 |
<var title="">worker global scope</var>. Let this be the <var |
| 1896 |
|
|
title="">inside port</var>. |
| 1897 |
|
|
|
| 1898 |
wakaba |
1.36 |
</span><li> |
| 1899 |
|
|
<p class="has-ja-translation" data-ja-hash="047476799040ed3c8f2b583408be732a"><span class=en-original lang=en>Associate the <var title="">inside port</var> with <var |
| 1900 |
wakaba |
1.29 |
title="">worker global scope</var>. |
| 1901 |
|
|
|
| 1902 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><var title="">inside port</var> を <var |
| 1903 |
|
|
title="">worker global scope</var> に関連付けます。</span><li> |
| 1904 |
|
|
<p class="no-ja-translation" data-ja-hash="bf2642ced659847cb4402165d2ab3a8e"><span class=en-original lang=en><span>Entangle</span> <var title="">outside port</var> and <var |
| 1905 |
wakaba |
1.29 |
title="">inside port</var>. |
| 1906 |
|
|
|
| 1907 |
wakaba |
1.36 |
</span><li> |
| 1908 |
|
|
<p class="has-ja-translation" data-ja-hash="2c5bd80faeda34c67a2533f32a477c51"><span class=en-original lang=en>Return <var title="">worker</var>, and run the following steps |
| 1909 |
wakaba |
1.29 |
asynchronously. |
| 1910 |
|
|
|
| 1911 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><var title="">worker</var> を返し、以降の段階を非同期に走らせます。</span><li> |
| 1912 |
|
|
<p class="has-ja-translation" data-ja-hash="faa1ae1399f8e4f6b212fe45bba07893"><span class=en-original lang=en>Open <var title="">inside port</var>'s <span>port message |
| 1913 |
wakaba |
1.29 |
queue</span>. |
| 1914 |
|
|
|
| 1915 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><var title="">inside port</var> の<span>ポート・メッセージ待ち行列</span>を開きます。</span><li> |
| 1916 |
|
|
<p class="has-ja-translation" data-ja-hash="5eaa92a75cbbf580809052327262059a"><span class=en-original lang=en>Open <var title="">outside port</var>'s <span>port message |
| 1917 |
wakaba |
1.30 |
queue</span>. |
| 1918 |
|
|
|
| 1919 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><var title="">outside port</var> の<span>ポート・メッセージ待ち行列</span>を開きます。</span><li> |
| 1920 |
|
|
<p class="no-ja-translation" data-ja-hash="5dde6963d0fd86935486ce9c7473b40e"><span class=en-original lang=en><a href="#run-a">Run a worker</a>, with the <span>script browsing |
| 1921 |
wakaba |
1.30 |
context</span> of the script that invoked the method as the <var |
| 1922 |
|
|
title="">owner browsing context</var>, with the <span>script document |
| 1923 |
|
|
context</span> of the script that invoked the method as the <var |
| 1924 |
|
|
title="">owner document</var>, and with <var title="">worker global |
| 1925 |
wakaba |
1.36 |
scope</var> as the global scope.</span></p> |
| 1926 |
wakaba |
1.25 |
</ol> |
| 1927 |
wakaba |
1.11 |
|
| 1928 |
wakaba |
1.36 |
<h4 id=shared1 class="no-ja-translation" data-ja-hash="660755479f7743bee608286560e94bfd"><span class=en-original lang=en><span class=secno>2.6.3 </span>Shared workers and the |
| 1929 |
|
|
<code><a href="#sharedworker">SharedWorker</a></code> interface</span></h4> |
| 1930 |
wakaba |
1.29 |
|
| 1931 |
wakaba |
1.36 |
<pre class="idl no-ja-translation" data-ja-hash="e9f64514cc5486960acf6e0d6fda83c8"><span class=en-original lang=en>[NoInterfaceObject, |
| 1932 |
wakaba |
1.29 |
<a href="#sharedworker0" title=dom-SharedWorker>Constructor</a>(in DOMString scriptURL, in DOMString name)] |
| 1933 |
|
|
interface <dfn id=sharedworker>SharedWorker</dfn> : <a href="#abstractworker">AbstractWorker</a> { |
| 1934 |
|
|
readonly attribute <code>MessagePort</code> <a href="#port" title=dom-SharedWorker-port>port</a>; |
| 1935 |
wakaba |
1.36 |
};</span></pre> |
| 1936 |
wakaba |
1.29 |
|
| 1937 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="fa90f278bf10ccc803f16340cb3454f3"><span class=en-original lang=en>The <dfn id=port title=dom-SharedWorker-port><code>port</code></dfn> |
| 1938 |
wakaba |
1.29 |
attribute must return the value it was assigned by the object's |
| 1939 |
|
|
constructor. It represents the <code>MessagePort</code> for communicating |
| 1940 |
|
|
with the shared worker. |
| 1941 |
|
|
|
| 1942 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="ec56f4c5071ac285686586d381295796"><span class=en-original lang=en>When the <dfn id=sharedworker0 |
| 1943 |
wakaba |
1.29 |
title=dom-SharedWorker><code>SharedWorker(<var title="">scriptURL</var>, |
| 1944 |
|
|
<var title="">name</var>)</code></dfn> constructor is invoked, the user |
| 1945 |
|
|
agent must run the following steps: |
| 1946 |
wakaba |
1.11 |
|
| 1947 |
wakaba |
1.36 |
</span><ol> |
| 1948 |
wakaba |
1.13 |
<li> |
| 1949 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="3219e42f1040482201a693e248f580cb"><span class=en-original lang=en><span title="resolve a url">Resolve</span> the <var |
| 1950 |
wakaba |
1.32 |
title="">scriptURL</var> argument. |
| 1951 |
|
|
|
| 1952 |
|
|
</span><span class=ja-translation lang=ja><var |
| 1953 |
wakaba |
1.15 |
title="">scriptURL</var> 引数を<span title="resolve a url">解決</span>します。</span><li> |
| 1954 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="160444b5a61c1e71f39825a01936237f"><span class=en-original lang=en>If this fails, throw a <code>SYNTAX_ERR</code> exception. |
| 1955 |
wakaba |
1.32 |
|
| 1956 |
|
|
</span><span class=ja-translation lang=ja>これが失敗した場合、 <code>SYNTAX_ERR</code> |
| 1957 |
wakaba |
1.15 |
例外を投げます。</span><li> |
| 1958 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="b087dd24bd7b57655bef9f719db30b9a"><span class=en-original lang=en>If the <span>origin</span> of the resulting <span>absolute URL</span> |
| 1959 |
wakaba |
1.29 |
is not the <span title="same origin">same</span> as the origin of the |
| 1960 |
|
|
script that invoked the constructor, then throw a <span>security |
| 1961 |
|
|
exception</span>. |
| 1962 |
|
|
|
| 1963 |
wakaba |
1.36 |
</span><li> |
| 1964 |
|
|
<p class="has-ja-translation" data-ja-hash="683a2c0080e014b9eae98b884ccaf7e4"><span class=en-original lang=en>Execute the following substeps atomically:</span><span class=ja-translation lang=ja>次の部分段階群を原子的に実行します。</span></p> |
| 1965 |
wakaba |
1.13 |
|
| 1966 |
|
|
<ol> |
| 1967 |
|
|
<li> |
| 1968 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="2800d1a8667906afc331a67e21d9ea29"><span class=en-original lang=en>Create a new <code><a href="#sharedworker">SharedWorker</a></code> |
| 1969 |
wakaba |
1.29 |
object, which will shortly be associated with a <code><a |
| 1970 |
|
|
href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> |
| 1971 |
|
|
object. Let this <code><a href="#sharedworker">SharedWorker</a></code> |
| 1972 |
|
|
object be <var title="">worker</var>. |
| 1973 |
wakaba |
1.22 |
|
| 1974 |
wakaba |
1.36 |
</span><li> |
| 1975 |
|
|
<p class="no-ja-translation" data-ja-hash="07cc057567324a83e25ec6344dc011a7"><span class=en-original lang=en><span>Create a <code>MessagePort</code> object</span> owned by the |
| 1976 |
wakaba |
1.29 |
<span>script execution context</span> of the script that invoked the |
| 1977 |
|
|
method. Let this be the <var title="">outside port</var>. |
| 1978 |
wakaba |
1.25 |
|
| 1979 |
wakaba |
1.36 |
</span><li> |
| 1980 |
|
|
<p class="no-ja-translation" data-ja-hash="95cd5e27932141432ed9ff6323032568"><span class=en-original lang=en>Assign <var title="">outside port</var> to the <code |
| 1981 |
wakaba |
1.29 |
title=dom-SharedWorker-port><a href="#port">port</a></code> attribute |
| 1982 |
|
|
of <var title="">worker</var>. |
| 1983 |
wakaba |
1.25 |
|
| 1984 |
wakaba |
1.36 |
</span><li> |
| 1985 |
|
|
<p class="no-ja-translation" data-ja-hash="5aec0369bd40bfd0f0ff2dc70f75b9f5"><span class=en-original lang=en>If there exists a <code><a |
| 1986 |
wakaba |
1.29 |
href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> |
| 1987 |
|
|
object whose <a href="#closing" |
| 1988 |
|
|
title=dom-WorkerGlobalScope-closing>closing</a> flag is false, whose |
| 1989 |
|
|
<code title=dom-WorkerGlobalScope-name>name</code> attribute is |
| 1990 |
|
|
exactly equal to the <var title="">name</var> argument, and whose |
| 1991 |
|
|
<code title=dom-WorkerGlobalScope-location><a |
| 1992 |
|
|
href="#location">location</a></code> attribute represents an |
| 1993 |
|
|
<span>absolute URL</span> that has the <span>same origin</span> as the |
| 1994 |
wakaba |
1.36 |
resulting <span>absolute URL</span>, then run these substeps:</span></p> |
| 1995 |
wakaba |
1.25 |
|
| 1996 |
wakaba |
1.29 |
<ol> |
| 1997 |
|
|
<li> |
| 1998 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="826754f668578065470b1f9de24553bc"><span class=en-original lang=en>Let <var title="">worker global scope</var> be that <code><a |
| 1999 |
wakaba |
1.29 |
href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> |
| 2000 |
|
|
object. |
| 2001 |
|
|
|
| 2002 |
wakaba |
1.36 |
</span><li> |
| 2003 |
|
|
<p class="no-ja-translation" data-ja-hash="7b6f8fa4ae92ed20dd16a2fb90c3e618"><span class=en-original lang=en>If <var title="">worker global scope</var>'s <code |
| 2004 |
wakaba |
1.29 |
title=dom-WorkerGlobalScope-location><a |
| 2005 |
|
|
href="#location">location</a></code> attribute represents an |
| 2006 |
|
|
<span>absolute URL</span> that is not exactly equal to the resulting |
| 2007 |
|
|
<span>absolute URL</span>, then throw a |
| 2008 |
|
|
<code>URL_MISMATCH_ERR</code> exception and abort all these steps. |
| 2009 |
|
|
<span class=big-issue>code 21</span> |
| 2010 |
|
|
|
| 2011 |
wakaba |
1.36 |
</span><li> |
| 2012 |
|
|
<p class="has-ja-translation" data-ja-hash="9c4f87efaa1e868cd6bf63dbffa749c0"><span class=en-original lang=en>Associate <var title="">worker</var> with <var title="">worker |
| 2013 |
wakaba |
1.29 |
global scope</var>. |
| 2014 |
|
|
|
| 2015 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><var title="">worker</var> を <var title="">worker |
| 2016 |
|
|
global scope</var> に関連付けます。</span><li> |
| 2017 |
|
|
<p class="no-ja-translation" data-ja-hash="e87b6ef3fda022b070571262147c6f22"><span class=en-original lang=en><span>Create a <code>MessagePort</code> object</span> owned by the |
| 2018 |
wakaba |
1.29 |
<var title="">worker global scope</var>. Let this be the <var |
| 2019 |
|
|
title="">inside port</var>. |
| 2020 |
|
|
|
| 2021 |
wakaba |
1.36 |
</span><li> |
| 2022 |
|
|
<p class="no-ja-translation" data-ja-hash="bf2642ced659847cb4402165d2ab3a8e"><span class=en-original lang=en><span>Entangle</span> <var title="">outside port</var> and <var |
| 2023 |
wakaba |
1.29 |
title="">inside port</var>. |
| 2024 |
|
|
|
| 2025 |
wakaba |
1.36 |
</span><li> |
| 2026 |
|
|
<p class="has-ja-translation" data-ja-hash="ebb713e9e29aab450d79b533c42b67ae"><span class=en-original lang=en>Return <var title="">worker</var> and perform the next step |
| 2027 |
wakaba |
1.29 |
asynchronously. |
| 2028 |
|
|
|
| 2029 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><var title="">worker</var> を返し、 |
| 2030 |
|
|
次の段階を非同期に実行します。</span><li> |
| 2031 |
|
|
<p class="no-ja-translation" data-ja-hash="3b59bbc8dc9af6fb95a0a13c18150f55"><span class=en-original lang=en>Create an event that uses the <code>MessageEvent</code> interface, |
| 2032 |
wakaba |
1.29 |
with the name <code title=event-connect>connect</code>, which does |
| 2033 |
|
|
not bubble, is cancelable, has no default action, has a <code |
| 2034 |
|
|
title=dom-MessageEvent-data>data</code> attribute whose value is the |
| 2035 |
|
|
empty string and has a <code |
| 2036 |
|
|
title=dom-MessageEvent-messagePort>messagePort</code> attribute |
| 2037 |
|
|
whose value is the newly created port, and add it to <var |
| 2038 |
|
|
title="">worker global scope</var>'s <a href="#queue">queue of |
| 2039 |
|
|
events</a>, targetted at the <var title="">worker global scope</var> |
| 2040 |
|
|
itself. |
| 2041 |
|
|
|
| 2042 |
wakaba |
1.36 |
</span><li> |
| 2043 |
|
|
<p class="has-ja-translation" data-ja-hash="dd866391287c967d4799df78a7249911"><span class=en-original lang=en>Abort all these steps. |
| 2044 |
|
|
</span><span class=ja-translation lang=ja>これらの段階をすべて停止します。</span></ol> |
| 2045 |
wakaba |
1.11 |
|
| 2046 |
wakaba |
1.29 |
<li> |
| 2047 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="9dd8cf11e82f420b740d38c627bdbd31"><span class=en-original lang=en><span>Create a new <code><a |
| 2048 |
wakaba |
1.29 |
href="#sharedworkerglobalscope">SharedWorkerGlobalScope</a></code> |
| 2049 |
|
|
object</span>. Let this be the <var title="">worker global |
| 2050 |
|
|
scope</var>. |
| 2051 |
wakaba |
1.11 |
|
| 2052 |
wakaba |
1.36 |
</span><li> |
| 2053 |
|
|
<p class="has-ja-translation" data-ja-hash="9c4f87efaa1e868cd6bf63dbffa749c0"><span class=en-original lang=en>Associate <var title="">worker</var> with <var title="">worker |
| 2054 |
wakaba |
1.29 |
global scope</var>. |
| 2055 |
wakaba |
1.23 |
|
| 2056 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><var title="">worker</var> を <var title="">worker |
| 2057 |
|
|
global scope</var> に関連付けます。</span><li> |
| 2058 |
|
|
<p class="no-ja-translation" data-ja-hash="41bc5a86cc5d47bc40691672571f6352"><span class=en-original lang=en>Set the <code title=dom-SharedWorkerGlobalScope-name><a |
| 2059 |
wakaba |
1.29 |
href="#name">name</a></code> attribute of <var title="">worker global |
| 2060 |
|
|
scope</var> be <var title="">name</var>. |
| 2061 |
wakaba |
1.11 |
|
| 2062 |
wakaba |
1.36 |
</span><li> |
| 2063 |
|
|
<p class="no-ja-translation" data-ja-hash="e87b6ef3fda022b070571262147c6f22"><span class=en-original lang=en><span>Create a <code>MessagePort</code> object</span> owned by the |
| 2064 |
wakaba |
1.29 |
<var title="">worker global scope</var>. Let this be the <var |
| 2065 |
|
|
title="">inside port</var>. |
| 2066 |
wakaba |
1.11 |
|
| 2067 |
wakaba |
1.36 |
</span><li> |
| 2068 |
|
|
<p class="no-ja-translation" data-ja-hash="bf2642ced659847cb4402165d2ab3a8e"><span class=en-original lang=en><span>Entangle</span> <var title="">outside port</var> and <var |
| 2069 |
wakaba |
1.29 |
title="">inside port</var>. |
| 2070 |
wakaba |
1.36 |
</span></ol> |
| 2071 |
wakaba |
1.13 |
|
| 2072 |
|
|
<li> |
| 2073 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="ebb713e9e29aab450d79b533c42b67ae"><span class=en-original lang=en>Return <var title="">worker</var> and perform the next step |
| 2074 |
wakaba |
1.29 |
asynchronously. |
| 2075 |
wakaba |
1.25 |
|
| 2076 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><var title="">worker</var> を返し、 |
| 2077 |
|
|
次の段階を非同期に実行します。</span><li> |
| 2078 |
|
|
<p class="no-ja-translation" data-ja-hash="3b59bbc8dc9af6fb95a0a13c18150f55"><span class=en-original lang=en>Create an event that uses the <code>MessageEvent</code> interface, |
| 2079 |
wakaba |
1.22 |
with the name <code title=event-connect>connect</code>, which does not |
| 2080 |
|
|
bubble, is cancelable, has no default action, has a <code |
| 2081 |
|
|
title=dom-MessageEvent-data>data</code> attribute whose value is the |
| 2082 |
|
|
empty string and has a <code |
| 2083 |
|
|
title=dom-MessageEvent-messagePort>messagePort</code> attribute whose |
| 2084 |
wakaba |
1.29 |
value is the newly created port, and add it to <var title="">worker |
| 2085 |
|
|
global scope</var>'s <a href="#queue">queue of events</a>, targetted at |
| 2086 |
|
|
the <var title="">worker global scope</var> itself. |
| 2087 |
wakaba |
1.23 |
|
| 2088 |
wakaba |
1.36 |
</span><li> |
| 2089 |
|
|
<p class="no-ja-translation" data-ja-hash="5dde6963d0fd86935486ce9c7473b40e"><span class=en-original lang=en><a href="#run-a">Run a worker</a>, with the <span>script browsing |
| 2090 |
wakaba |
1.30 |
context</span> of the script that invoked the method as the <var |
| 2091 |
|
|
title="">owner browsing context</var>, with the <span>script document |
| 2092 |
|
|
context</span> of the script that invoked the method as the <var |
| 2093 |
|
|
title="">owner document</var>, and with <var title="">worker global |
| 2094 |
wakaba |
1.36 |
scope</var> as the global scope.</span></p> |
| 2095 |
wakaba |
1.22 |
</ol> |
| 2096 |
wakaba |
1.15 |
|
| 2097 |
wakaba |
1.36 |
<h2 id=apis-available class="has-ja-translation" data-ja-hash="4fce100e6a2eccbb2df8631a438feeb6"><span class=en-original lang=en><span class=secno>3. </span>APIs available to workers</span><span class=ja-translation lang=ja><span class=secno>3. </span>労働者が利用可能な API</span></h2> |
| 2098 |
wakaba |
1.15 |
|
| 2099 |
wakaba |
1.22 |
<pre |
| 2100 |
wakaba |
1.36 |
class="idl no-ja-translation" data-ja-hash="19b0864717610ad2e6bd630fe67c2669"><span class=en-original lang=en>[NoInterfaceObject] interface <dfn id=workerutils>WorkerUtils</dfn> { |
| 2101 |
wakaba |
1.25 |
void <a href="#importscripts" title=dom-WorkerGlobalScope-importScripts>importScripts</a>([Variadic] in DOMString urls); |
| 2102 |
wakaba |
1.22 |
readonly attribute <span>Storage</span> <a href="#localstorage" title=dom-localStorage>localStorage</a>; |
| 2103 |
|
|
<span>Database</span> <a href="#opendatabase" title=dom-opendatabase>openDatabase</a>(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize); |
| 2104 |
|
|
void <a href="#shownotification" title=dom-showNotification>showNotification</a>(in DOMString title, in DOMString subtitle, in DOMString description); |
| 2105 |
|
|
void <a href="#shownotification" title=dom-showNotification>showNotification</a>(in DOMString title, in DOMString subtitle, in DOMString description, in VoidCallback onclick); |
| 2106 |
wakaba |
1.36 |
};</span></pre> |
| 2107 |
wakaba |
1.16 |
|
| 2108 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="fc1e0d30e2c0869e54fb2487a7dd6836" data-ja-real-hash="43ee0f4f7856a9484e5ed892bc4ab914"><span class=en-original lang=en>Objects that implement the <code><a |
| 2109 |
wakaba |
1.32 |
href="#workerglobalscope">WorkerGlobalScope</a></code> interface must also |
| 2110 |
|
|
implement the <code><a href="#workerutils">WorkerUtils</a></code> |
| 2111 |
|
|
interface. |
| 2112 |
|
|
|
| 2113 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja><code><a href="#workerglobalscope">WorkerGlobalScope</a></code> 界面を実装するオブジェクトは、 <code><a href="#workerutils">WorkerUtils</a></code> 界面も実装しなければ<em class=rfc2119 title="MUST">なりません</em>。</span><p class="big-issue no-ja-translation" data-ja-hash="fffa5f76ab27c1602edf28b5c8fbcc6d"><span class=en-original lang=en>Need to define a sync database API. |
| 2114 |
wakaba |
1.16 |
|
| 2115 |
wakaba |
1.36 |
</span><p class="big-issue no-ja-translation" data-ja-hash="020c6256453de8b69b3b5b421e78d1f0"><span class=en-original lang=en>May need to define a browser sniffing API (like |
| 2116 |
|
|
window.navigator).</span></p> |
| 2117 |
wakaba |
1.16 |
<!-- XXX ApplicationCache --> |
| 2118 |
|
|
<!-- XXX a way to set cookies on the URL for the script --> |
| 2119 |
|
|
<!-- XXX debugging: void log(in DOMString s); // log to console --> |
| 2120 |
|
|
<!-- XXX debugging: onerror --> |
| 2121 |
|
|
|
| 2122 |
|
|
<hr> |
| 2123 |
|
|
|
| 2124 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="59b28734296c1cd390d156b0e8e5fb94"><span class=en-original lang=en>The DOM APIs (<code>Node</code> objects, <code>Document</code> objects, |
| 2125 |
wakaba |
1.32 |
etc) are not available to workers in this version of this specification. |
| 2126 |
|
|
|
| 2127 |
|
|
</span><span class=ja-translation lang=ja>DOM API (<code>Node</code> オブジェクト、 <code>Document</code> |
| 2128 |
wakaba |
1.36 |
オブジェクト、その他) は、この版のこの仕様書では労働者に利用可能ではありません。</span><h3 id=importing class="has-ja-translation" data-ja-hash="e7522d998689dc52be80feeff81470ca"><span class=en-original lang=en><span class=secno>3.1 </span>Importing scripts and |
| 2129 |
|
|
libraries</span><span class=ja-translation lang=ja><span class=secno>3.1 </span>スクリプトとライブラリーの輸入</span></h3> |
| 2130 |
wakaba |
1.22 |
|
| 2131 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="a50ee5d5d404f735326c6d0cb9ede11c"><span class=en-original lang=en>When a script invokes the <dfn id=importscripts |
| 2132 |
wakaba |
1.25 |
title=dom-WorkerGlobalScope-importScripts><code>importScripts(<var |
| 2133 |
|
|
title="">urls</var>)</code></dfn> method on a <code><a |
| 2134 |
wakaba |
1.22 |
href="#workerglobalscope">WorkerGlobalScope</a></code> object, the user |
| 2135 |
|
|
agent must run the following steps: |
| 2136 |
|
|
|
| 2137 |
wakaba |
1.36 |
</span><ol> |
| 2138 |
wakaba |
1.22 |
<li> |
| 2139 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="143a8bb07f4501807d2bbf2d2d2b345a"><span class=en-original lang=en>If there are no arguments, return without doing anything. Abort these |
| 2140 |
wakaba |
1.25 |
steps. |
| 2141 |
|
|
|
| 2142 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>引数がない場合、何も返さずに返ります。 |
| 2143 |
|
|
これらの段階を停止します。</span><li> |
| 2144 |
|
|
<p class="has-ja-translation" data-ja-hash="b89818b453add85fbb5ec1e963e3072c"><span class=en-original lang=en><span title="resolve a url">Resolve</span> each argument. |
| 2145 |
wakaba |
1.22 |
|
| 2146 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>各引数を<span title="resolve a url">解決</span>します。</span><li> |
| 2147 |
|
|
<p class="has-ja-translation" data-ja-hash="54adea3a3a07dd8833ad87eb937142f1"><span class=en-original lang=en>If any fail, throw a <code>SYNTAX_ERR</code> exception. |
| 2148 |
wakaba |
1.22 |
|
| 2149 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>いずれかが失敗した場合、 <code>SYNTAX_ERR</code> 例外を投げます。</span><li> |
| 2150 |
|
|
<p class="has-ja-translation" data-ja-hash="952d7bd44378695378ddf1084a1c5347"><span class=en-original lang=en>If any of the resulting <span title="absolute URL">absolute |
| 2151 |
wakaba |
1.25 |
URLs</span> have an <span>origin</span> that is not the <span |
| 2152 |
|
|
title="same origin">same</span> as the origin of the script that invoked |
| 2153 |
|
|
the method, then throw a <span>security exception</span>. |
| 2154 |
wakaba |
1.22 |
|
| 2155 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>結果として得られた<span title="absolute URL">絶対 |
| 2156 |
|
|
URL</span> |
| 2157 |
|
|
のいずれかが、メソッドを呼び出したスクリプトの<span>origin</span>と<span |
| 2158 |
|
|
title="same origin">同じ</span>ではない起源を持つ場合、 |
| 2159 |
|
|
<span>保安性例外</span>を投げます。</span><li> |
| 2160 |
|
|
<p class="has-ja-translation" data-ja-hash="9a0a1930525c4231da8248d6b7847c8d"><span class=en-original lang=en>Attempt to <span>fetch</span> each resource identified by the |
| 2161 |
|
|
resulting <span title="absolute URLs">absolute URL</span>.</span><span class=ja-translation lang=ja>結果として得られた<span title="absolute URLs">絶対 URL</span> |
| 2162 |
|
|
によって識別される資源をそれぞれ<span>取得</span>しようと試みます。</span></p> |
| 2163 |
wakaba |
1.22 |
|
| 2164 |
|
|
<li> |
| 2165 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="4fc5f1898eb20e4c8da603b91c1ae884"><span class=en-original lang=en>For each argument in turn, in the order given, starting with the first |
| 2166 |
|
|
one, run these substeps:</span><span class=ja-translation lang=ja>各引数について、与えられた順に最初のものから、次の部分段階群を走らせます。</span></p> |
| 2167 |
wakaba |
1.25 |
|
| 2168 |
|
|
<ol> |
| 2169 |
|
|
<li> |
| 2170 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="a5cd8fb5d75985afdc62f7ac228329d4"><span class=en-original lang=en>Wait for the fetching attempt for the corresponding resource to |
| 2171 |
|
|
complete.</span><span class=ja-translation lang=ja>対応する資源を取得しようとする試みが完了するのを待ちます。</span></p> |
| 2172 |
wakaba |
1.25 |
|
| 2173 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="2446641268e7d8ba8d36fcd4b537b0d2"><span class=en-original lang=en>If the fetching attempt failed, throw a <code>NETWORK_ERR</code> |
| 2174 |
wakaba |
1.26 |
exception and abort all these steps. <a |
| 2175 |
|
|
href="#refsXHR">[XHR]</a><!-- XXX get DOM Core updated instead |
| 2176 |
wakaba |
1.36 |
--></span></p> |
| 2177 |
wakaba |
1.25 |
|
| 2178 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="3b806ac3639f6a9110a968f4676bb0a2"><span class=en-original lang=en>If the fetching attempt succeeded, then let <var |
| 2179 |
|
|
title="">script</var> be the resource that was obtained.</span><span class=ja-translation lang=ja>取得の試みが成功した場合、 <var |
| 2180 |
|
|
title="">script</var> を、得られた資源とします。</span></p> |
| 2181 |
|
|
|
| 2182 |
|
|
<p class="note has-ja-translation" data-ja-hash="9d495d7b0fa2439cfa3470c4af977171"><span class=en-original lang=en>As with the worker's script, the script here is always |
| 2183 |
|
|
assumed to be JavaScript, regardless of the MIME type.</span><span class=ja-translation lang=ja>労働者のスクリプトと同じく、ここでのスクリプトも、 MIME 型に関わらず常に |
| 2184 |
|
|
JavaScript であるとみなします。</span></p> |
| 2185 |
wakaba |
1.25 |
<!-- XXX --> |
| 2186 |
|
|
|
| 2187 |
|
|
<li> |
| 2188 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="d806bc2f0c51e55fe69ffd7270a7713c"><span class=en-original lang=en>Let <var title="">script</var>'s <span>script execution |
| 2189 |
wakaba |
1.31 |
context</span>, <span>script browsing context</span>, and <span>script |
| 2190 |
|
|
document context</span> be the same as for the script that was |
| 2191 |
|
|
executed by the <a href="#run-a">run a worker</a> processing model for |
| 2192 |
wakaba |
1.36 |
this worker.</span></p> |
| 2193 |
wakaba |
1.22 |
|
| 2194 |
wakaba |
1.25 |
<li> |
| 2195 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="596313e12fbf748ad5e6824e08d0fb89"><span class=en-original lang=en>Run <var title="">script</var> until it either returns, fails to |
| 2196 |
wakaba |
1.25 |
catch an exception, or gets prematurely aborted by the "<a |
| 2197 |
wakaba |
1.30 |
href="#kill-a">kill a worker</a>" or "<a href="#terminate">terminate a |
| 2198 |
wakaba |
1.36 |
worker</a>" algorithms defined above.</span></p> |
| 2199 |
wakaba |
1.25 |
|
| 2200 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="c7d543d741a3d731cce1fac38ebfcb64"><span class=en-original lang=en>If an exception was raised or if the script was prematurely aborted, |
| 2201 |
wakaba |
1.25 |
then abort all these steps, letting the exception or aborting continue |
| 2202 |
|
|
to be processed by the script that called the <code |
| 2203 |
|
|
title=dom-WorkerGlobalScope-importScripts><a |
| 2204 |
wakaba |
1.36 |
href="#importscripts">importScripts()</a></code> method.</span></p> |
| 2205 |
wakaba |
1.22 |
|
| 2206 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="a2d222b3ee337b79266e81f663801084"><span class=en-original lang=en>If the "<a href="#kill-a">kill a worker</a>" or "<a |
| 2207 |
wakaba |
1.30 |
href="#terminate">terminate a worker</a>" algoriths abort the script |
| 2208 |
wakaba |
1.36 |
then abort all these steps.</span></p> |
| 2209 |
wakaba |
1.25 |
</ol> |
| 2210 |
wakaba |
1.22 |
</ol> |
| 2211 |
|
|
|
| 2212 |
wakaba |
1.36 |
<h3 id=apis-defined class="has-ja-translation" data-ja-hash="d6d6885373ce92bfa8857f5a375a9c8f"><span class=en-original lang=en><span class=secno>3.2 </span>APIs defined in other |
| 2213 |
|
|
specifications</span><span class=ja-translation lang=ja><span class=secno>3.2 </span>他の仕様書で定義されている API</span></h3> |
| 2214 |
wakaba |
1.22 |
|
| 2215 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="3c9a0dcc3dbfc7283eea34202de4d321"><span class=en-original lang=en>The <dfn id=localstorage |
| 2216 |
wakaba |
1.22 |
title=dom-localStorage><code>localStorage</code></dfn>, <dfn |
| 2217 |
|
|
id=opendatabase title=dom-opendatabase><code>openDatabase()</code></dfn> |
| 2218 |
|
|
must act as defined for the APIs with the same names on the |
| 2219 |
|
|
<code>Window</code> object in the HTML5 specification, with the exception |
| 2220 |
|
|
that where the API would use the <span>origin</span> of the <span>active |
| 2221 |
|
|
document</span> of the <span>browsing context</span> of the |
| 2222 |
|
|
<code>Window</code> object on which the method was supposedly invoked, it |
| 2223 |
|
|
must instead use the <span>origin</span> of the script that invoked the |
| 2224 |
|
|
method. <a href="#refsHTML5">[HTML5]</a> |
| 2225 |
|
|
|
| 2226 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="6563db877bfe3b57772fed7dedbfc84b"><span class=en-original lang=en>The <dfn id=shownotification |
| 2227 |
wakaba |
1.22 |
title=dom-showNotification><code>showNotification()</code></dfn> methods |
| 2228 |
|
|
must act as defined for the APIs with the same names on the |
| 2229 |
|
|
<code>Window</code> object in the HTML5 specification. <a |
| 2230 |
|
|
href="#refsHTML5">[HTML5]</a> |
| 2231 |
|
|
|
| 2232 |
wakaba |
1.36 |
</span><h3 id=interface class="has-ja-translation" data-ja-hash="78e75b89c304218ef77a66cd9efdf398"><span class=en-original lang=en><span class=secno>3.3 </span>Interface objects and |
| 2233 |
|
|
constructors</span><span class=ja-translation lang=ja><span class=secno>3.3 </span>界面オブジェクトと構築器</span></h3> |
| 2234 |
wakaba |
1.22 |
|
| 2235 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="2135421a70c368c728d0af40f99cee55"><span class=en-original lang=en>There must be no interface objects and constructors available in the |
| 2236 |
wakaba |
1.22 |
global scope of scripts whose <span>script execution context</span> is a |
| 2237 |
|
|
<code><a href="#workerglobalscope">WorkerGlobalScope</a></code> object |
| 2238 |
|
|
except for the following: |
| 2239 |
|
|
|
| 2240 |
wakaba |
1.36 |
</span><ul> |
| 2241 |
wakaba |
1.22 |
<li> |
| 2242 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="ee396bbb3d32ae2d31fc0a108ea3389c"><span class=en-original lang=en><code>XMLHttpRequest</code> and all interface objects and constructors |
| 2243 |
wakaba |
1.31 |
defined by the XMLHttpRequest specifications, except that the |
| 2244 |
|
|
<span>document response entity body</span> must always be null. <a |
| 2245 |
|
|
href="#refsXHR">[XHR]</a> |
| 2246 |
|
|
|
| 2247 |
wakaba |
1.36 |
</span><li> |
| 2248 |
|
|
<p class="has-ja-translation" data-ja-hash="3a205f7812c3029dcecfcbbd61199f90"><span class=en-original lang=en>The <code>WebSocket</code> interface object and constructor. |
| 2249 |
wakaba |
1.23 |
|
| 2250 |
wakaba |
1.32 |
</span><span class=ja-translation lang=ja><code>WebSocket</code> 界面オブジェクトと構築器</span><li> |
| 2251 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="c537145c77e1103c3a76557f40172a5a"><span class=en-original lang=en>The <code>MessageChannel</code> interface object and constructor. |
| 2252 |
wakaba |
1.32 |
</span><span class=ja-translation lang=ja><code>MessageChannel</code> 界面オブジェクトと構築器</span></ul> |
| 2253 |
|
|
|
| 2254 |
wakaba |
1.36 |
<h3 id=worker0 class="has-ja-translation" data-ja-hash="ae4aa0f882fcbd2ee8252e59113ec205"><span class=en-original lang=en><span class=secno>3.4 </span>Worker locations</span><span class=ja-translation lang=ja><span class=secno>3.4 </span>労働者の所在</span></h3> |
| 2255 |
wakaba |
1.23 |
|
| 2256 |
|
|
<pre |
| 2257 |
wakaba |
1.36 |
class="idl no-ja-translation" data-ja-hash="cf592219c4e6cd8a917cbb3071aebfd5"><span class=en-original lang=en>[NoInterfaceObject] interface <dfn id=workerlocation>WorkerLocation</dfn> { |
| 2258 |
wakaba |
1.23 |
readonly attribute DOMString <a href="#href" title=dom-WorkerLocation-href>href</a>; |
| 2259 |
|
|
readonly attribute DOMString <a href="#protocol" title=dom-WorkerLocation-protocol>protocol</a>; |
| 2260 |
|
|
readonly attribute DOMString <a href="#host" title=dom-WorkerLocation-host>host</a>; |
| 2261 |
|
|
readonly attribute DOMString <a href="#hostname" title=dom-WorkerLocation-hostname>hostname</a>; |
| 2262 |
wakaba |
1.29 |
readonly attribute DOMString <a href="#port0" title=dom-WorkerLocation-port>port</a>; |
| 2263 |
wakaba |
1.23 |
readonly attribute DOMString <a href="#pathname" title=dom-WorkerLocation-pathname>pathname</a>; |
| 2264 |
|
|
readonly attribute DOMString <a href="#search" title=dom-WorkerLocation-search>search</a>; |
| 2265 |
|
|
readonly attribute DOMString <a href="#hash" title=dom-WorkerLocation-hash>hash</a>; |
| 2266 |
wakaba |
1.36 |
};</span></pre> |
| 2267 |
wakaba |
1.23 |
|
| 2268 |
wakaba |
1.36 |
<p class="no-ja-translation" data-ja-hash="36debbc2eb6f1156c1bae8ade6331936"><span class=en-original lang=en>A <code><a href="#workerlocation">WorkerLocation</a></code> object |
| 2269 |
wakaba |
1.23 |
represents an <span>absolute URL</span> set at its creation. |
| 2270 |
|
|
|
| 2271 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="2d034b308d5fd16e5cf88da132b7ecb7"><span class=en-original lang=en>The <dfn id=href title=dom-WorkerLocation-href><code>href</code></dfn> |
| 2272 |
wakaba |
1.23 |
attribute must return the <span>absolute URL</span> that the object |
| 2273 |
|
|
represents. |
| 2274 |
|
|
|
| 2275 |
wakaba |
1.36 |
</span><p class="no-ja-translation" data-ja-hash="f2d3c1ea8523c84f8de83e432d4ecb8e"><span class=en-original lang=en>The <code><a href="#workerlocation">WorkerLocation</a></code> interface |
| 2276 |
wakaba |
1.23 |
also has the complement of <span>URL decomposition attributes</span>, <dfn |
| 2277 |
|
|
id=protocol title=dom-WorkerLocation-protocol><code>protocol</code></dfn>, |
| 2278 |
|
|
<dfn id=host title=dom-WorkerLocation-host><code>host</code></dfn>, <dfn |
| 2279 |
wakaba |
1.29 |
id=port0 title=dom-WorkerLocation-port><code>port</code></dfn>, <dfn |
| 2280 |
wakaba |
1.23 |
id=hostname title=dom-WorkerLocation-hostname><code>hostname</code></dfn>, |
| 2281 |
|
|
<dfn id=pathname |
| 2282 |
|
|
title=dom-WorkerLocation-pathname><code>pathname</code></dfn>, <dfn |
| 2283 |
|
|
id=search title=dom-WorkerLocation-search><code>search</code></dfn>, and |
| 2284 |
|
|
<dfn id=hash title=dom-WorkerLocation-hash><code>hash</code></dfn>. These |
| 2285 |
|
|
must follow the rules given for URL decomposition attributes, with the |
| 2286 |
|
|
<span title=concept-uda-input>input</span> being the <span>absolute |
| 2287 |
|
|
URL</span> that the object represents (same as the <code |
| 2288 |
|
|
title=dom-WorkerLocation-href><a href="#href">href</a></code> attribute), |
| 2289 |
|
|
and the <span title=concept-uda-setter>common setter action</span> being a |
| 2290 |
|
|
no-op, since the attributes are defined to be readonly. <a |
| 2291 |
|
|
href="#refsHTML5">[HTML5]</a> |
| 2292 |
wakaba |
1.22 |
|
| 2293 |
wakaba |
1.36 |
</span><h2 class="no-num has-ja-translation" data-ja-hash="d95867deadfe690e40f42068d6b59df8" id=references><span class=en-original lang=en>References</span><span class=ja-translation lang=ja>参考文献</span></h2> |
| 2294 |
wakaba |
1.32 |
|
| 2295 |
wakaba |
1.36 |
<p class="big-issue has-ja-translation" data-ja-hash="456d04331290bc0f50928aee5f719e46"><span class=en-original lang=en>This section will be written in a future |
| 2296 |
wakaba |
1.32 |
draft.<!--XXX--> |
| 2297 |
wakaba |
1.1 |
|
| 2298 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>この章は将来の仕様案で執筆します。</span><h2 class="no-num has-ja-translation" data-ja-hash="0407c27180c9b019e644e8ad4c6a9324" id=acknowledgements><span class=en-original lang=en>Acknowledgements</span><span class=ja-translation lang=ja>謝辞</span></h2> |
| 2299 |
wakaba |
1.1 |
<!-- ACKS --> |
| 2300 |
|
|
|
| 2301 |
wakaba |
1.36 |
<p class="has-ja-translation" data-ja-hash="a17a0feb6f58a31040d51121e80bc233" data-ja-real-hash="bff2983b00cd4af08698b22bd1fe8ac7"><span class=en-original lang=en>Thanks to Aaron Boodman, Jonas Sicking, Justin James, Maciej Stachowiak, |
| 2302 |
wakaba |
1.32 |
Mike Smith, and Philip Taylor for their useful and substantial comments. |
| 2303 |
|
|
|
| 2304 |
wakaba |
1.36 |
</span><span class=ja-translation lang=ja>Aaron Boodman, Jonas Sicking, Justin James, Maciej Stachowiak, Mike Smith, Philip Taylor の有用かつ重要なコメントに感謝します。</span><p class="has-ja-translation" data-ja-hash="7c6875278ecf56df193c33c553856fac"><span class=en-original lang=en>Huge thanks to the whole Gears team, who pioneered this technology and |
| 2305 |
wakaba |
1.32 |
whose experience has been a huge influence on this specification. |
| 2306 |
|
|
</span><span class=ja-translation lang=ja>Gears チームの方々にも非常に感謝します。 |
| 2307 |
wakaba |
1.14 |
Gears チームの方々はこの技術を開拓し、その経験はこの仕様書にも多大な影響を与えています。 |
| 2308 |
|
|
</span> |