Skip to content

Commit 94cc357

Browse files
committed
use VarScope
1 parent 5f26557 commit 94cc357

44 files changed

Lines changed: 134 additions & 102 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public static void configureGlobalThis(
375375
}
376376

377377
private static void addAsConstructorAndAlias(final FunctionObject function,
378-
final Scriptable scope,
378+
final VarScope scope,
379379
final HtmlUnitScriptable destination,
380380
final Scriptable prototype,
381381
final ClassConfiguration config) {
@@ -398,7 +398,7 @@ private static void addAsConstructorAndAlias(final FunctionObject function,
398398
}
399399
}
400400

401-
private static void additionalCtor(final Scriptable scope, final Window window, final Scriptable proto,
401+
private static void additionalCtor(final VarScope scope, final Window window, final Scriptable proto,
402402
final Method ctorMethod, final String prop, final String clazzName) throws Exception {
403403
final FunctionObject function = new FunctionObject(prop, ctorMethod, scope);
404404
final Object prototypeProperty = ScriptableObject.getProperty(window, clazzName);
@@ -489,7 +489,7 @@ public static void applyPolyfills(final WebClient webClient, final BrowserVersio
489489
}
490490
}
491491

492-
private static void defineConstructor(final Scriptable scope,
492+
private static void defineConstructor(final VarScope scope,
493493
final Scriptable prototype, final ScriptableObject constructor) {
494494
constructor.setParentScope(scope);
495495
try {
@@ -538,7 +538,7 @@ private static void deleteProperties(final Scriptable destination, final String.
538538
* @param className the class for which properties should be removed
539539
* @param properties the properties to remove
540540
*/
541-
private static void removePrototypeProperties(final Scriptable scope, final String className,
541+
private static void removePrototypeProperties(final VarScope scope, final String className,
542542
final String... properties) {
543543
final ScriptableObject prototype = (ScriptableObject) ScriptableObject.getClassPrototype(scope, className);
544544
for (final String property : properties) {
@@ -1415,7 +1415,7 @@ public static Scriptable newArray(final Scriptable scope, final Object[] element
14151415
* @param elements the initial elements..
14161416
* @return the new Uint8Array
14171417
*/
1418-
public static NativeUint8Array newUint8Array(final Scriptable scope, final byte[] elements) {
1418+
public static NativeUint8Array newUint8Array(final VarScope scope, final byte[] elements) {
14191419
final NativeArrayBuffer arrayBuffer = new NativeArrayBuffer(elements.length);
14201420
ScriptRuntime.setBuiltinProtoAndParent(arrayBuffer, scope, TopLevel.Builtins.ArrayBuffer);
14211421
System.arraycopy(elements, 0, arrayBuffer.getBuffer(), 0, elements.length);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public final class NativeFunctionToStringFunction {
4040
* @param scope the scope
4141
* @param browserVersion the simulated browser
4242
*/
43-
public static void installFix(final Scriptable scope, final BrowserVersion browserVersion) {
43+
public static void installFix(final VarScope scope, final BrowserVersion browserVersion) {
4444
if (browserVersion.hasFeature(JS_NATIVE_FUNCTION_TOSTRING_COMPACT)) {
4545
final ScriptableObject fnPrototype =
4646
(ScriptableObject) ScriptableObject.getClassPrototype(scope, "Function");

src/main/java/org/htmlunit/javascript/host/BroadcastChannel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.htmlunit.corejs.javascript.Function;
2323
import org.htmlunit.corejs.javascript.FunctionObject;
2424
import org.htmlunit.corejs.javascript.Scriptable;
25+
import org.htmlunit.corejs.javascript.VarScope;
2526
import org.htmlunit.javascript.AbstractJavaScriptEngine;
2627
import org.htmlunit.javascript.HtmlUnitContextFactory;
2728
import org.htmlunit.javascript.JavaScriptEngine;
@@ -56,7 +57,7 @@ public class BroadcastChannel extends EventTarget {
5657
* @return the java object to allow JavaScript to access
5758
*/
5859
@JsxConstructor
59-
public static BroadcastChannel jsConstructor(final Context cx, final Scriptable scope,
60+
public static BroadcastChannel jsConstructor(final Context cx, final VarScope scope,
6061
final Object[] args, final Function ctorObj, final boolean inNewExpr) {
6162
if (args.length < 1 || JavaScriptEngine.isUndefined(args[0])) {
6263
throw JavaScriptEngine.typeError("BroadcastChannel constructor requires a channel name argument");

src/main/java/org/htmlunit/javascript/host/ConsoleCustom.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import org.htmlunit.corejs.javascript.Function;
1919
import org.htmlunit.corejs.javascript.NativeConsole;
2020
import org.htmlunit.corejs.javascript.Scriptable;
21+
import org.htmlunit.corejs.javascript.VarScope;
2122

2223
/**
2324
* Contains some missing features of Rhino {@link NativeConsole}.
@@ -41,7 +42,7 @@ private ConsoleCustom() {
4142
* @param args the arguments passed into the method
4243
* @param function the function
4344
*/
44-
public static void timeStamp(final Context context, final Scriptable scope,
45+
public static void timeStamp(final Context context, final VarScope scope,
4546
final Scriptable thisObj, final Object[] args, final Function function) {
4647
// noop
4748
}

src/main/java/org/htmlunit/javascript/host/DOMRect.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import org.htmlunit.corejs.javascript.Context;
1818
import org.htmlunit.corejs.javascript.Function;
19-
import org.htmlunit.corejs.javascript.Scriptable;
19+
import org.htmlunit.corejs.javascript.VarScope;
2020
import org.htmlunit.javascript.configuration.JsxClass;
2121
import org.htmlunit.javascript.configuration.JsxConstructor;
2222
import org.htmlunit.javascript.configuration.JsxGetter;
@@ -43,7 +43,7 @@ public class DOMRect extends DOMRectReadOnly {
4343
* @return the java object to allow JavaScript to access
4444
*/
4545
@JsxConstructor
46-
public static DOMRect jsConstructor(final Context cx, final Scriptable scope,
46+
public static DOMRect jsConstructor(final Context cx, final VarScope scope,
4747
final Object[] args, final Function ctorObj, final boolean inNewExpr) {
4848

4949
final DOMRect rect = new DOMRect();

src/main/java/org/htmlunit/javascript/host/Element.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.htmlunit.corejs.javascript.NativeObject;
4040
import org.htmlunit.corejs.javascript.Scriptable;
4141
import org.htmlunit.corejs.javascript.ScriptableObject;
42+
import org.htmlunit.corejs.javascript.VarScope;
4243
import org.htmlunit.corejs.javascript.WithScope;
4344
import org.htmlunit.css.ComputedCssStyleDeclaration;
4445
import org.htmlunit.css.ElementCssStyleDeclaration;
@@ -858,7 +859,7 @@ public void insertAdjacentHTML(final String position, final String text) {
858859
* @param function the function
859860
*/
860861
@JsxFunction({CHROME, EDGE, FF})
861-
public static void moveBefore(final Context context, final Scriptable scope,
862+
public static void moveBefore(final Context context, final VarScope scope,
862863
final Scriptable thisObj, final Object[] args, final Function function) {
863864
Node.moveBefore(context, scope, thisObj, args, function);
864865
}
@@ -1556,7 +1557,7 @@ public void releaseCapture() {
15561557
* @param function the function
15571558
*/
15581559
@JsxFunction
1559-
public static void before(final Context context, final Scriptable scope,
1560+
public static void before(final Context context, final VarScope scope,
15601561
final Scriptable thisObj, final Object[] args, final Function function) {
15611562
Node.before(context, thisObj, args, function);
15621563
}
@@ -1571,7 +1572,7 @@ public static void before(final Context context, final Scriptable scope,
15711572
* @param function the function
15721573
*/
15731574
@JsxFunction
1574-
public static void after(final Context context, final Scriptable scope,
1575+
public static void after(final Context context, final VarScope scope,
15751576
final Scriptable thisObj, final Object[] args, final Function function) {
15761577
Node.after(context, thisObj, args, function);
15771578
}
@@ -1585,7 +1586,7 @@ public static void after(final Context context, final Scriptable scope,
15851586
* @param function the function
15861587
*/
15871588
@JsxFunction
1588-
public static void replaceWith(final Context context, final Scriptable scope,
1589+
public static void replaceWith(final Context context, final VarScope scope,
15891590
final Scriptable thisObj, final Object[] args, final Function function) {
15901591
Node.replaceWith(context, thisObj, args, function);
15911592
}
@@ -1600,7 +1601,7 @@ public static void replaceWith(final Context context, final Scriptable scope,
16001601
* @return the value
16011602
*/
16021603
@JsxFunction
1603-
public static boolean matches(final Context context, final Scriptable scope,
1604+
public static boolean matches(final Context context, final VarScope scope,
16041605
final Scriptable thisObj, final Object[] args, final Function function) {
16051606
if (!(thisObj instanceof Element)) {
16061607
throw JavaScriptEngine.typeError("Illegal invocation");
@@ -1630,7 +1631,7 @@ public static boolean matches(final Context context, final Scriptable scope,
16301631
* @return the value
16311632
*/
16321633
@JsxFunction({FF, FF_ESR})
1633-
public static boolean mozMatchesSelector(final Context context, final Scriptable scope,
1634+
public static boolean mozMatchesSelector(final Context context, final VarScope scope,
16341635
final Scriptable thisObj, final Object[] args, final Function function) {
16351636
return matches(context, scope, thisObj, args, function);
16361637
}
@@ -1645,7 +1646,7 @@ public static boolean mozMatchesSelector(final Context context, final Scriptable
16451646
* @return the value
16461647
*/
16471648
@JsxFunction
1648-
public static boolean webkitMatchesSelector(final Context context, final Scriptable scope,
1649+
public static boolean webkitMatchesSelector(final Context context, final VarScope scope,
16491650
final Scriptable thisObj, final Object[] args, final Function function) {
16501651
return matches(context, scope, thisObj, args, function);
16511652
}
@@ -1661,7 +1662,7 @@ public static boolean webkitMatchesSelector(final Context context, final Scripta
16611662
* @return the found element or null
16621663
*/
16631664
@JsxFunction
1664-
public static Element closest(final Context context, final Scriptable scope,
1665+
public static Element closest(final Context context, final VarScope scope,
16651666
final Scriptable thisObj, final Object[] args, final Function function) {
16661667
if (!(thisObj instanceof Element)) {
16671668
throw JavaScriptEngine.typeError("Illegal invocation");
@@ -1730,7 +1731,7 @@ public boolean toggleAttribute(final String name, final Object force) {
17301731
* @param function the function
17311732
*/
17321733
@JsxFunction
1733-
public static void append(final Context context, final Scriptable scope,
1734+
public static void append(final Context context, final VarScope scope,
17341735
final Scriptable thisObj, final Object[] args, final Function function) {
17351736
if (!(thisObj instanceof Element)) {
17361737
throw JavaScriptEngine.typeError("Illegal invocation");
@@ -1750,7 +1751,7 @@ public static void append(final Context context, final Scriptable scope,
17501751
* @param function the function
17511752
*/
17521753
@JsxFunction
1753-
public static void prepend(final Context context, final Scriptable scope,
1754+
public static void prepend(final Context context, final VarScope scope,
17541755
final Scriptable thisObj, final Object[] args, final Function function) {
17551756
if (!(thisObj instanceof Element)) {
17561757
throw JavaScriptEngine.typeError("Illegal invocation");
@@ -1770,7 +1771,7 @@ public static void prepend(final Context context, final Scriptable scope,
17701771
* @param function the function
17711772
*/
17721773
@JsxFunction
1773-
public static void replaceChildren(final Context context, final Scriptable scope,
1774+
public static void replaceChildren(final Context context, final VarScope scope,
17741775
final Scriptable thisObj, final Object[] args, final Function function) {
17751776
if (!(thisObj instanceof Element)) {
17761777
throw JavaScriptEngine.typeError("Illegal invocation");

src/main/java/org/htmlunit/javascript/host/Location.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import org.htmlunit.corejs.javascript.Context;
3232
import org.htmlunit.corejs.javascript.Function;
3333
import org.htmlunit.corejs.javascript.FunctionObject;
34-
import org.htmlunit.corejs.javascript.Scriptable;
3534
import org.htmlunit.corejs.javascript.ScriptableObject;
35+
import org.htmlunit.corejs.javascript.VarScope;
3636
import org.htmlunit.html.HtmlPage;
3737
import org.htmlunit.javascript.HtmlUnitScriptable;
3838
import org.htmlunit.javascript.configuration.JsxClass;
@@ -158,7 +158,7 @@ public class Location extends HtmlUnitScriptable {
158158
* @return the java object to allow JavaScript to access
159159
*/
160160
@JsxConstructor
161-
public static Location jsConstructor(final Context cx, final Scriptable scope,
161+
public static Location jsConstructor(final Context cx, final VarScope scope,
162162
final Object[] args, final Function ctorObj, final boolean inNewExpr) {
163163

164164
final Location location = new Location();
@@ -177,7 +177,7 @@ public static Location jsConstructor(final Context cx, final Scriptable scope,
177177
* @param window the window that this location belongs to
178178
* @param page the page that will become the enclosing page
179179
*/
180-
public void initialize(final Scriptable scope, final Window window, final Page page) {
180+
public void initialize(final VarScope scope, final Window window, final Page page) {
181181
final int attributes = ScriptableObject.PERMANENT | ScriptableObject.READONLY;
182182

183183
FunctionObject functionObject = new FunctionObject(METHOD_ASSIGN.getName(), METHOD_ASSIGN, scope);

src/main/java/org/htmlunit/javascript/host/NativeFunctionPrefixResolver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import org.htmlunit.corejs.javascript.Context;
1818
import org.htmlunit.corejs.javascript.NativeFunction;
19-
import org.htmlunit.corejs.javascript.Scriptable;
19+
import org.htmlunit.corejs.javascript.VarScope;
2020
import org.htmlunit.xpath.xml.utils.PrefixResolver;
2121

2222
/**
@@ -28,15 +28,15 @@
2828
public class NativeFunctionPrefixResolver implements PrefixResolver {
2929

3030
private final NativeFunction resolverFn_;
31-
private final Scriptable scope_;
31+
private final VarScope scope_;
3232

3333
/**
3434
* Constructor.
3535
*
3636
* @param resolverFn the {@link NativeFunction} this resolver is for
3737
* @param scope the scope
3838
*/
39-
public NativeFunctionPrefixResolver(final NativeFunction resolverFn, final Scriptable scope) {
39+
public NativeFunctionPrefixResolver(final NativeFunction resolverFn, final VarScope scope) {
4040
resolverFn_ = resolverFn;
4141
scope_ = scope;
4242
}

src/main/java/org/htmlunit/javascript/host/URLSearchParams.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.htmlunit.corejs.javascript.Scriptable;
3838
import org.htmlunit.corejs.javascript.SymbolKey;
3939
import org.htmlunit.corejs.javascript.TopLevel;
40+
import org.htmlunit.corejs.javascript.VarScope;
4041
import org.htmlunit.javascript.HtmlUnitScriptable;
4142
import org.htmlunit.javascript.JavaScriptEngine;
4243
import org.htmlunit.javascript.configuration.JsxClass;
@@ -103,7 +104,7 @@ public NativeParamsIterator(final String className) {
103104
* @param type the type
104105
* @param iterator the backing iterator
105106
*/
106-
public NativeParamsIterator(final Scriptable scope, final String className, final Type type,
107+
public NativeParamsIterator(final VarScope scope, final String className, final Type type,
107108
final Iterator<NameValuePair> iterator) {
108109
super(scope, URL_SEARCH_PARMS_TAG);
109110
iterator_ = iterator;

src/main/java/org/htmlunit/javascript/host/WebSocket.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public WebSocket() {
103103
* @param scope the scope
104104
* @param window the top level window
105105
*/
106-
private WebSocket(final String url, final Scriptable scope, final Window window) {
106+
private WebSocket(final String url, final VarScope scope, final Window window) {
107107
super();
108108
try {
109109
final WebWindow webWindow = window.getWebWindow();
@@ -249,7 +249,7 @@ public void onWebSocketError(final Throwable cause) {
249249
* @return the java object to allow JavaScript to access
250250
*/
251251
@JsxConstructor
252-
public static Scriptable jsConstructor(final Context cx, final Scriptable scope, final Object[] args,
252+
public static Scriptable jsConstructor(final Context cx, final VarScope scope, final Object[] args,
253253
final Function ctorObj, final boolean inNewExpr) {
254254
if (args.length < 1 || args.length > 2) {
255255
throw JavaScriptEngine

0 commit comments

Comments
 (0)