Skip to content

Commit dd695c5

Browse files
committed
Add atob, btoa, structuredClone to shadow realms
1 parent 842a625 commit dd695c5

File tree

1 file changed

+82
-68
lines changed

1 file changed

+82
-68
lines changed

source

+82-68
Original file line numberDiff line numberDiff line change
@@ -10661,7 +10661,7 @@ o.myself = o;</code></pre>
1066110661

1066210662
<div w-nodev>
1066310663

10664-
<p>The <dfn method for="WindowOrWorkerGlobalScope"
10664+
<p>The <dfn method for="WindowOrWorkerOrShadowRealmGlobalScope"
1066510665
data-x="dom-structuredClone"><code>structuredClone(<var>value</var>,
1066610666
<var>options</var>)</code></dfn> method steps are:</p>
1066710667

@@ -112755,6 +112755,87 @@ interface mixin <dfn interface>WindowEventHandlers</dfn> {
112755112755
</div>
112756112756

112757112757

112758+
<h3 id="windoworworkerorshadowrealmglobalscope-mixin">The <code>WindowOrWorkerOrShadowRealmGlobalScope</code> mixin</h3>
112759+
112760+
<p>The <code>WindowOrWorkerOrShadowRealmGlobalScope</code> mixin is for use of APIs that are to be exposed on
112761+
<code>Window</code> and <code>WorkerGlobalScope</code> objects.</p>
112762+
112763+
<p class="note">Other standards are encouraged to further extend it using <code data-x="">partial
112764+
interface mixin <span>WindowOrWorkerOrShadowRealmGlobalScope</span> { &hellip; };</code> along with an
112765+
appropriate reference.</p>
112766+
112767+
<pre><code class="idl">interface mixin <dfn interface>WindowOrWorkerOrShadowRealmGlobalScope</dfn> {
112768+
// base64 utility methods
112769+
DOMString <span data-x="dom-btoa">btoa</span>(DOMString data);
112770+
ByteString <span data-x="dom-atob">atob</span>(DOMString data);
112771+
112772+
// structured cloning
112773+
any <span data-x="dom-structuredClone">structuredClone</span>(any value, optional <span>StructuredSerializeOptions</span> options = {});
112774+
};
112775+
<span>Window</span> includes <span>WindowOrWorkerGlobalScope</span>;
112776+
<span>WorkerGlobalScope</span> includes <span>WindowOrWorkerGlobalScope</span>;
112777+
<span>ShadowRealmGlobalScope</span> includes <span>WindowOrWorkerGlobalScope</span>;</code></pre>
112778+
112779+
<h4 id="atob">Base64 utility methods</h4>
112780+
112781+
<p>The <code data-x="dom-atob">atob()</code> and <code data-x="dom-btoa">btoa()</code> methods
112782+
allow developers to transform content to and from the base64 encoding.</p>
112783+
112784+
<p class="note">In these APIs, for mnemonic purposes, the "b" can be considered to stand for
112785+
"binary", and the "a" for "ASCII". In practice, though, for primarily historical reasons, both the
112786+
input and output of these functions are Unicode strings.</p>
112787+
112788+
<dl class="domintro">
112789+
<dt><code data-x=""><var>result</var> = self.<span subdfn data-x="dom-btoa">btoa</span>(<var>data</var>)</code></dt>
112790+
112791+
<dd>
112792+
<p>Takes the input data, in the form of a Unicode string containing only characters in the range
112793+
U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF respectively, and
112794+
converts it to its base64 representation, which it returns.</p>
112795+
112796+
<p>Throws an <span>"<code>InvalidCharacterError</code>"</span> <code>DOMException</code>
112797+
exception if the input string contains any out-of-range characters.</p>
112798+
</dd>
112799+
112800+
<dt><code data-x=""><var>result</var> = self.<span subdfn data-x="dom-atob">atob</span>(<var>data</var>)</code></dt>
112801+
112802+
<dd>
112803+
<p>Takes the input data, in the form of a Unicode string containing base64-encoded binary data,
112804+
decodes it, and returns a string consisting of characters in the range U+0000 to U+00FF, each
112805+
representing a binary byte with values 0x00 to 0xFF respectively, corresponding to that binary
112806+
data.</p>
112807+
112808+
<p>Throws an <span>"<code>InvalidCharacterError</code>"</span> <code>DOMException</code> if the
112809+
input string is not valid base64 data.</p>
112810+
</dd>
112811+
</dl>
112812+
112813+
<div w-nodev>
112814+
112815+
<p>The <dfn method for="WindowOrWorkerOrShadowRealmGlobalScope" data-x="dom-btoa"><code
112816+
id="dom-windowbase64-btoa">btoa(<var>data</var>)</code></dfn> method must throw an
112817+
<span>"<code>InvalidCharacterError</code>"</span> <code>DOMException</code> if <var>data</var>
112818+
contains any character whose code point is greater than U+00FF. Otherwise, the user agent must
112819+
convert <var>data</var> to a byte sequence whose <var>n</var>th byte is the eight-bit
112820+
representation of the <var>n</var>th code point of <var>data</var>, and then must apply
112821+
<span>forgiving-base64 encode</span> to that byte sequence and return the result.</p>
112822+
112823+
<p>The <dfn method for="WindowOrWorkerOrShadowRealmGlobalScope" data-x="dom-atob"><code
112824+
id="dom-windowbase64-atob">atob(<var>data</var>)</code></dfn> method steps are:</p>
112825+
112826+
<ol>
112827+
<li><p>Let <var>decodedData</var> be the result of running <span>forgiving-base64 decode</span>
112828+
on <var>data</var>.</p></li>
112829+
112830+
<li><p>If <var>decodedData</var> is failure, then throw an
112831+
<span>"<code>InvalidCharacterError</code>"</span> <code>DOMException</code>.</p></li>
112832+
112833+
<li><p>Return <var>decodedData</var>.</p></li>
112834+
</ol>
112835+
112836+
</div>
112837+
112838+
112758112839
<h3 id="windoworworkerglobalscope-mixin">The <code>WindowOrWorkerGlobalScope</code> mixin</h3>
112759112840

112760112841
<p>The <code>WindowOrWorkerGlobalScope</code> mixin is for use of APIs that are to be exposed on
@@ -112773,10 +112854,6 @@ interface mixin <dfn interface>WindowOrWorkerGlobalScope</dfn> {
112773112854

112774112855
undefined <span data-x="dom-reportError">reportError</span>(any e);
112775112856

112776-
// base64 utility methods
112777-
DOMString <span data-x="dom-btoa">btoa</span>(DOMString data);
112778-
ByteString <span data-x="dom-atob">atob</span>(DOMString data);
112779-
112780112857
// timers
112781112858
long <span data-x="dom-setTimeout">setTimeout</span>(<span>TimerHandler</span> handler, optional long timeout = 0, any... arguments);
112782112859
undefined <span data-x="dom-clearTimeout">clearTimeout</span>(optional long id = 0);
@@ -112789,9 +112866,6 @@ interface mixin <dfn interface>WindowOrWorkerGlobalScope</dfn> {
112789112866
// ImageBitmap
112790112867
<span data-x="idl-Promise">Promise</span>&lt;<span>ImageBitmap</span>&gt; <span data-x="dom-createImageBitmap">createImageBitmap</span>(<span>ImageBitmapSource</span> image, optional <span>ImageBitmapOptions</span> options = {});
112791112868
<span data-x="idl-Promise">Promise</span>&lt;<span>ImageBitmap</span>&gt; <span data-x="dom-createImageBitmap">createImageBitmap</span>(<span>ImageBitmapSource</span> image, long sx, long sy, long sw, long sh, optional <span>ImageBitmapOptions</span> options = {});
112792-
112793-
// structured cloning
112794-
any <span data-x="dom-structuredClone">structuredClone</span>(any value, optional <span>StructuredSerializeOptions</span> options = {});
112795112869
};
112796112870
<span>Window</span> includes <span>WindowOrWorkerGlobalScope</span>;
112797112871
<span>WorkerGlobalScope</span> includes <span>WindowOrWorkerGlobalScope</span>;</code></pre>
@@ -112850,66 +112924,6 @@ document.body.appendChild(frame)</code></pre>
112850112924
</div>
112851112925

112852112926

112853-
<h3 id="atob">Base64 utility methods</h3>
112854-
112855-
<p>The <code data-x="dom-atob">atob()</code> and <code data-x="dom-btoa">btoa()</code> methods
112856-
allow developers to transform content to and from the base64 encoding.</p>
112857-
112858-
<p class="note">In these APIs, for mnemonic purposes, the "b" can be considered to stand for
112859-
"binary", and the "a" for "ASCII". In practice, though, for primarily historical reasons, both the
112860-
input and output of these functions are Unicode strings.</p>
112861-
112862-
<dl class="domintro">
112863-
<dt><code data-x=""><var>result</var> = self.<span subdfn data-x="dom-btoa">btoa</span>(<var>data</var>)</code></dt>
112864-
112865-
<dd>
112866-
<p>Takes the input data, in the form of a Unicode string containing only characters in the range
112867-
U+0000 to U+00FF, each representing a binary byte with values 0x00 to 0xFF respectively, and
112868-
converts it to its base64 representation, which it returns.</p>
112869-
112870-
<p>Throws an <span>"<code>InvalidCharacterError</code>"</span> <code>DOMException</code>
112871-
exception if the input string contains any out-of-range characters.</p>
112872-
</dd>
112873-
112874-
<dt><code data-x=""><var>result</var> = self.<span subdfn data-x="dom-atob">atob</span>(<var>data</var>)</code></dt>
112875-
112876-
<dd>
112877-
<p>Takes the input data, in the form of a Unicode string containing base64-encoded binary data,
112878-
decodes it, and returns a string consisting of characters in the range U+0000 to U+00FF, each
112879-
representing a binary byte with values 0x00 to 0xFF respectively, corresponding to that binary
112880-
data.</p>
112881-
112882-
<p>Throws an <span>"<code>InvalidCharacterError</code>"</span> <code>DOMException</code> if the
112883-
input string is not valid base64 data.</p>
112884-
</dd>
112885-
</dl>
112886-
112887-
<div w-nodev>
112888-
112889-
<p>The <dfn method for="WindowOrWorkerGlobalScope" data-x="dom-btoa"><code
112890-
id="dom-windowbase64-btoa">btoa(<var>data</var>)</code></dfn> method must throw an
112891-
<span>"<code>InvalidCharacterError</code>"</span> <code>DOMException</code> if <var>data</var>
112892-
contains any character whose code point is greater than U+00FF. Otherwise, the user agent must
112893-
convert <var>data</var> to a byte sequence whose <var>n</var>th byte is the eight-bit
112894-
representation of the <var>n</var>th code point of <var>data</var>, and then must apply
112895-
<span>forgiving-base64 encode</span> to that byte sequence and return the result.</p>
112896-
112897-
<p>The <dfn method for="WindowOrWorkerGlobalScope" data-x="dom-atob"><code
112898-
id="dom-windowbase64-atob">atob(<var>data</var>)</code></dfn> method steps are:</p>
112899-
112900-
<ol>
112901-
<li><p>Let <var>decodedData</var> be the result of running <span>forgiving-base64 decode</span>
112902-
on <var>data</var>.</p></li>
112903-
112904-
<li><p>If <var>decodedData</var> is failure, then throw an
112905-
<span>"<code>InvalidCharacterError</code>"</span> <code>DOMException</code>.</p></li>
112906-
112907-
<li><p>Return <var>decodedData</var>.</p></li>
112908-
</ol>
112909-
112910-
</div>
112911-
112912-
112913112927
<h3 split-filename="dynamic-markup-insertion"><dfn>Dynamic markup insertion</dfn></h3>
112914112928

112915112929
<p class="note">APIs for dynamically inserting markup into the document interact with the parser,

0 commit comments

Comments
 (0)