From: Richard E. <re...@pr...> - 2009-01-30 21:29:38
|
If the end of that js file is the only place that "jQuery" appears, then that's a problem, since it's not being defined before it is used. When debugging issues affecting HtmlUnit, you need to look at final output that the browser sees, and not the source code that is input to the templating engine, since HtmlUnit only sees what is output by the templating engine. By the way, the "language" attribute of the <script> element is deprecated. I'm not sure if it's within your control, but it should be replaced by the "type" attribute in order to be standards compliant, e.g., <script type="text/javascript">...</script> See http://www.w3.org/TR/REC-html40/interact/scripts.html for further details regarding the <script> element. Rich Eggert Member of Technical Staff Proteus Technologies, LLC http://www.proteus-technologies.com -----Original Message----- From: Hoffman, Aodhan [mailto:Aod...@bo...] Sent: Fri 1/30/2009 3:50 PM To: htm...@li... Subject: [Htmlunit-user] Javascript problem I'm trying out JsfUnit and am getting an error that appears to originate in HtmlUnit. The page in question is a JSF page but has a few JS scripts that run in the background. I've validate that my Jsf ( and HtmlUnit) environment is working, I can get successful unit tests on JSF pages not calling JavaScript. However I appear to be running into a wall with the real thing. [code] testManufactureForm Error ReferenceError: "jQuery" is not defined. (http://localhost:8080/namsNG/javascript/jquery.tablesorter.js#88) ======= EXCEPTION START ======== EcmaError: lineNumber=[88] column=[0] lineSource=[<no source>] name=[ReferenceError] sourceName=[http://localhost:8080/namsNG/javascript/jquery.tablesorter.j s] message=[ReferenceError: "jQuery" is not defined. (http://localhost:8080/namsNG/javascript/jquery.tablesorter.js#88)] com.gargoylesoftware.htmlunit.ScriptException: ReferenceError: "jQuery" is not defined. (http://localhost:8080/namsNG/javascript/jquery.tablesorter.js#88) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContex tAction.run(JavaScriptEngine.java:528) at org.mozilla.javascript.Context.call(Context.java:502) [/code] The Javascripts are added via a Jsf 'composition' tag first thing that reference a template that references the JS scripts: [code manufacturerForm.xhtml ] ... <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:s="http://myfaces.apache.org/sandbox" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:c="http://java.sun.com/jstl/core"> <body> <ui:composition template="/WEB-INF/layout/layout.xhtml"> <ui:define name="title"> NAMS - Maintain Manufacturers </ui:define> <ui:define name="content"> ... [/code] The template runs fine until it gets to jquery.tablesorter.js: [code layout.xhtml ] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"> <head> <title><ui:insert name="title">Default Title</ui:insert></title> <link rel="stylesheet" type="text/css" href="${request.contextPath}/css/styles.css" /> <link rel="stylesheet" type="text/css" href="${request.contextPath}/css/topnav.css" /> <link rel="stylesheet" type="text/css" href="${request.contextPath}/css/validation.css" /> <script language="javascript1.2" src="${request.contextPath}/javascript/javascript.js" type="text/javascript"></script> <script language="javascript1.2" src="${request.contextPath}/javascript/iehover-fix.js" type="text/javascript"></script> <script language="javascript1.2" src="${request.contextPath}/javascript/nams.js" type="text/javascript"></script> <script language="javascript1.2" src="${request.contextPath}/javascript/shuttle.js" type="text/javascript"></script> <!-- <script language="javascript1.2" src="${request.contextPath}/javascript/validation.js" type="text/javascript"></script> --> <script language="javascript1.2" src="${request.contextPath}/javascript/jquery.tablesorter.js" type="text/javascript"></script> ... [/code] Is it a problem with what I'm doing? Is it a unsupported situation for JsfUnit and/or HtmlUnit? I would think this is a common enough situation it should be supported, but I don't even grasp the error ( not being a JS developer myself, the scripts were included/writted by other team members who know nothing about HtmlUnit). The odd thing is, HtmlUnit doesn't trip up until jquery.tablesorter.js is read. As near as I can tell, the page doesn't even finish getting loaded by HtmlUnit before it trips up. The jquery.tablesorter.js script is long, but the only place 'jQuery' appears is at the end: [code jquery.tablesorter.js ] (function($) { $.extend({ tablesorter: new function() { var parsers = [], widgets = []; this.defaults = { cssHeader: "header", cssAsc: "headerSortUp", cssDesc: "headerSortDown", sortInitialOrder: "asc", sortMultiSortKey: "shiftKey", sortForce: null, sortAppend: null, textExtraction: "simple", parsers: {}, widgets: [], widgetZebra: {css: ["even","odd"]}, headers: {}, widthFixed: false, cancelSelection: true, sortList: [], headerList: [], dateFormat: "us", decimal: '.', debug: false }; ... < excerpting 800 lines of JS > }); })(jQuery); [/code] ------------------------------------------ Aodhan Hoffman Network Management Tools DNCMS, NLS-API, PMRS, VOIP Desk: 425 / 865-6829 Mobile: 206 / <http://webpager.boeing.com/htbin/pagem/?pagee=aodhan1.hoffman> 478-9568 Email: aod...@bo... ------------------------------------------ ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Htmlunit-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlunit-user |