galenframework/galen

Issue while resizing Screenshot

Opened this issue · 0 comments

Hi, I found small while testing on an older Firefox version (ver. 10 ESR):

While doing a pageDump the Method resizeScreenshotIfNeeded is called.
It runs some JS-Code, which gets the window.devicePixelRatio from the browser, however this feature isn't implemented in older Firefox versions so the value isn't set. The JS-Code checks for undefined and null but the tested Firefox version sets it to NaN, which causes an Nullpointer in the Code when calling the .double() method on the result.

Simply extending the the JS-Code by a !isNaN(pr) fixes the problem. Everything else runs just fine afterwards.

 public static final String JS_RETRIEVE_DEVICE_PIXEL_RATIO =
             "window.devicePixelRatio = window.devicePixelRatio || " +
             "window.screen.deviceXDPI / window.screen.logicalXDPI; " +
             "var pr = window.devicePixelRatio; if (pr != undefined && pr != null && !isNaN(pr))" + 
             "return pr; else return 1.0;"; 

Class: GalenUtils
Method: resizeScreenshotIfNeeded(Webdriver, BufferedImage)
Field (static class variable): JS_RETRIEVE_DEVICE_PIXEL_RATIO