Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 732035 of DedicatedWorkerGlobalScope

  • Revision slug: Web/API/DedicatedWorkerGlobalScope
  • Revision title: DedicatedWorkerGlobalScope
  • Revision id: 732035
  • Created:
  • Creator: chrisdavidmills
  • Is current revision? No
  • Comment

Revision Content

{{APIRef}}

The DedicatedWorkerGlobalScope object (the {{domxref("Worker")}} global scope) is accessible through the {{domxref("window.self","self")}} keyword. Some additional global functions, namespaces objects, and constructors, not typically associated with the worker global scope, but available on it, are listed in the JavaScript Reference. See also: Functions available to workers.

Properties

This interface inherits properties from the {{domxref("WorkerGlobalScope")}} interface, and its parent {{domxref("EventTarget")}}, and therefore implements properties from {{domxref("WindowTimers")}}, {{domxref("WindowBase64")}}, and {{domxref("WindowEventHandlers")}}.

Properties inherited from WorkerGlobalScope

{{domxref("WorkerGlobalScope.self")}}
Returns an object reference to the DedicatedWorkerGlobalScope object itself.
{{domxref("WorkerGlobalScope.console")}} {{readOnlyinline}}
Returns the {{domxref("Console")}} associated with the worker.
{{domxref("WorkerGlobalScope.location")}} {{readOnlyinline}}
Returns the {{domxref("WorkerLocation")}} associated with the worker. WorkerLocation is a specific location object, mostly a subset of the {{domxref("Location")}} for browsing scopes, but adapted to workers.
{{domxref("WorkerGlobalScope.navigator")}} {{readOnlyinline}}
Returns the {{domxref("WorkerNavigator")}} associated with the worker. WorkerNavigator is a specific navigator object, mostly a subset of the {{domxref("Navigator")}} for browsing scopes, but adapted to workers.
{{domxref("WorkerGlobalScope.performance")}} {{readOnlyinline}} {{Non-standard_inline}}
Returns the {{domxref("Performance")}} object associated with the worker, which is a regular performance object, but with a subset of its properties and methods available.

Event handlers

This interface inherits event handlers from the {{domxref("WorkerGlobalScope")}} interface, and its parent {{domxref("EventTarget")}}, and therefore implements event handlers from {{domxref("WindowTimers")}}, {{domxref("WindowBase64")}}, and {{domxref("WindowEventHandlers")}}.

{{domxref("DedicatedWorkerGlobalScope.onmessage")}}
Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("message")}} event is raised. These events are of type {{domxref("MessageEvent")}} and will be called when the worker's parent receives a message (i.e. from the {{domxref("Worker.postMessage", "postMessage()")}} method.

Methods

This interface inherits methods from the {{domxref("WorkerGlobalScope")}} interface, and its parent {{domxref("EventTarget")}}, and therefore implements methods from {{domxref("WindowTimers")}}, {{domxref("WindowBase64")}}, and {{domxref("WindowEventHandlers")}}.

Inherited from WorkerGlobalScope

{{domxref("WorkerGlobalScope.close()")}}
Discards any tasks queued in the WorkerGlobalScope's event loop, effectively closing this particular scope.
{{domxref("WorkerGlobalScope.dump()")}} {{non-standard_inline}}
Writes a message to the console.
{{domxref("WorkerGlobalScope.importScripts()")}}
Imports one or more scripts into the worker's scope. You can specify as many as you'd like, separated by commas. For example: importScripts('foo.js', 'bar.js');

Implemented from other places

{{domxref("WindowBase64.atob()")}}
Decodes a string of data which has been encoded using base-64 encoding.
{{domxref("WindowBase64.btoa()")}}
Creates a base-64 encoded ASCII string from a string of binary data.
{{domxref("WindowTimers.clearInterval()")}}
Cancels the repeated execution set using {{domxref("WindowTimers.setInterval()")}}.
{{domxref("WindowTimers.clearTimeout()")}}
Cancels the repeated execution set using {{domxref("WindowTimers.setTimeout()")}}.
{{domxref("WindowTimers.setInterval()")}}
Schedules the execution of a function every X milliseconds.
{{domxref("WindowTimers.setTimeout()")}}
Sets a delay for executing a function.

Specifications

Specification Status Comment
{{SpecName('HTML WHATWG', '#dedicatedworkerglobalscope', 'DedicatedWorkerGlobalScope')}} {{Spec2('HTML WHATWG')}} No change from {{SpecName("Web Workers")}}.
{{SpecName('Web Workers', '#dedicatedworkerglobalscope', 'DedicatedWorkerGlobalScope')}} {{Spec2('Web Workers')}} Initial definition.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatUnknown}} {{CompatGeckoDesktop("1.9.1")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
ononline, onoffline {{CompatUnknown}} {{CompatGeckoDesktop("29")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
console {{Non-standard_inline}} {{CompatUnknown}} {{CompatGeckoDesktop("29")}} as  WorkerConsole
{{CompatGeckoDesktop("30")}} as the regular Console
{{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
performance {{CompatUnknown}} {{CompatGeckoDesktop("34")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatUnknown}} {{CompatUnknown}} {{CompatGeckoMobile("1.9.1")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
ononline, onoffline {{CompatUnknown}} {{CompatUnknown}} {{CompatGeckoMobile("29")}} as a specific WorkerConsole
{{CompatGeckoMobile("30")}} as the regular Console
{{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
console {{Non-standard_inline}} {{CompatUnknown}} {{CompatUnknown}} {{CompatGeckoMobile("29")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
performance {{CompatUnknown}} {{CompatUnknown}} {{CompatGeckoMobile("34")}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}

See also

Revision Source

<p>{{APIRef}}</p>

<p>The <strong><code>DedicatedWorkerGlobalScope</code></strong> object (the {{domxref("Worker")}} global scope) is accessible through the {{domxref("window.self","self")}} keyword. Some additional global functions, namespaces objects, and constructors, not typically associated with the worker global scope, but available on it, are listed in the <a href="/en-US/docs/Web/JavaScript/Reference">JavaScript Reference</a>. See also: <a href="/en-US/docs/Web/Guide/Needs_categorization/Functions_available_to_workers">Functions available to workers</a>.</p>

<h2 id="Properties">Properties</h2>

<p><em>This interface inherits properties from the {{domxref("WorkerGlobalScope")}} interface, and its parent {{domxref("EventTarget")}}, and therefore implements properties from {{domxref("WindowTimers")}}, {{domxref("WindowBase64")}}, and {{domxref("WindowEventHandlers")}}.</em></p>

<h3 id="Properties_inherited_from_WorkerGlobalScope">Properties inherited from WorkerGlobalScope</h3>

<dl>
 <dt>{{domxref("WorkerGlobalScope.self")}}</dt>
 <dd>Returns an object reference to the <code>DedicatedWorkerGlobalScope</code> object itself.</dd>
 <dt>{{domxref("WorkerGlobalScope.console")}} {{readOnlyinline}}</dt>
 <dd>Returns the {{domxref("Console")}} associated with the worker.</dd>
 <dt>{{domxref("WorkerGlobalScope.location")}} {{readOnlyinline}}</dt>
 <dd>Returns the {{domxref("WorkerLocation")}} associated with the worker. <code>WorkerLocation</code> is a specific location object, mostly a subset of the {{domxref("Location")}} for browsing scopes, but adapted to workers.</dd>
 <dt>{{domxref("WorkerGlobalScope.navigator")}} {{readOnlyinline}}</dt>
 <dd>Returns the {{domxref("WorkerNavigator")}} associated with the worker. <code>WorkerNavigator</code> is a specific navigator object, mostly a subset of the {{domxref("Navigator")}} for browsing scopes, but adapted to workers.</dd>
 <dt>{{domxref("WorkerGlobalScope.performance")}} {{readOnlyinline}} {{Non-standard_inline}}</dt>
 <dd>Returns the {{domxref("Performance")}} object associated with the worker, which is a regular performance object, but with a subset of its properties and methods available.</dd>
</dl>

<h3 id="Event_handlers">Event handlers</h3>

<p><em>This interface inherits event handlers from the {{domxref("WorkerGlobalScope")}} interface, and its parent {{domxref("EventTarget")}}, and therefore implements event handlers from {{domxref("WindowTimers")}}, {{domxref("WindowBase64")}}, and {{domxref("WindowEventHandlers")}}.</em></p>

<dl>
 <dt>{{domxref("DedicatedWorkerGlobalScope.onmessage")}}</dt>
 <dd>Is an {{domxref("EventHandler")}} representing the code to be called when the {{event("message")}} event is raised. These events are of type {{domxref("MessageEvent")}} and will be called when the worker's parent receives a message (i.e. from the {{domxref("Worker.postMessage", "postMessage()")}} method.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<p><em>This interface inherits methods from the {{domxref("WorkerGlobalScope")}} interface, and its parent {{domxref("EventTarget")}}, and therefore implements methods from {{domxref("WindowTimers")}}, {{domxref("WindowBase64")}}, and {{domxref("WindowEventHandlers")}}.</em></p>

<h3 id="Inherited_from_WorkerGlobalScope">Inherited from WorkerGlobalScope</h3>

<dl>
 <dt>{{domxref("WorkerGlobalScope.close()")}}</dt>
 <dd>Discards any tasks queued in the <code>WorkerGlobalScope</code>'s event loop, effectively closing this particular scope.</dd>
 <dt>{{domxref("WorkerGlobalScope.dump()")}} {{non-standard_inline}}</dt>
 <dd>Writes a message to the console.</dd>
 <dt>{{domxref("WorkerGlobalScope.importScripts()")}}</dt>
 <dd>Imports one or more scripts into the worker's scope. You can specify as many as you'd like, separated by commas. For example:<code> importScripts('foo.js', 'bar.js');</code></dd>
</dl>

<h3 id="Implemented_from_other_places">Implemented from other places</h3>

<dl><!-- base64 func <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=287112" rel="freelink">https://bugzilla.mozilla.org/show_bug.cgi?id=287112</a> (see last comments) <a class="link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=123003" rel="freelink">https://bugzilla.mozilla.org/show_bug.cgi?id=123003</a> <a href="https://lxr.mozilla.org/seamonkey/source/dom/src/base/nsGlobalWindow.cpp#4946" rel="freelink">https://lxr.mozilla.org/seamonkey/sou...indow.cpp#4946</a> -->
 <dt>{{domxref("WindowBase64.atob()")}}</dt>
 <dd>Decodes a string of data which has been encoded using base-64 encoding.</dd>
 <dt>{{domxref("WindowBase64.btoa()")}}</dt>
 <dd>Creates a base-64 encoded ASCII string from a string of binary data.</dd>
 <dt>{{domxref("WindowTimers.clearInterval()")}}</dt>
 <dd>Cancels the repeated execution set using {{domxref("WindowTimers.setInterval()")}}.</dd>
 <dt>{{domxref("WindowTimers.clearTimeout()")}}</dt>
 <dd>Cancels the repeated execution set using {{domxref("WindowTimers.setTimeout()")}}.</dd>
 <dt>{{domxref("WindowTimers.setInterval()")}}</dt>
 <dd>Schedules the execution of a function every X milliseconds.</dd>
 <dt>{{domxref("WindowTimers.setTimeout()")}}</dt>
 <dd>Sets a delay for executing a function.</dd>
</dl>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG', '#dedicatedworkerglobalscope', 'DedicatedWorkerGlobalScope')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>No change from {{SpecName("Web Workers")}}.</td>
  </tr>
  <tr>
   <td>{{SpecName('Web Workers', '#dedicatedworkerglobalscope', 'DedicatedWorkerGlobalScope')}}</td>
   <td>{{Spec2('Web Workers')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{ CompatibilityTable() }}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("1.9.1")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>ononline</code>, <code>onoffline</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("29")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>console</code> {{Non-standard_inline}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("29")}} as&nbsp; <code>WorkerConsole</code><br />
    {{CompatGeckoDesktop("30")}} as the regular <code>Console</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>performance</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoDesktop("34")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Chrome for Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("1.9.1")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>ononline</code>, <code>onoffline</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("29")}} as a specific <code>WorkerConsole</code><br />
    {{CompatGeckoMobile("30")}} as the regular <code>Console</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>console</code> {{Non-standard_inline}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("29")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>performance</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("34")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{domxref("Worker")}}</li>
 <li>{{domxref("WorkerGlobalScope")}}</li>
 <li><a href="/en-US/docs/Web/Guide/Performance/Using_web_workers">Using web workers</a></li>
 <li><a href="/en-US/docs/Web/Guide/Needs_categorization/Functions_available_to_workers">Functions available to workers</a></li>
</ul>
Revert to this revision