Skip to content

Commit 1047241

Browse files
committed
Add atob, btoa, structuredClone to shadow realms
1 parent 9fe566a commit 1047241

File tree

1 file changed

+82
-68
lines changed

1 file changed

+82
-68
lines changed

source

Lines changed: 82 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -10659,7 +10659,7 @@ o.myself = o;</code></pre>
1065910659

1066010660
<div w-nodev>
1066110661

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

@@ -112750,6 +112750,87 @@ interface mixin <dfn interface>WindowEventHandlers</dfn> {
112750112750
</div>
112751112751

112752112752

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

112755112836
<p>The <code>WindowOrWorkerGlobalScope</code> mixin is for use of APIs that are to be exposed on
@@ -112768,10 +112849,6 @@ interface mixin <dfn interface>WindowOrWorkerGlobalScope</dfn> {
112768112849

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

112771-
// base64 utility methods
112772-
DOMString <span data-x="dom-btoa">btoa</span>(DOMString data);
112773-
ByteString <span data-x="dom-atob">atob</span>(DOMString data);
112774-
112775112852
// timers
112776112853
long <span data-x="dom-setTimeout">setTimeout</span>(<span>TimerHandler</span> handler, optional long timeout = 0, any... arguments);
112777112854
undefined <span data-x="dom-clearTimeout">clearTimeout</span>(optional long id = 0);
@@ -112784,9 +112861,6 @@ interface mixin <dfn interface>WindowOrWorkerGlobalScope</dfn> {
112784112861
// ImageBitmap
112785112862
<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 = {});
112786112863
<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 = {});
112787-
112788-
// structured cloning
112789-
any <span data-x="dom-structuredClone">structuredClone</span>(any value, optional <span>StructuredSerializeOptions</span> options = {});
112790112864
};
112791112865
<span>Window</span> includes <span>WindowOrWorkerGlobalScope</span>;
112792112866
<span>WorkerGlobalScope</span> includes <span>WindowOrWorkerGlobalScope</span>;</code></pre>
@@ -112845,66 +112919,6 @@ document.body.appendChild(frame)</code></pre>
112845112919
</div>
112846112920

112847112921

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

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

0 commit comments

Comments
 (0)