Worker.hx 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (C)2005-2013 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. // This file is generated, do not edit!
  23. package js.html;
  24. /** <p>Workers are background tasks that can be easily created and can send messages back to their creators. Creating a worker is as simple as calling the <code>Worker()</code>&nbsp;constructor, specifying a script to be run in the worker thread.</p>
  25. <p>Of note is the fact that workers may in turn spawn new workers as long as those workers are hosted within the same origin as the parent page.&nbsp; In addition, workers may use <a title="En/XMLHttpRequest" class="internal" rel="internal" href="https://developer.mozilla.org/en/DOM/XMLHttpRequest"><code>XMLHttpRequest</code></a> for network I/O, with the exception that the <code>responseXML</code> and <code>channel</code> attributes on <code>XMLHttpRequest</code> always return <code>null</code>.</p>
  26. <p>For a list of global functions available to workers, see <a title="En/DOM/Worker/Functions available to workers" rel="internal" href="https://developer.mozilla.org/En/DOM/Worker/Functions_available_to_workers">Functions available to workers</a>.</p>
  27. <div class="geckoVersionNote">
  28. <p>
  29. </p><div class="geckoVersionHeading">Gecko 2.0 note<div>(Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)
  30. </div></div>
  31. <p></p>
  32. <p>If you want to use workers in extensions, and would like to have access to <a title="en/js-ctypes" rel="internal" href="https://developer.mozilla.org/en/js-ctypes">js-ctypes</a>, you should use the <code><a rel="custom" href="https://developer.mozilla.org/en/DOM/ChromeWorker">ChromeWorker</a></code>
  33. object instead.</p>
  34. </div>
  35. <p>See <a class="internal" title="en/Using DOM workers" rel="internal" href="/api/js/html/WorkerContext">Using web workers</a> for examples and details.</p><br><br>
  36. Documentation for this class was provided by <a href="https://developer.mozilla.org/En/DOM/Worker">MDN</a>. */
  37. @:native("Worker")
  38. extern class Worker extends AbstractWorker
  39. {
  40. /** An event listener that is called whenever a <code>MessageEvent</code> with type <code>message</code> bubbles through the worker. The message is stored in the event's <code>data</code> member. */
  41. var onmessage : EventListener;
  42. /** <p>The constructor creates a web worker that executes the script at the specified URL. This script must obey the <a title="Same origin policy for JavaScript" rel="internal" href="https://developer.mozilla.org/en/Same_origin_policy_for_JavaScript">same-origin policy</a>. Note that there is a disagreement among browser manufacturers about whether a data URI is of the same origin or not. Though Gecko 10.0 (Firefox 10.0 / Thunderbird 10.0)
  43. and later accept data URIs, that's not the case in all other browsers.</p>
  44. <pre>Worker(
  45. &nbsp;&nbsp;in DOMString aStringURL
  46. );
  47. </pre>
  48. <div id="section_6"><span id="Parameters"></span><h5 class="editable">Parameters</h5>
  49. <dl> <dt><code>aStringURL</code></dt> <dd>The URL of the script the worker is to execute. It must obey the same-origin policy (or be a data URI for Gecko 10.0 or later).</dd>
  50. </dl>
  51. <div id="section_7"><span id="Return_value"></span><h6 class="editable">Return value</h6>
  52. <p>A new <code>Worker</code>.</p>
  53. </div></div> */
  54. function new( scriptUrl : String ) : Void;
  55. function postMessage( message : Dynamic, ?messagePorts : Array<Dynamic> ) : Void;
  56. function terminate() : Void;
  57. }