ANSWER: do not initialize your HtmlUnit WebClient like this: new WebClient(); instead, initialize it like this: new WebClient(BrowserVersion.FIREFOX_38);The default "browser" that the HtmlUnit WebClient gives you does not have some of the basic JavaScript functions available to call such as "addEventListener".
See also: HtmlUnit issue tracker non-issue 1615.