Menu

#1919 js_fonts not returning anything thus resulting has_lied_languages = true

2.27
closed
RBRi
None
1
2019-03-07
2017-09-11
arya
No

I'm testing HTMLUnit with a fingerprinting website and it returns has_lied_languages = true and js_fonts also contains no fonts which is probably the reason for has_lied_languages being true.

I have put the fingerprinting page here, if you access it by Google Chrome you will see that js_fonts has some fonts in front of it.

http://45.33.94.30/test.html

But if you access it with HtmlUnit, js_fonts is blank and has_lied_languages = false

try {
    BrowserVersion bv = BrowserVersion.CHROME;

    webClient = new WebClient(bv);
    webClient.getOptions().setTimeout(900000);
    webClient.getOptions().setJavaScriptEnabled(true);

    webClient.getOptions().setThrowExceptionOnScriptError(false);
    webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
    webClient.setCssErrorHandler(new SilentCssErrorHandler());
    webClient.getCache().setMaxSize(0);

    LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
            "org.apache.commons.logging.impl.NoOpLog");
    java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
    java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(Level.OFF);
    java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.javascript.StrictErrorReporter")
            .setLevel(Level.OFF);
    java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.javascript.host.ActiveXObject")
            .setLevel(Level.OFF);
    java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument")
            .setLevel(Level.OFF);
    java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.html.HtmlScript").setLevel(Level.OFF);
    java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit.javascript.host.WindowProxy")
            .setLevel(Level.OFF);
    java.util.logging.Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);
    java.util.logging.Logger.getLogger("org.apache").setLevel(Level.OFF);

    HtmlPage htmlPage = webClient.getPage("http://45.33.94.30/test.html");
    Thread.sleep(9000);

    htmlPage.save(new File("result.html"));
    webClient.close();
} catch (Exception e) {
    e.printStackTrace();
}

Discussion

  • RBRi

    RBRi - 2017-09-12
    • status: open --> accepted
    • assigned_to: RBRi
     
  • RBRi

    RBRi - 2017-09-12

    As far as i can see this is because HtmlUnit is a headless browser. Instead of doing real page layouting we are doing some estimations. For your sample the offsetWidth property ignores the font face.

    Testcase: com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement2Test.offsetWidth_spanWithDiffernetFonts()

     
  • arya

    arya - 2017-09-12

    Is there a way to simulate it? By manually setting a list of js_fonts?

     
  • arya

    arya - 2017-09-28

    I just tried the latest build and I see that has_lied_languages now returns false, but has_lied_browser returns true. The reason for this is ProductSub, I manually changed the getProductSub() in Navigator.java to what Google Chrome returns and that solved the issue.

     
  • RBRi

    RBRi - 2017-10-10

    getProductSub is now fixed

     

    Last edit: RBRi 2017-10-15
  • RBRi

    RBRi - 2019-03-07

    Will close this, i guess we have fixed what is possible with a headless browser.

     
  • RBRi

    RBRi - 2019-03-07
    • status: accepted --> closed
     

Log in to post a comment.