Skip to content

Commit 8c93c08

Browse files
committed
add tests for NativeTypedArrayView Symbol.toStringTag support (issue HtmlUnit/htmlunit-rhino-fork#16)
1 parent d616c03 commit 8c93c08

File tree

1 file changed

+192
-0
lines changed

1 file changed

+192
-0
lines changed
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
/*
2+
* Copyright (c) 2002-2024 Gargoyle Software Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* https://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
package org.htmlunit.javascript;
16+
17+
import org.htmlunit.WebDriverTestCase;
18+
import org.htmlunit.junit.BrowserRunner;
19+
import org.htmlunit.junit.BrowserRunner.Alerts;
20+
import org.junit.Test;
21+
import org.junit.runner.RunWith;
22+
23+
/**
24+
* Tests for the various TypedArray's.
25+
*
26+
* @author Ronald Brill
27+
*/
28+
@RunWith(BrowserRunner.class)
29+
public class NativeTypedArrayTest extends WebDriverTestCase {
30+
31+
/**
32+
* @throws Exception if the test fails
33+
*/
34+
@Test
35+
@Alerts("Float32Array")
36+
public void toStringFloat32Array() throws Exception {
37+
final String html
38+
= "<html></head>\n"
39+
+ "<body>"
40+
+ "<script>\n"
41+
+ LOG_TITLE_FUNCTION
42+
+ " log((new Float32Array(1))[Symbol.toStringTag]);\n"
43+
+ "</script>\n"
44+
+ "</body></html>";
45+
46+
loadPageVerifyTitle2(html);
47+
}
48+
49+
/**
50+
* @throws Exception if the test fails
51+
*/
52+
@Test
53+
@Alerts("Float64Array")
54+
public void toStringFloat64Array() throws Exception {
55+
final String html
56+
= "<html></head>\n"
57+
+ "<body>"
58+
+ "<script>\n"
59+
+ LOG_TITLE_FUNCTION
60+
+ " log((new Float64Array(1))[Symbol.toStringTag]);\n"
61+
+ "</script>\n"
62+
+ "</body></html>";
63+
64+
loadPageVerifyTitle2(html);
65+
}
66+
67+
/**
68+
* @throws Exception if the test fails
69+
*/
70+
@Test
71+
@Alerts("Int8Array")
72+
public void toStringInt8Array() throws Exception {
73+
final String html
74+
= "<html></head>\n"
75+
+ "<body>"
76+
+ "<script>\n"
77+
+ LOG_TITLE_FUNCTION
78+
+ " log((new Int8Array(1))[Symbol.toStringTag]);\n"
79+
+ "</script>\n"
80+
+ "</body></html>";
81+
82+
loadPageVerifyTitle2(html);
83+
}
84+
85+
/**
86+
* @throws Exception if the test fails
87+
*/
88+
@Test
89+
@Alerts("Int16Array")
90+
public void toStringInt16Array() throws Exception {
91+
final String html
92+
= "<html></head>\n"
93+
+ "<body>"
94+
+ "<script>\n"
95+
+ LOG_TITLE_FUNCTION
96+
+ " log((new Int16Array(1))[Symbol.toStringTag]);\n"
97+
+ "</script>\n"
98+
+ "</body></html>";
99+
100+
loadPageVerifyTitle2(html);
101+
}
102+
103+
/**
104+
* @throws Exception if the test fails
105+
*/
106+
@Test
107+
@Alerts("Int32Array")
108+
public void toStringInt32Array() throws Exception {
109+
final String html
110+
= "<html></head>\n"
111+
+ "<body>"
112+
+ "<script>\n"
113+
+ LOG_TITLE_FUNCTION
114+
+ " log((new Int32Array(1))[Symbol.toStringTag]);\n"
115+
+ "</script>\n"
116+
+ "</body></html>";
117+
118+
loadPageVerifyTitle2(html);
119+
}
120+
121+
/**
122+
* @throws Exception if the test fails
123+
*/
124+
@Test
125+
@Alerts("Uint8Array")
126+
public void toStringUint8Array() throws Exception {
127+
final String html
128+
= "<html></head>\n"
129+
+ "<body>"
130+
+ "<script>\n"
131+
+ LOG_TITLE_FUNCTION
132+
+ " log((new Uint8Array(1))[Symbol.toStringTag]);\n"
133+
+ "</script>\n"
134+
+ "</body></html>";
135+
136+
loadPageVerifyTitle2(html);
137+
}
138+
139+
/**
140+
* @throws Exception if the test fails
141+
*/
142+
@Test
143+
@Alerts("Uint16Array")
144+
public void toStringUint16Array() throws Exception {
145+
final String html
146+
= "<html></head>\n"
147+
+ "<body>"
148+
+ "<script>\n"
149+
+ LOG_TITLE_FUNCTION
150+
+ " log((new Uint16Array(1))[Symbol.toStringTag]);\n"
151+
+ "</script>\n"
152+
+ "</body></html>";
153+
154+
loadPageVerifyTitle2(html);
155+
}
156+
157+
/**
158+
* @throws Exception if the test fails
159+
*/
160+
@Test
161+
@Alerts("Uint32Array")
162+
public void toStringUint32Array() throws Exception {
163+
final String html
164+
= "<html></head>\n"
165+
+ "<body>"
166+
+ "<script>\n"
167+
+ LOG_TITLE_FUNCTION
168+
+ " log((new Uint32Array(1))[Symbol.toStringTag]);\n"
169+
+ "</script>\n"
170+
+ "</body></html>";
171+
172+
loadPageVerifyTitle2(html);
173+
}
174+
175+
/**
176+
* @throws Exception if the test fails
177+
*/
178+
@Test
179+
@Alerts("Uint8ClampedArray")
180+
public void toStringUint8ClampedArray() throws Exception {
181+
final String html
182+
= "<html></head>\n"
183+
+ "<body>"
184+
+ "<script>\n"
185+
+ LOG_TITLE_FUNCTION
186+
+ " log((new Uint8ClampedArray(1))[Symbol.toStringTag]);\n"
187+
+ "</script>\n"
188+
+ "</body></html>";
189+
190+
loadPageVerifyTitle2(html);
191+
}
192+
}

0 commit comments

Comments
 (0)