Skip to content

Commit 84a95dc

Browse files
committed
BigInt support added
1 parent 23d7c2d commit 84a95dc

File tree

7 files changed

+97
-4
lines changed

7 files changed

+97
-4
lines changed

src/changes/changes.xml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@
77
</properties>
88

99
<body>
10-
<release version="4.9.0" date="February xx, 2025" description="Bugfixes">
10+
<release version="4.9.0" date="February xx, 2025" description="Bugfixes, BigInt">
11+
<action type="fix" dev="rbri">
12+
core-js: junit-vintage-engine was NOT marked as 'test' dependency, therefore we had junit
13+
as part of our depenencies/lib/diestribution (regression from 4.8.0)
14+
</action>
15+
<action type="add" dev="rbri">
16+
BigInt support added.
17+
</action>
1118
<action type="fix" dev="RhinoTeam">
12-
core-js: Symbol.hasInstance for Function.prototype implemented
19+
core-js: Symbol.hasInstance for Function.prototype implemented.
1320
</action>
1421
<action type="add" dev="rbri">
15-
core-js: Context#emptyArgs is deprecated
22+
core-js: Context#emptyArgs is deprecated.
1623
</action>
1724
</release>
1825

src/main/java/org/htmlunit/javascript/JavaScriptEngine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public static void configureRhino(final WebClient webClient,
423423
NumberCustom.class, ScriptableObject.DONTENUM);
424424

425425
// remove some objects, that Rhino defines in top scope but that we don't want
426-
deleteProperties(scope, "Continuation", "StopIteration", "BigInt");
426+
deleteProperties(scope, "Continuation", "StopIteration");
427427
if (!browserVersion.hasFeature(JS_ITERATOR_VISIBLE_IN_WINDOW)) {
428428
deleteProperties(scope, "Iterator");
429429
}

src/test/java/org/htmlunit/general/DedicatedWorkerGlobalScopeClassNameTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,15 @@ public void beforeUnloadEvent() throws Exception {
508508
test("BeforeUnloadEvent");
509509
}
510510

511+
/**
512+
* @throws Exception if the test fails
513+
*/
514+
@Test
515+
@Alerts("function BigInt() { [native code] }")
516+
public void bigInt() throws Exception {
517+
test("BigInt");
518+
}
519+
511520
/**
512521
* @throws Exception if the test fails
513522
*/

src/test/java/org/htmlunit/general/DedicatedWorkerGlobalScopeTypeOfTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,15 @@ public void beforeUnloadEvent() throws Exception {
505505
test("BeforeUnloadEvent");
506506
}
507507

508+
/**
509+
* @throws Exception if the test fails
510+
*/
511+
@Test
512+
@Alerts("function")
513+
public void bigInt() throws Exception {
514+
test("BigInt");
515+
}
516+
508517
/**
509518
* @throws Exception if the test fails
510519
*/

src/test/java/org/htmlunit/general/HostClassNameTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,15 @@ public void beforeUnloadEvent() throws Exception {
522522
test("BeforeUnloadEvent");
523523
}
524524

525+
/**
526+
* @throws Exception if the test fails
527+
*/
528+
@Test
529+
@Alerts("function BigInt() { [native code] }")
530+
public void bigInt() throws Exception {
531+
test("BigInt");
532+
}
533+
525534
/**
526535
* @throws Exception if the test fails
527536
*/

src/test/java/org/htmlunit/general/HostTypeOfTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,15 @@ public void beforeUnloadEvent() throws Exception {
498498
test("BeforeUnloadEvent");
499499
}
500500

501+
/**
502+
* @throws Exception if the test fails
503+
*/
504+
@Test
505+
@Alerts("function")
506+
public void bigInt() throws Exception {
507+
test("BigInt");
508+
}
509+
501510
/**
502511
* @throws Exception if the test fails
503512
*/
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2002-2025 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.htmlunit.junit.BrowserRunner.HtmlUnitNYI;
21+
import org.junit.Test;
22+
import org.junit.runner.RunWith;
23+
24+
/**
25+
* Some test for BigInt support.
26+
*
27+
* @author Ronald Brill
28+
*/
29+
@RunWith(BrowserRunner.class)
30+
public class NativeBigIntTest extends WebDriverTestCase {
31+
32+
/**
33+
* @throws Exception if the test fails
34+
*/
35+
@Test
36+
@Alerts(DEFAULT = {"bigint", "bigint"})
37+
public void typeof() throws Exception {
38+
final String html
39+
= "<html>"
40+
+ "<body>\n"
41+
+ "<script>\n"
42+
+ LOG_TITLE_FUNCTION
43+
+ " log(typeof 1n);\n"
44+
+ " log(typeof BigInt('1'));\n"
45+
+ "</script>\n"
46+
+ "</body></html>";
47+
48+
loadPageVerifyTitle2(html);
49+
}
50+
}

0 commit comments

Comments
 (0)