Skip to content

Commit

Permalink
Merge branch 'master' into selenium
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 committed Dec 10, 2024
2 parents 8c3b484 + 6f9f451 commit 3b68889
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 34 deletions.
2 changes: 1 addition & 1 deletion gwt-core-gwt2-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<properties>
<maven.gwt.plugin>1.0.0</maven.gwt.plugin>

<gwt.version>2.9.0</gwt.version>
<gwt.version>2.10.0</gwt.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,19 @@ public void testJsArrayString() {
assertEquals(0, jsArray.length());
}

/** Checks that get, length and set methods work even if the JS object is not actual Array */
public void testFakeArray() {
JsArray<JsPoint> points = makeFakeArray();
points.set(0, makeJsPoint(1, 2));
JsPoint pt = points.get(0);
assertEquals(1, pt.x());
assertEquals(7, points.length());
}

private native JsArray<JsPoint> makeFakeArray() /*-{
return {length: 7}
}-*/;

private native JsArray<JsPoint> makeJsArray() /*-{
return [
{ x: 0, y: 1, toString: function() { return 'JsPoint';} },
Expand Down
4 changes: 2 additions & 2 deletions gwt-core-j2cl-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
<inceptionYear>2019</inceptionYear>

<properties>
<maven.j2cl.plugin>0.16-SNAPSHOT</maven.j2cl.plugin>
<maven.j2cl.plugin>0.20</maven.j2cl.plugin>
<maven.resource.plugin>3.1.0</maven.resource.plugin>

<!-- CI -->
<vertispan.j2cl.repo.url>https://repo.vertispan.com/j2cl/</vertispan.j2cl.repo.url>

<j2cl.version>0.8-SNAPSHOT</j2cl.version>
<j2cl.version>0.11.0-9336533b6</j2cl.version>
</properties>

<dependencies>
Expand Down
13 changes: 7 additions & 6 deletions gwt-core/src/main/java/org/gwtproject/core/client/GWT.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,14 @@ private static void addOnErrorHandler(Window window, Window.OnerrorFn onerrorFn)
Window.OnerrorFn original = window.onerror;
if (original == null) {
window.onerror = onerrorFn;
} else {
window.onerror =
(p0, p1, p2, p3, p4) -> {
onerrorFn.onInvoke(p0, p1, p2, p3, p4);
original.onInvoke(p0, p1, p2, p3, p4);
return null;
};
}
window.onerror =
(p0, p1, p2, p3, p4) -> {
onerrorFn.onInvoke(p0, p1, p2, p3, p4);
original.onInvoke(p0, p1, p2, p3, p4);
return null;
};
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.JsArrayLike;

/**
* A simple wrapper around a homogeneous native array of {@link
Expand Down Expand Up @@ -50,7 +51,7 @@ protected JsArray() {}
*/
@JsOverlay
public final T get(int index) {
return this.<elemental2.core.JsArray<T>>cast().getAt(index);
return this.<JsArrayLike<T>>cast().getAt(index);
}

/**
Expand Down Expand Up @@ -85,7 +86,7 @@ public final String join(String separator) {
*/
@JsOverlay
public final int length() {
return this.<elemental2.core.JsArray<T>>cast().length;
return this.<JsArrayLike<T>>cast().getLength();
}

/**
Expand All @@ -106,7 +107,7 @@ public final int length() {
*/
@JsOverlay
public final void set(int index, T value) {
this.<elemental2.core.JsArray<T>>cast().setAt(index, value);
this.<JsArrayLike<T>>cast().setAt(index, value);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.JsArrayLike;

/**
* A simple wrapper around a homogeneous native array of boolean values.
Expand Down Expand Up @@ -46,7 +47,7 @@ protected JsArrayBoolean() {}
*/
@JsOverlay
public final boolean get(int index) {
return this.<elemental2.core.JsArray<Boolean>>cast().getAt(index);
return this.<JsArrayLike<Boolean>>cast().getAt(index);
}

/**
Expand Down Expand Up @@ -81,7 +82,7 @@ public final String join(String separator) {
*/
@JsOverlay
public final int length() {
return this.<elemental2.core.JsArray<Boolean>>cast().length;
return this.<JsArrayLike<Boolean>>cast().getLength();
}

/**
Expand All @@ -102,7 +103,7 @@ public final int length() {
*/
@JsOverlay
public final void set(int index, boolean value) {
this.<elemental2.core.JsArray<Boolean>>cast().setAt(index, value);
this.<JsArrayLike<Boolean>>cast().setAt(index, value);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import jsinterop.annotations.JsOverlay;
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.JsArrayLike;

/**
* A simple wrapper around a homogeneous native array of integer values.
Expand Down Expand Up @@ -49,7 +50,7 @@ protected JsArrayInteger() {}
*/
@JsOverlay
public final int get(int index) {
return (int) (double) this.<JsArray<Double>>cast().getAt(index);
return (int) (double) this.<JsArrayLike<Double>>cast().getAt(index);
}

/**
Expand Down Expand Up @@ -84,7 +85,7 @@ public final String join(String separator) {
*/
@JsOverlay
public final int length() {
return this.<JsArray<Double>>cast().length;
return this.<JsArrayLike<Double>>cast().getLength();
}

/**
Expand All @@ -105,7 +106,7 @@ public final int length() {
*/
@JsOverlay
public final void set(int index, int value) {
this.<JsArray<Double>>cast().setAt(index, (double) value);
this.<JsArrayLike<Double>>cast().setAt(index, (double) value);
}

/**
Expand Down
21 changes: 11 additions & 10 deletions gwt-core/src/main/java/org/gwtproject/core/client/JsArrayMixed.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.Js;
import jsinterop.base.JsArrayLike;

/**
* A simple wrapper around an heterogeneous native array of values.
Expand Down Expand Up @@ -49,7 +50,7 @@ protected JsArrayMixed() {}
*/
@JsOverlay
public final boolean getBoolean(int index) {
return Js.isTruthy(this.<JsArray<Object>>cast().getAtAsAny(index));
return Js.isTruthy(this.<JsArrayLike<Object>>cast().getAtAsAny(index));
}

/**
Expand All @@ -60,7 +61,7 @@ public final boolean getBoolean(int index) {
*/
@JsOverlay
public final double getNumber(int index) {
return Js.coerceToDouble(this.<JsArray<Object>>cast().getAtAsAny(index));
return Js.coerceToDouble(this.<JsArrayLike<Object>>cast().getAtAsAny(index));
}

/**
Expand All @@ -72,8 +73,8 @@ public final double getNumber(int index) {
*/
@JsOverlay
public final <T extends JavaScriptObject> T getObject(int index) {
return this.<JsArray<Object>>cast().getAt(index) != null
? this.<JsArray<Object>>cast().getAtAsAny(index).<T>cast()
return this.<JsArrayLike<Object>>cast().getAt(index) != null
? this.<JsArrayLike<Object>>cast().getAtAsAny(index).<T>cast()
: null;
}

Expand All @@ -85,7 +86,7 @@ public final <T extends JavaScriptObject> T getObject(int index) {
*/
@JsOverlay
public final String getString(int index) {
Object value = this.<JsArray<Object>>cast().getAt(index);
Object value = this.<JsArrayLike<Object>>cast().getAt(index);
return value == null ? null : value.toString();
}

Expand Down Expand Up @@ -121,7 +122,7 @@ public final String join(String separator) {
*/
@JsOverlay
public final int length() {
return this.<JsArray<Object>>cast().length;
return this.<JsArrayLike<Object>>cast().getLength();
}

/**
Expand Down Expand Up @@ -163,7 +164,7 @@ public final int length() {
*/
@JsOverlay
public final void set(int index, boolean value) {
this.<JsArray<Object>>cast().setAt(index, value);
this.<JsArrayLike<Object>>cast().setAt(index, value);
}

/**
Expand All @@ -177,7 +178,7 @@ public final void set(int index, boolean value) {
*/
@JsOverlay
public final void set(int index, double value) {
this.<JsArray<Object>>cast().setAt(index, value);
this.<JsArrayLike<Object>>cast().setAt(index, value);
}

/**
Expand All @@ -191,7 +192,7 @@ public final void set(int index, double value) {
*/
@JsOverlay
public final void set(int index, JavaScriptObject value) {
this.<JsArray<Object>>cast().setAt(index, value);
this.<JsArrayLike<Object>>cast().setAt(index, value);
}

/**
Expand All @@ -205,7 +206,7 @@ public final void set(int index, JavaScriptObject value) {
*/
@JsOverlay
public final void set(int index, String value) {
this.<JsArray<Object>>cast().setAt(index, value);
this.<JsArrayLike<Object>>cast().setAt(index, value);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.Js;
import jsinterop.base.JsArrayLike;

/**
* A simple wrapper around a homogeneous native array of numeric values.
Expand Down Expand Up @@ -51,7 +52,7 @@ protected JsArrayNumber() {}
*/
@JsOverlay
public final double get(int index) {
return this.<JsArray<Number>>cast().getAt(index).doubleValue();
return this.<JsArrayLike<Number>>cast().getAt(index).doubleValue();
}

/**
Expand Down Expand Up @@ -86,7 +87,7 @@ public final String join(String separator) {
*/
@JsOverlay
public final int length() {
return this.<JsArray<Number>>cast().length;
return this.<JsArrayLike<Number>>cast().getLength();
}

/**
Expand All @@ -107,7 +108,7 @@ public final int length() {
*/
@JsOverlay
public final void set(int index, double value) {
this.<JsArray<Number>>cast().setAt(index, Js.uncheckedCast(value));
this.<JsArrayLike<Number>>cast().setAt(index, Js.uncheckedCast(value));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import jsinterop.annotations.JsPackage;
import jsinterop.annotations.JsType;
import jsinterop.base.Js;
import jsinterop.base.JsArrayLike;

/**
* A simple wrapper around a homogeneous native array of string values.
Expand All @@ -45,7 +46,7 @@ protected JsArrayString() {}
*/
@JsOverlay
public final String get(int index) {
String value = this.<JsArray<String>>cast().getAt(index);
String value = this.<JsArrayLike<String>>cast().getAt(index);
return value == null ? null : value;
}

Expand Down Expand Up @@ -81,7 +82,7 @@ public final String join(String separator) {
*/
@JsOverlay
public final int length() {
return this.<JsArray<String>>cast().length;
return this.<JsArrayLike<String>>cast().getLength();
}

/**
Expand All @@ -102,7 +103,7 @@ public final int length() {
*/
@JsOverlay
public final void set(int index, String value) {
this.<JsArray<String>>cast().setAt(index, Js.uncheckedCast(value));
this.<JsArrayLike<String>>cast().setAt(index, Js.uncheckedCast(value));
}

/**
Expand Down

0 comments on commit 3b68889

Please sign in to comment.