Skip to content

Commit

Permalink
Update the encoding IDL file (#9780)
Browse files Browse the repository at this point in the history
Also update the existing idlharness.js test to use it.
  • Loading branch information
lukebjerring authored and foolip committed Mar 14, 2018
1 parent 8896c5c commit b202bbb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 51 deletions.
61 changes: 10 additions & 51 deletions encoding/idlharness.html
Expand Up @@ -11,56 +11,15 @@
<h1>idlharness test</h1>
<p>This test validates the WebIDL included in the Encoding Living Standard.</p>

<script type="text/plain" class="untested-idl">
interface Window {};
</script>

<script type="text/plain" class="idl">
// 8.1 Interface TextDecoder

dictionary TextDecoderOptions {
boolean fatal = false;
boolean ignoreBOM = false;
};

dictionary TextDecodeOptions {
boolean stream = false;
};

[Constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options),
Exposed=(Window,Worker)]
interface TextDecoder {
readonly attribute DOMString encoding;
readonly attribute boolean fatal;
readonly attribute boolean ignoreBOM;
USVString decode(optional BufferSource input, optional TextDecodeOptions options);
};

// 8.2 Interface TextDecoder

[Constructor,
Exposed=(Window,Worker)]
interface TextEncoder {
readonly attribute DOMString encoding;
[NewObject] Uint8Array encode(optional USVString input = "");
};
</script>

<script>
function select(selector) {
return [].slice.call(document.querySelectorAll(selector))
.map(function(e) { return e.textContent; })
.join('\n\n');
}

var idl = select('.idl')
var untested = select('.untested-idl');
var idl_array = new IdlArray();
idl_array.add_untested_idls(untested);
idl_array.add_idls(idl);
idl_array.add_objects({
TextEncoder: ['new TextEncoder()'],
TextDecoder: ['new TextDecoder()']
});
idl_array.test();
promise_test(async() => {
const text = await (await fetch('/interfaces/encoding.idl')).text();
const idl_array = new IdlArray();
idl_array.add_idls(text);
idl_array.add_objects({
TextEncoder: ['new TextEncoder()'],
TextDecoder: ['new TextDecoder()']
});
idl_array.test();
}, 'Test driver');
</script>
24 changes: 24 additions & 0 deletions interfaces/encoding.idl
@@ -0,0 +1,24 @@
dictionary TextDecoderOptions {
boolean fatal = false;
boolean ignoreBOM = false;
};

dictionary TextDecodeOptions {
boolean stream = false;
};

[Constructor(optional DOMString label = "utf-8", optional TextDecoderOptions options),
Exposed=(Window,Worker)]
interface TextDecoder {
readonly attribute DOMString encoding;
readonly attribute boolean fatal;
readonly attribute boolean ignoreBOM;
USVString decode(optional BufferSource input, optional TextDecodeOptions options);
};

[Constructor,
Exposed=(Window,Worker)]
interface TextEncoder {
readonly attribute DOMString encoding;
[NewObject] Uint8Array encode(optional USVString input = "");
};

0 comments on commit b202bbb

Please sign in to comment.