OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <meta charset="utf-8"> | |
3 <title>idlharness test: Encoding Living Standard API</title> | |
4 <link rel="author" title="Joshua Bell" href="mailto:jsbell@google.com" /> | |
5 <link rel="help" href="https://encoding.spec.whatwg.org/#api"/> | |
6 <script src="../../../resources/testharness.js"></script> | |
7 <script src="../../../resources/testharnessreport.js"></script> | |
8 <script src="../../../resources/WebIDLParser.js"></script> | |
9 <script src="../../../resources/idlharness.js"></script> | |
10 | |
11 <h1>idlharness test</h1> | |
12 <p>This test validates the WebIDL included in the Encoding Living Standard.</p> | |
13 | |
14 <script type="text/plain" class="untested-idl"> | |
15 interface Window {}; | |
16 </script> | |
17 | |
18 <script type="text/plain" class="idl"> | |
19 // 8.1 Interface TextDecoder | |
20 | |
21 dictionary TextDecoderOptions { | |
22 boolean fatal = false; | |
23 boolean ignoreBOM = false; | |
24 }; | |
25 | |
26 dictionary TextDecodeOptions { | |
27 boolean stream = false; | |
28 }; | |
29 | |
30 [Constructor(optional DOMString label = "utf-8", optional TextDecoderOptions opt
ions), | |
31 Exposed=Window,Worker] | |
32 interface TextDecoder { | |
33 readonly attribute DOMString encoding; | |
34 readonly attribute boolean fatal; | |
35 readonly attribute boolean ignoreBOM; | |
36 USVString decode(optional BufferSource input, optional TextDecodeOptions optio
ns); | |
37 }; | |
38 | |
39 // 8.2 Interface TextDecoder | |
40 | |
41 [Constructor, | |
42 Exposed=Window,Worker] | |
43 interface TextEncoder { | |
44 readonly attribute DOMString encoding; | |
45 [NewObject] Uint8Array encode(optional USVString input = ""); | |
46 }; | |
47 </script> | |
48 | |
49 <script> | |
50 function select(selector) { | |
51 return [].slice.call(document.querySelectorAll(selector)) | |
52 .map(function(e) { return e.textContent; }) | |
53 .join('\n\n'); | |
54 } | |
55 | |
56 var idl = select('.idl') | |
57 var untested = select('.untested-idl'); | |
58 var idl_array = new IdlArray(); | |
59 idl_array.add_untested_idls(untested); | |
60 idl_array.add_idls(idl); | |
61 idl_array.add_objects({ | |
62 TextEncoder: ['new TextEncoder()'], | |
63 TextDecoder: ['new TextDecoder()'] | |
64 }); | |
65 idl_array.test(); | |
66 </script> | |
OLD | NEW |