title: HtmlUnit Javascript Error
body: <p>I am trying to emulate pressing a JS "Continue" button (using HtmlUnit) which submits a hidden form, and then retrieve the HTML/XML source of the page after submitting the form. On a regular browser, the button appears after a 1 second delay (replacing some text). However, upon loading the page in HtmlUnit I receive a Javascript error. </p>
  
  <p>The link is safe if you would like to click it yourself, however it contains a bunch of ads, or you can view-source: to view the source.
  The JavaScript script ca be found here: <a href="http://ajax.cloudflare.com/cdn-cgi/nexp/dokv=97fb4d042e/cloudflare.min.js#3" rel="nofollow">http://ajax.cloudflare.com/cdn-cgi/nexp/dokv=97fb4d042e/cloudflare.min.js#3</a></p>
  
  
  
  <pre class="lang-java prettyprint-override"><code>    String link = "http://www.firedrive.com/file/A550ECCE9DF21DB6";
      final WebClient webClient = new WebClient(BrowserVersion.CHROME);
  
      //webClient.getOptions().setJavaScriptEnabled(false);
      final HtmlPage page1 = webClient.getPage(link);
  
      List&lt;HtmlForm&gt; forms = page1.getForms();
  
      final HtmlForm form = forms.get(1);
      final HtmlHiddenInput button = form.getInputByName("confirm");
      final HtmlPage page2 = button.click();
  
      System.out.println(page2.asXml());
      webClient.closeAllWindows();
  </code></pre>
  
  <p>However the following error appears, regarding the server's JS script:</p>
  
  <pre class="lang-java prettyprint-override"><code>======= EXCEPTION START ========
  Exception class=[net.sourceforge.htmlunit.corejs.javascript.WrappedException]
  com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot find function stopPropagation in object [object MessageEvent]. (http://ajax.cloudflare.com/cdn-cgi/nexp/dokv=97fb4d042e/cloudflare.min.js#3)
      at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:705)
      at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:620)
      at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:513)
      at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:591)
      at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:566)
      at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:975)
      at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:349)
      at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:409)
      at com.gargoylesoftware.htmlunit.html.HtmlScript$3.execute(HtmlScript.java:274)
      at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:288)
      at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:741)
      at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
      at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:701)
      at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1170)
      at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1072)
      at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206)
      at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:330)
      at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3126)
      at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2093)
      at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:920)
      at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499)
      at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452)
      at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
      at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:965)
      at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:247)
      at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:193)
      at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:268)
      at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:156)
      at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:468)
      at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:342)
      at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:407)
      at com.gargoylesoftware.htmlunit.WebClient.getPage(WebClient.java:392)
      at TestClass.submittingForm(TestClass.java:23)
      at TestClass.main(TestClass.java:39)
  
  
   == CALLING JAVASCRIPT ==
  
    function (b) {
        var c = b.source;
        c !== a &amp;&amp; null !== c || "cf-tick" !== b.data || (b.stopPropagation(), d.length &gt; 0 &amp;&amp; d.shift()());
    }
  
  ======= EXCEPTION END ========
  ======= EXCEPTION END ========
  ======= EXCEPTION END ========
  </code></pre>
  
  <p>And I am also receiving several Warnings regarding cookies:</p>
  
  <pre class="lang-java prettyprint-override"><code>Jul 19, 2014 10:52:35 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies
  WARNING: Cookie rejected [lang="en", version:0, domain:., path:/, expiry:null] Illegal domain attribute "". Domain of origin: "www.firedrive.com"
  Jul 19, 2014 10:52:35 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies
  WARNING: Cookie rejected [lang="en", version:0, domain:., path:/, expiry:null] Illegal domain attribute "". Domain of origin: "www.firedrive.com"
  Jul 19, 2014 10:52:35 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies
  WARNING: Cookie rejected [lang="en", version:0, domain:., path:/, expiry:null] Illegal domain attribute "". Domain of origin: "www.firedrive.com"
  Jul 19, 2014 10:52:35 AM org.apache.http.client.protocol.ResponseProcessCookies processCookies
  WARNING: Cookie rejected [lang="en", version:0, domain:., path:/, expiry:null] Illegal domain attribute "". Domain of origin: "www.firedrive.com"
  </code></pre>
  
  <p>Editing JavaScript is not an option as I have no access to the host.</p>
  
  <p>Any ideas/links are much appreciated, thanks!</p>