1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
---
title: WindowOrWorkerGlobalScope
slug: Web/API/WindowOrWorkerGlobalScope
tags:
- API
- HTML DOM
- NeedsTranslation
- Service Worker
- TopicStub
- Window
- WindowOrWorkerGlobalScope
- Worker
- WorkerGlobalScope
translation_of: Web/API/WindowOrWorkerGlobalScope
---
<div>{{ApiRef()}}</div>
<p><span class="seoSummary">The <strong><code>WindowOrWorkerGlobalScope</code></strong> mixin describes several features common to the {{domxref("Window")}} and {{domxref("WorkerGlobalScope")}} interfaces.</span> Each of these interfaces can, of course, add more features in addition to the ones listed below.</p>
<div class="note">
<p><strong>Note</strong>: <code>WindowOrWorkerGlobalScope</code> is a mixin and not an interface; you can't actually create an object of type <code>WindowOrWorkerGlobalScope</code>.</p>
</div>
<h2 id="Properties_2">Properties</h2>
<p>These properties are defined on the {{domxref("WindowOrWorkerGlobalScope")}} mixin, and implemented by {{domxref("Window")}} and {{domxref("WorkerGlobalScope")}}.</p>
<div id="Properties">
<dl>
<dt>{{domxref("WindowOrWorkerGlobalScope.caches")}} {{readOnlyinline}}</dt>
<dd>Returns the {{domxref("CacheStorage")}} object associated with the current context. This object enables functionality such as storing assets for offline use, and generating custom responses to requests.</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.crossOriginIsolated")}} {{readOnlyinline}}</dt>
<dd>Returns a boolean value that indicates whether a {{jsxref("SharedArrayBuffer")}} can be sent via a {{domxref("Window.postMessage()")}} call.</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.indexedDB")}} {{readonlyInline}}</dt>
<dd>Provides a mechanism for applications to asynchronously access capabilities of indexed databases; returns an {{domxref("IDBFactory")}} object.</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.isSecureContext")}} {{readOnlyinline}}</dt>
<dd>Returns a boolean indicating whether the current context is secure (<code>true</code>) or not (<code>false</code>).</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.origin")}} {{readOnlyinline}}</dt>
<dd>Returns the origin of the global scope, serialized as a string.</dd>
</dl>
</div>
<h2 id="Methods">Methods</h2>
<p>These methods are defined on the {{domxref("WindowOrWorkerGlobalScope")}} mixin, and implemented by {{domxref("Window")}} and {{domxref("WorkerGlobalScope")}}.</p>
<dl>
<dt>{{domxref("WindowOrWorkerGlobalScope.atob()")}}</dt>
<dd>Decodes a string of data which has been encoded using base-64 encoding.</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.btoa()")}}</dt>
<dd>Creates a base-64 encoded ASCII string from a string of binary data.</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.clearInterval()")}}</dt>
<dd>Cancels the repeated execution set using {{domxref("WindowOrWorkerGlobalScope.setInterval()")}}.</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.clearTimeout()")}}</dt>
<dd>Cancels the delayed execution set using {{domxref("WindowOrWorkerGlobalScope.setTimeout()")}}.</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.createImageBitmap()")}}</dt>
<dd>Accepts a variety of different image sources, and returns a {{domxref("Promise")}} which resolves to an {{domxref("ImageBitmap")}}. Optionally the source is cropped to the rectangle of pixels originating at <em>(</em><code>sx</code>, <code>sy</code><em>)</em> with width <code>sw</code>, and height <code>sh</code>.</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.fetch()")}}</dt>
<dd>Starts the process of fetching a resource from the network.</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.queueMicrotask()")}}</dt>
<dd>Enqueues a microtask—a short function to be executed after execution of the JavaScript code completes and control isn't being returned to a JavaScript caller, but before handling callbacks and other tasks. This lets your code run without interfering with other, possibly higher priority, code, but <em>before</em> the browser runtime regains control, potentially depending upon the work you need to complete.</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.setInterval()")}}</dt>
<dd>Schedules a function to execute every time a given number of milliseconds elapses.</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.setTimeout()")}}</dt>
<dd>Schedules a function to execute in a given amount of time.</dd>
</dl>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName("HTML WHATWG",'webappapis.html#windoworworkerglobalscope-mixin', '<code>WindowOrWorkerGlobalScope</code> mixin')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td>This is where the main mixin is defined.</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("api.WindowOrWorkerGlobalScope")}}</p>
<h2 id="See_also">See also</h2>
<ul>
<li>{{domxref("Window")}}</li>
<li>{{domxref("WorkerGlobalScope")}}</li>
</ul>
|