Prev |  | Next

## 4.9. Comparing JavaScript

Two PDF documents can have the “same” JavaScript. The comparison is done byte-wise using the method `haveSameJavaScript()`. Whitespaces are ignored.

    @Test
    public void haveSameJavaScript() throws Exception {
      String filenameTest = "documentUnderTest.pdf";
      String filenameReference = "reference.pdf";

      AssertThat.document(filenameTest)
                .and(filenameReference)
                .haveSameJavaScript()
      ;
    }

If you want to see the JavaScript code, you can extract it with the utility `ExtractJavaScript` as described in chapter 9.8: “Extract JavaScript to a Text File”.

Prev | Up | Next
4.8. Comparing Images | Home | 4.10. Comparing Layout as Rendered Pages