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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
---
title: WindowOrWorkerGlobalScope
slug: Web/API/WindowOrWorkerGlobalScope
tags:
- API
- DOM
- DOM API
- NeedsTranslation
- Service Worker
- TopicStub
- Window
- WindowOrWorkerGlobalScope
- Worker
- WorkerGlobalScope
translation_of: Web/API/WindowOrWorkerGlobalScope
---
<div>{{ApiRef()}}</div>
<p>The <strong><code>WindowOrWorkerGlobalScope</code></strong> mixin describes several features common to the {{domxref("Window")}} and {{domxref("WorkerGlobalScope")}} interfaces. 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.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 properties 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>(sx, sy)</em> with width sw, and height sh.</dd>
<dt>{{domxref("WindowOrWorkerGlobalScope.fetch()")}}</dt>
<dd>Starts the process of fetching a resource from the network.</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>
<tr>
<td>{{SpecName('Fetch','#fetch-method','fetch()')}}</td>
<td>{{Spec2('Fetch')}}</td>
<td>Definition of the <code>fetch()</code> method.</td>
</tr>
<tr>
<td>{{SpecName('Service Workers', '#self-caches', 'caches')}}</td>
<td>{{Spec2('Service Workers')}}</td>
<td>Definition of the <code>caches</code> property.</td>
</tr>
<tr>
<td>{{SpecName('IndexedDB 2', '#dom-windoworworkerglobalscope-indexeddb', 'indexedDB')}}</td>
<td>{{Spec2('IndexedDB 2')}}</td>
<td>Definition of the <code>indexedDB</code> property.</td>
</tr>
<tr>
<td>{{SpecName('Secure Contexts', '#dom-windoworworkerglobalscope-issecurecontext', 'isSecureContext')}}</td>
<td>{{Spec2('Secure Contexts')}}</td>
<td>Definition of the <code>isSecureContext</code> property.</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>
|