JDK-8087682 : Web unit test testDOMWindowAndStyleAccess gets NPE in Utils.getScreen
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 8u60
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2015-05-12
  • Updated: 2020-04-03
  • Resolved: 2020-04-03
Related Reports
Duplicate :  
Relates :  
Description
The web unit tests now run in headless mode to support running them on our headless test machines -- see RT-40716. This results in the following exception in DOMTest.testDOMWindowAndStyleAccess, although the test still passes:

javafx.scene.web.DOMTest > testDOMWindowAndStyleAccess STANDARD_ERROR
    java.lang.NullPointerException
    	at com.sun.javafx.util.Utils.getScreen(Utils.java:687)
    	at com.sun.javafx.webkit.WebPageClientImpl.getScreenBounds(WebPageClientImpl.java:110)
    	at com.sun.webkit.WCWidget.fwkGetScreenRect(WCWidget.java:118)
    	at com.sun.webkit.dom.DOMWindowImpl.resizeByImpl(Native Method)
    	at com.sun.webkit.dom.DOMWindowImpl.resizeBy(DOMWindowImpl.java:1151)
    	at javafx.scene.web.DOMTest.lambda$testDOMWindowAndStyleAccess$49(DOMTest.java:344)
    	at javafx.scene.web.DOMTest$$Lambda$246/30864552.run(Unknown Source)
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    	at com.sun.javafx.application.PlatformImpl.lambda$null$171(PlatformImpl.java:295)
    	at com.sun.javafx.application.PlatformImpl$$Lambda$52/19305760.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at com.sun.javafx.application.PlatformImpl.lambda$runLater$172(PlatformImpl.java:294)
    	at com.sun.javafx.application.PlatformImpl$$Lambda$51/9075867.run(Unknown Source)
    	at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
    	at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
    	at java.lang.Thread.run(Thread.java:744)

Comments
I happened to see this old bug and we no longer see this problem. It is almost certainly as a duplicate of JDK-8087438, so I'm closing it as such.
03-04-2020

The problem is that Utils.getBounds(Object obj) returns null for WebView in Headless mode. The code is this: Node n = (Node)obj; return n.localToScreen(n.getLayoutBounds()); So, n.localToScreen must be returning null (I didn't debug it). Is that ok? Should it return new BoundingBox(0, 0, 0, 0) instead (just like in the default case of Utils.getBounds)? Or should it be fixed to return non-null value?
13-05-2015