Skip to content

Commit

Permalink
BigInt support added
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Jan 15, 2025
1 parent 23d7c2d commit 84a95dc
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@
</properties>

<body>
<release version="4.9.0" date="February xx, 2025" description="Bugfixes">
<release version="4.9.0" date="February xx, 2025" description="Bugfixes, BigInt">
<action type="fix" dev="rbri">
core-js: junit-vintage-engine was NOT marked as 'test' dependency, therefore we had junit
as part of our depenencies/lib/diestribution (regression from 4.8.0)
</action>
<action type="add" dev="rbri">
BigInt support added.
</action>
<action type="fix" dev="RhinoTeam">
core-js: Symbol.hasInstance for Function.prototype implemented
core-js: Symbol.hasInstance for Function.prototype implemented.
</action>
<action type="add" dev="rbri">
core-js: Context#emptyArgs is deprecated
core-js: Context#emptyArgs is deprecated.
</action>
</release>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public static void configureRhino(final WebClient webClient,
NumberCustom.class, ScriptableObject.DONTENUM);

// remove some objects, that Rhino defines in top scope but that we don't want
deleteProperties(scope, "Continuation", "StopIteration", "BigInt");
deleteProperties(scope, "Continuation", "StopIteration");
if (!browserVersion.hasFeature(JS_ITERATOR_VISIBLE_IN_WINDOW)) {
deleteProperties(scope, "Iterator");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,15 @@ public void beforeUnloadEvent() throws Exception {
test("BeforeUnloadEvent");
}

/**
* @throws Exception if the test fails
*/
@Test
@Alerts("function BigInt() { [native code] }")
public void bigInt() throws Exception {
test("BigInt");
}

/**
* @throws Exception if the test fails
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,15 @@ public void beforeUnloadEvent() throws Exception {
test("BeforeUnloadEvent");
}

/**
* @throws Exception if the test fails
*/
@Test
@Alerts("function")
public void bigInt() throws Exception {
test("BigInt");
}

/**
* @throws Exception if the test fails
*/
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/org/htmlunit/general/HostClassNameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,15 @@ public void beforeUnloadEvent() throws Exception {
test("BeforeUnloadEvent");
}

/**
* @throws Exception if the test fails
*/
@Test
@Alerts("function BigInt() { [native code] }")
public void bigInt() throws Exception {
test("BigInt");
}

/**
* @throws Exception if the test fails
*/
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/org/htmlunit/general/HostTypeOfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,15 @@ public void beforeUnloadEvent() throws Exception {
test("BeforeUnloadEvent");
}

/**
* @throws Exception if the test fails
*/
@Test
@Alerts("function")
public void bigInt() throws Exception {
test("BigInt");
}

/**
* @throws Exception if the test fails
*/
Expand Down
50 changes: 50 additions & 0 deletions src/test/java/org/htmlunit/javascript/NativeBigIntTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2002-2025 Gargoyle Software Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.htmlunit.javascript;

import org.htmlunit.WebDriverTestCase;
import org.htmlunit.junit.BrowserRunner;
import org.htmlunit.junit.BrowserRunner.Alerts;
import org.htmlunit.junit.BrowserRunner.HtmlUnitNYI;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* Some test for BigInt support.
*
* @author Ronald Brill
*/
@RunWith(BrowserRunner.class)
public class NativeBigIntTest extends WebDriverTestCase {

/**
* @throws Exception if the test fails
*/
@Test
@Alerts(DEFAULT = {"bigint", "bigint"})
public void typeof() throws Exception {
final String html
= "<html>"
+ "<body>\n"
+ "<script>\n"
+ LOG_TITLE_FUNCTION
+ " log(typeof 1n);\n"
+ " log(typeof BigInt('1'));\n"
+ "</script>\n"
+ "</body></html>";

loadPageVerifyTitle2(html);
}
}

0 comments on commit 84a95dc

Please sign in to comment.