Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / js / xpconnect / tests / mochitest / test_private_field_dom.html
blob4a50c7ca9539a035bd488737f3f986345863b8c6
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=????
5 -->
7 <head>
8 <meta charset="utf-8">
9 <title>Test for Bug ????</title>
10 <script src="/tests/SimpleTest/SimpleTest.js"></script>
11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
12 <iframe id="ifr"></iframe>
13 </head>
15 <body>
16 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1094930">Mozilla Bug 1094930</a>
17 <p id="display"></p>
18 <div id="test_contents">
19 <!-- Extracted from nsHTMLTagList.h -->
20 <applet></applet>
21 <area></area>
22 <audio></audio>
23 <base>
24 </base>
25 <bgsound></bgsound>
26 <blockquote></blockquote>
28 <body></body>
29 <br></br>
30 <button></button>
31 <canvas></canvas>
32 <caption></caption>
33 <col>
34 </col>
35 <colgroup></colgroup>
36 <data></data>
37 <datalist></datalist>
38 <del></del>
39 <details></details>
40 <dialog></dialog>
41 <dir></dir>
42 <div></div>
43 <dl></dl>
44 <embed></embed>
45 <fieldset></fieldset>
46 <font></font>
47 <form></form>
48 <frame></frame>
49 <frameset></frameset>
50 <h1></h1>
51 <h2></h2>
52 <h3></h3>
53 <h4></h4>
54 <h5></h5>
55 <h6></h6>
57 <head></head>
58 <hr>
59 </hr>
60 <html>
62 </html>
63 <iframe></iframe>
64 <img></img>
65 <input></input>
66 <ins></ins>
67 <keygen></keygen>
68 <label></label>
69 <legend></legend>
70 <li></li>
71 <link>
72 </link>
73 <listing></listing>
74 <map></map>
75 <marquee></marquee>
76 <menu></menu>
77 <menuitem>
78 </menuitem>
79 <meta>
80 </meta>
81 <meter></meter>
82 <multicol></multicol>
83 <object></object>
84 <ol></ol>
85 <optgroup></optgroup>
86 <option></option>
87 <output></output>
88 <p></p>
89 <param>
90 </param>
91 <picture></picture>
92 <pre></pre>
93 <progress></progress>
94 <q></q>
95 <script></script>
96 <select></select>
97 <slot></slot>
98 <source>
99 </source>
100 <span></span>
101 <style></style>
102 <summary></summary>
103 <table></table>
104 <tbody></tbody>
105 <td></td>
106 <textarea></textarea>
107 <tfoot></tfoot>
108 <th></th>
109 <thead></thead>
110 <template></template>
111 <time></time>
112 <title></title>
113 <tr></tr>
114 <track>
115 </track>
116 <ul></ul>
117 <video></video>
118 <xmp></xmp>
119 </div>
120 <script type="application/javascript">
121 SimpleTest.waitForExplicitFinish();
122 info("running")
125 // Because private fields may not be enabled, we construct A via the below eval of an IFFE,
126 // and return early if it syntax errors.
127 var A = undefined;
128 try {
129 A = eval(`(function(){
130 class Base {
131 constructor(o) {
132 return o;
136 class A extends Base {
137 #x = 1;
138 static g(o) {
139 return o.#x;
141 static s(o, v) {
142 o.#x = v;
146 return A;
147 })();`);
148 } catch (e) {
149 is(e instanceof SyntaxError, true, "Threw Syntax Error, Private Fields Not Enabled");
150 is(/private fields are not currently supported/.test(e.message), true, "correct message");
153 if (A instanceof Function) {
154 function assertThrewInstance(f, error) {
155 var threw = true;
156 try {
157 f();
158 threw = false;
159 } catch (e) {
160 // info("Caught " + e.name);
161 is(e instanceof error, true, "Correct Error thrown");
163 is(threw, true, "Error was thrown");
166 function testNode(node) {
167 info("Testing node " + node.nodeName);
169 assertThrewInstance(() => A.g(node), TypeError);
170 assertThrewInstance(() => A.s(node, 'node'), TypeError);
171 // info("Stamping Node");
172 new A(node);
173 // info("Asserting read");
174 is(A.g(node), 1, "correct value read");
175 // info("Setting");
176 A.s(node, 'node');
177 // info("Verifing setter set the value");
178 is(A.g(node), 'node', "updated value read");
179 // info("Verifying we cannot double-init");
180 assertThrewInstance(() => new A(node), TypeError);
183 function testNodeRecursive(node) {
184 testNode(node);
185 for (c of node.children) {
186 testNodeRecursive(c)
190 const test_contents = document.getElementById('test_contents');
191 testNodeRecursive(test_contents);
193 info("Checking Window");
194 // Window itself isn't allowed to host private fields, because it's
195 // a cross-origin object
196 assertThrewInstance(() => A.g(window), TypeError)
198 info("Checking Window Prototype Chain")
199 // However, it's prototype chain can.
200 w = Object.getPrototypeOf(window);
201 while (w) {
202 testNode(w);
203 w = Object.getPrototypeOf(w);
206 info("Test Document")
207 testNode(document);
210 info("Test CSSRuleList")
211 testNode(document.styleSheets[0].cssRules)
213 info("Test DOMTokenList")
214 const div = document.createElement('div');
215 testNode(div.classList);
217 SimpleTest.finish();
218 </script>
219 </body>
221 </html>