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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
---
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>O <a href="https://medium.com/javascript-scene/functional-mixins-composing-software-ffb66d5e731c">mixin</a> WindowOrWorkerGlobalScope descreve vários recursos comuns às interfaces Window e WorkerGlobalScope. Cada uma dessas interfaces pode, obviamente, adicionar mais recursos além dos listados abaixo.</p>
<div class="note">
<p><strong>Nota</strong>: <code>WindowOrWorkerGlobalScope</code> é um mixin e não uma interface; você não pode atualmente criar um objeto do tipo <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', 'webappapis.html#dom-origin', '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>{{CompatibilityTable}}</p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th>Feature</th>
<th>Firefox (Gecko)</th>
<th>Chrome</th>
<th>Edge</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{CompatGeckoDesktop(52)}}</td>
<td>54</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
</tr>
<tr>
<td><code>origin</code></td>
<td>{{CompatGeckoDesktop(54)}}</td>
<td>59</td>
<td>{{CompatUnknown}}</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 Webview</th>
<th>Edge</th>
<th>Firefox Mobile (Gecko)</th>
<th>Android</th>
<th>IE Mobile</th>
<th>Opera Mobile</th>
<th>Safari Mobile</th>
<th>Chrome for Android</th>
</tr>
<tr>
<td>Basic support</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatGeckoMobile(52)}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>54</td>
</tr>
<tr>
<td><code>origin</code></td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatGeckoMobile(54)}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>{{CompatUnknown}}</td>
<td>59</td>
</tr>
</tbody>
</table>
</div>
<p> </p>
<h2 id="See_also">See also</h2>
<ul>
<li>{{domxref("Window")}}</li>
<li>{{domxref("WorkerGlobalScope")}}</li>
</ul>
|