-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
jfx11, 8u271, jfx15, jfx16
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
Linux x86_64 / Ubuntu Mate 21.04 / openJDK 16.0.1
The problem has been around since at least Java 12/JavaFX 12 and is also present on Windows 7 and 10 x86_64.
A DESCRIPTION OF THE PROBLEM :
JavaScript instanceof is not evaluated correctly for subclasses of Event in the JavaFX WebView.
The submitted example HTML behaves as expected on e.g. Chrome, Opera, Firefox, Edge.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create an HTML file with embedded or imported JavaScript.
Create a subclass of Event within a script tag in the HTML file. Create an instance of the class and use instanceof on it.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The instanceof operator should return true.
ACTUAL -
The instanceof operator returns false.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class Demo extends Application {
@Override
public void start(final Stage stage) throws Exception {
final var view = new WebView();
final var scene = new Scene(view);
stage.setWidth(800);
stage.setHeight(600);
stage.setScene(scene);
stage.show();
final var content =
"""
<!DOCTYPE html>
<html>
<body>
<script>
class B extends Event {
this(type) {
this.type = type;
}
}
const myObject = new B("type");
const p = document.createElement("p");
const text = `myObject is instanceof B: ${myObject instanceof B}`;
p.textContent = text;
document.body.appendChild(p);
</script>
</body>
</html>
""";
view.getEngine().loadContent(content);
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
FREQUENCY : always
Linux x86_64 / Ubuntu Mate 21.04 / openJDK 16.0.1
The problem has been around since at least Java 12/JavaFX 12 and is also present on Windows 7 and 10 x86_64.
A DESCRIPTION OF THE PROBLEM :
JavaScript instanceof is not evaluated correctly for subclasses of Event in the JavaFX WebView.
The submitted example HTML behaves as expected on e.g. Chrome, Opera, Firefox, Edge.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Create an HTML file with embedded or imported JavaScript.
Create a subclass of Event within a script tag in the HTML file. Create an instance of the class and use instanceof on it.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The instanceof operator should return true.
ACTUAL -
The instanceof operator returns false.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
public class Demo extends Application {
@Override
public void start(final Stage stage) throws Exception {
final var view = new WebView();
final var scene = new Scene(view);
stage.setWidth(800);
stage.setHeight(600);
stage.setScene(scene);
stage.show();
final var content =
"""
<!DOCTYPE html>
<html>
<body>
<script>
class B extends Event {
this(type) {
this.type = type;
}
}
const myObject = new B("type");
const p = document.createElement("p");
const text = `myObject is instanceof B: ${myObject instanceof B}`;
p.textContent = text;
document.body.appendChild(p);
</script>
</body>
</html>
""";
view.getEngine().loadContent(content);
}
public static void main(String[] args) {
launch(args);
}
}
---------- END SOURCE ----------
FREQUENCY : always
- duplicates
-
JDK-8259635 Update to 610.2 version of WebKit
- Resolved