You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(10) |
Aug
(30) |
Sep
(15) |
Oct
(26) |
Nov
(12) |
Dec
(17) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(7) |
Feb
(27) |
Mar
(73) |
Apr
(17) |
May
(17) |
Jun
(78) |
Jul
(67) |
Aug
(60) |
Sep
(89) |
Oct
(140) |
Nov
(173) |
Dec
(46) |
2004 |
Jan
(39) |
Feb
(7) |
Mar
(21) |
Apr
(31) |
May
(13) |
Jun
(86) |
Jul
(14) |
Aug
(14) |
Sep
(53) |
Oct
(184) |
Nov
(186) |
Dec
(319) |
2005 |
Jan
(336) |
Feb
(274) |
Mar
(226) |
Apr
(102) |
May
(196) |
Jun
(130) |
Jul
(119) |
Aug
(143) |
Sep
(76) |
Oct
(85) |
Nov
(70) |
Dec
(159) |
2006 |
Jan
(125) |
Feb
(100) |
Mar
(80) |
Apr
(39) |
May
(55) |
Jun
(58) |
Jul
(50) |
Aug
(76) |
Sep
(55) |
Oct
(101) |
Nov
(163) |
Dec
(85) |
2007 |
Jan
(56) |
Feb
(53) |
Mar
(180) |
Apr
(221) |
May
(290) |
Jun
(199) |
Jul
(322) |
Aug
(515) |
Sep
(121) |
Oct
(297) |
Nov
(177) |
Dec
(103) |
2008 |
Jan
(516) |
Feb
(315) |
Mar
(586) |
Apr
(615) |
May
(197) |
Jun
(381) |
Jul
(390) |
Aug
(195) |
Sep
(603) |
Oct
(499) |
Nov
(622) |
Dec
(350) |
2009 |
Jan
(313) |
Feb
(338) |
Mar
(507) |
Apr
(317) |
May
(197) |
Jun
(375) |
Jul
(235) |
Aug
(424) |
Sep
(410) |
Oct
(338) |
Nov
(286) |
Dec
(306) |
2010 |
Jan
(367) |
Feb
(339) |
Mar
(371) |
Apr
(172) |
May
(233) |
Jun
(264) |
Jul
(421) |
Aug
(110) |
Sep
(218) |
Oct
(189) |
Nov
(185) |
Dec
(168) |
2011 |
Jan
(145) |
Feb
(213) |
Mar
(205) |
Apr
(64) |
May
(159) |
Jun
(67) |
Jul
(104) |
Aug
(126) |
Sep
(144) |
Oct
(106) |
Nov
(154) |
Dec
(225) |
2012 |
Jan
(111) |
Feb
(87) |
Mar
(131) |
Apr
(102) |
May
(180) |
Jun
(160) |
Jul
(412) |
Aug
(315) |
Sep
(311) |
Oct
(369) |
Nov
(464) |
Dec
(284) |
2013 |
Jan
(343) |
Feb
(165) |
Mar
(174) |
Apr
(120) |
May
(153) |
Jun
(134) |
Jul
(202) |
Aug
(105) |
Sep
(228) |
Oct
(332) |
Nov
(192) |
Dec
(219) |
2014 |
Jan
(348) |
Feb
(194) |
Mar
(189) |
Apr
(188) |
May
(297) |
Jun
(206) |
Jul
(79) |
Aug
(279) |
Sep
(111) |
Oct
(159) |
Nov
(61) |
Dec
(78) |
2015 |
Jan
(152) |
Feb
(145) |
Mar
(239) |
Apr
(223) |
May
(248) |
Jun
(296) |
Jul
(172) |
Aug
(189) |
Sep
(338) |
Oct
(217) |
Nov
(131) |
Dec
(184) |
2016 |
Jan
(118) |
Feb
(221) |
Mar
(414) |
Apr
(412) |
May
(303) |
Jun
(133) |
Jul
(129) |
Aug
(121) |
Sep
(136) |
Oct
(67) |
Nov
(89) |
Dec
(245) |
2017 |
Jan
(349) |
Feb
(90) |
Mar
(328) |
Apr
(430) |
May
(284) |
Jun
(199) |
Jul
(164) |
Aug
(120) |
Sep
(57) |
Oct
(105) |
Nov
(108) |
Dec
(146) |
2018 |
Jan
(85) |
Feb
(48) |
Mar
(97) |
Apr
(62) |
May
(64) |
Jun
(136) |
Jul
(123) |
Aug
(87) |
Sep
(17) |
Oct
(27) |
Nov
(9) |
Dec
(16) |
2019 |
Jan
(9) |
Feb
(17) |
Mar
(18) |
Apr
(14) |
May
(8) |
Jun
|
Jul
(6) |
Aug
(12) |
Sep
(5) |
Oct
|
Nov
(2) |
Dec
|
2020 |
Jan
(8) |
Feb
|
Mar
(6) |
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
(4) |
Oct
(1) |
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(4) |
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2023 |
Jan
|
Feb
(6) |
Mar
(9) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <no...@us...> - 2003-06-23 14:27:37
|
Log Message: ----------- Fix for bug 759217:HtmlTextArea use HtmlNode for setText Patch submitted by Barnaby Court Modified Files: -------------- /cvsroot/htmlunit/htmlunit/src/xdocs: changes.xml todo.xml /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html: HtmlTextArea.java Revision Data ------------- Index: changes.xml =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/xdocs/changes.xml,v retrieving revision 1.109 retrieving revision 1.110 diff -u -d -r1.109 -r1.110 --- changes.xml 20 Jun 2003 17:38:37 -0000 1.109 +++ changes.xml 23 Jun 2003 14:27:33 -0000 1.110 @@ -115,8 +115,12 @@ Added instructions for the "how to compile from cvs" document. Patch provided by Barnaby Court. </action> + <action type="update" dev="mbowler" due-to="Barnaby Court" id="759217"> + Changed HtmlTextArea.setText() to actually modify the DOM + Patch provided by Barnaby Court. + </action> </release> - </body> + </body> <body> Index: todo.xml =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/xdocs/todo.xml,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- todo.xml 11 Apr 2003 19:29:18 -0000 1.7 +++ todo.xml 23 Jun 2003 14:27:34 -0000 1.8 @@ -4,6 +4,7 @@ <properties> <title>TODO list</title> <author email="mb...@Ga...">Mike Bowler</author> + <author email="Bar...@us...">BarnabyCourt</author> <revision>$Revision$</revision> </properties> @@ -21,7 +22,6 @@ <ol> <li>implement Document.write()</li> <li>Have TopLevelWindow's deregister themselves with WebClient when they are closed</li> - <li>HtmlTextArea.getText() and setText() currently don't modify the dom. This should be fixed</li> <li>Support for file urls</li> <li>Use HtmlUnit to verify all links in generated documentation</li> </ol> Index: HtmlTextArea.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlTextArea.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- HtmlTextArea.java 10 Jun 2003 11:56:58 -0000 1.10 +++ HtmlTextArea.java 23 Jun 2003 14:27:34 -0000 1.11 @@ -37,16 +37,19 @@ */ package com.gargoylesoftware.htmlunit.html; +import org.apache.html.dom.HTMLTextAreaElementImpl; +import org.w3c.dom.Element; + import com.gargoylesoftware.htmlunit.Assert; import com.gargoylesoftware.htmlunit.KeyValuePair; -import org.w3c.dom.Element; /** * Wrapper for the html element "textarea" * * @version $Revision$ * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> - */ + * @author <a href="mailto:Bar...@us...">Barnaby Court</a> + */ public class HtmlTextArea extends HtmlElement implements SubmittableElement { @@ -61,6 +64,7 @@ */ HtmlTextArea( final HtmlPage page, final Element element ) { super( page, element ); + value_ = getText(); } @@ -81,12 +85,8 @@ * @return The text */ public final String getText() { - if( value_ == null ) { - return asText(); - } - else { - return value_; - } + HTMLTextAreaElementImpl textElement = (HTMLTextAreaElementImpl) getElement(); + return textElement.getTextContent(); } @@ -114,7 +114,9 @@ */ public final void setText( final String newValue ) { Assert.notNull("newValue", newValue); - value_ = newValue; + + HTMLTextAreaElementImpl textElement = (HTMLTextAreaElementImpl) getElement(); + textElement.setTextContent(newValue); } @@ -136,7 +138,7 @@ * Return the value of this element to what it was at the time the page was loaded. */ public void reset() { - value_ = null; + setText(value_); } |
From: SourceForge.net <no...@so...> - 2003-06-23 13:31:00
|
Patches item #759217, was opened at 2003-06-23 09:30 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448268&aid=759217&group_id=47038 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Barnaby Court (barnabycourt) Assigned to: Nobody/Anonymous (nobody) Summary: HtmlTextArea use HtmlNode for setText Initial Comment: HtmlTextArea.getText() and setText() currently don't modify the dom. This patch fixes this issue. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448268&aid=759217&group_id=47038 |
From: Mike B. <mb...@Ga...> - 2003-06-23 00:54:18
|
Rahul Joshi wrote: > Hi, > I am new to Html Unit. Could anyone guide me as how should I go > about testing a menu that opens up when i click a link in my html > page. The menu is implemented in a javascript. If you could give more details then perhaps someone can help. What exactly are you trying to test? What condition are you looking for in your test? -- Mike Bowler Principal, Gargoyle Software Inc. Voice: (416) 822-0973 | Email : mb...@Ga... Fax : (416) 822-0975 | Website: http://www.GargoyleSoftware.com |
From: Christian S. <chr...@ne...> - 2003-06-21 14:35:14
|
Mike Bowler wrote: > > has anybody ever considered implementing a dedicated HTML DOM for use > > with HtmlUnit? > > Perhaps I'm just slow today but I'm not exactly sure what you're > proposing. Could you elaborate a bit on this with some specifics? > > Part of what confuses me is the reference to two DOM's. There are three > hierarchies (HtmlElement, Element, SimpleScriptable) but only one of > them is a DOM. I was using the term DOM a bit loosely - i.e. not in the strict sense of org.w3c.dom.*. I was referring to the HtmlElement and Element hierarchies. Basically, every Element gets a corresponding HtlmElement (lazily created). It seems combining in one Hierarchy these would yield great benefit. Christian |
From: johanholtman <j.h...@so...> - 2003-06-21 08:25:18
|
Hi, In the "host.Window" object code I see that the "setInterval()" method was coded but not working yet. So it is commented out. What are the problems with the currently commented solution: (1) That the result is not used? If we use the Result and have it change the page to the webClient only if there was a page change? Is that enough? (2) Is the setInterval to be working on the window level or on page level? If the page is unloaded the setInterval timer is to be stopped? Before experimenting as a newbie to this code, I would like to have some input from those understanding the code. Greetings, Johan |
From: Rahul J. <rah...@sp...> - 2003-06-20 20:38:19
|
Hi, I am new to Html Unit. Could anyone guide me as how should I go about testing a menu that opens up when i click a link in my html page. The menu is implemented in a javascript.=20 Thanking you. -Rahul |
From: johanholtman <j.h...@so...> - 2003-06-20 18:40:55
|
Hi, I posted the "bug" about the frameset: # 753776. I'm new to the HtmlUnit software, dived into a bit, and saw a few things that may help solving this problemen. Can anyone verify this? I added a simple HTML example (in the bug spec) so the reproduction is easy. As far as I can see in the HtmlAnchor object code is that the TARGET attribute value is not used in the click(). I think the target should influence the currentWebWindow, because that's the window that will be refreshed. Does this help in the HtmlAnchor.click(): 0. save the old frame: previousWebWindow = webWindow // see point 4 1. retrieval of the target webwindow via the frame name: wc = webClient.getWebWindowByName( targetName) 2. setting the current webwindow: webClient.setCurrentWindow( wc) 3. doing the rest of the click() 4. in the Webclient on line 317 could the oldPage be retrieved from the previousWebWindow (point 0). NOTICE: The same applies with an enclosing base/target tag. I think the target attribute of the base-tag is not used in the HtmlAnchor.click(). This could be done by checking within the HtmlAnchor object if it has a parent DOM object being a HtmlBase object with a specific target. |
From: SourceForge.net <no...@so...> - 2003-06-20 17:40:15
|
Patches item #757873, was opened at 2003-06-20 09:18 Message generated for change (Comment added) made by mbowler You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448268&aid=757873&group_id=47038 Category: None Group: None >Status: Closed >Resolution: Fixed Priority: 5 Submitted By: Barnaby Court (barnabycourt) >Assigned to: Mike Bowler (mbowler) Summary: Update CVS Building instructions Initial Comment: The current instructions for building HtmlUnit from CVS do not include the "ant initialize" task. Without this task the build fails. This patch adds information about this task to the instructions for building HtmlUnit from CVS. ---------------------------------------------------------------------- >Comment By: Mike Bowler (mbowler) Date: 2003-06-20 13:40 Message: Logged In: YES user_id=46756 Patch applied - thanks ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448268&aid=757873&group_id=47038 |
From: <no...@us...> - 2003-06-20 17:38:39
|
Log Message: ----------- Added instructions about getting dependant jar files Modified Files: -------------- /cvsroot/htmlunit/htmlunit/src/xdocs: buildingFromCvs.xml changes.xml Revision Data ------------- Index: buildingFromCvs.xml =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/xdocs/buildingFromCvs.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- buildingFromCvs.xml 11 Apr 2003 19:29:15 -0000 1.5 +++ buildingFromCvs.xml 20 Jun 2003 17:38:37 -0000 1.6 @@ -4,6 +4,7 @@ <properties> <title>Building HtmlUnit from CVS</title> <author email="mb...@Ga...">Mike Bowler</author> + <author email="Bar...@us...">BarnabyCourt</author> <revision>$Revision$</revision> </properties> @@ -38,7 +39,11 @@ <p> Make sure that you have <a href="http://jakarta.apache.org/ant">Ant</a> 1.5 installed. The build.xml file is located in the root of the src directory so change to that - directory and execute the following command + directory and execute the following commands + </p> + <source>ant initialize</source> + <p> + This will get the libraries needed to build that are not in the CVS repository. </p> <source>ant cleancompile</source> <p> Index: changes.xml =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/xdocs/changes.xml,v retrieving revision 1.108 retrieving revision 1.109 diff -u -d -r1.108 -r1.109 --- changes.xml 30 May 2003 19:22:18 -0000 1.108 +++ changes.xml 20 Jun 2003 17:38:37 -0000 1.109 @@ -107,6 +107,14 @@ both allow the form to be submitted no matter what is returned from Input.onclick. </action> + <action type="update" dev="mbowler" due-to="Barnaby Court"> + Moved all logic from the HtmlInput subclasses up into HtmlInput itself. + Patch provided by Barnaby Court. + </action> + <action type="update" dev="mbowler" due-to="Barnaby Court"> + Added instructions for the "how to compile from cvs" document. + Patch provided by Barnaby Court. + </action> </release> </body> |
From: Mike B. <mb...@Ga...> - 2003-06-20 15:02:25
|
> has anybody ever considered implementing a dedicated HTML DOM for use > with HtmlUnit? Perhaps I'm just slow today but I'm not exactly sure what you're proposing. Could you elaborate a bit on this with some specifics? Part of what confuses me is the reference to two DOM's. There are three hierarchies (HtmlElement, Element, SimpleScriptable) but only one of them is a DOM. > I am considering to use HU in a load test scenario - thats why I am > concerned about performance. I realize this may not be the case with > many others. I *do* use HtmlUnit for load testing and yes, there are performance problems although I suspect that these are due more to poor memory usage than anything else. I get OutOfMemoryError's regularly when stress testing and this is a problem I've been trying to isolate. -- Mike Bowler Principal, Gargoyle Software Inc. Voice: (416) 822-0973 | Email : mb...@Ga... Fax : (416) 822-0975 | Website: http://www.GargoyleSoftware.com |
From: Christian S. <chr...@ne...> - 2003-06-20 13:59:01
|
Hello, has anybody ever considered implementing a dedicated HTML DOM for use with HtmlUnit? Right now HU uses Xerces/Neko to parse the input and create an internal DOM. However, that DOM is only used by HtmlUnit to lookup structural information. Additionally, a parallel DOM is maintained that keeps the extra information required by Htmlunit, and there is a constant mapping between the two. Heres what I find: 1. theres no need to let Xerces create a HTML DOM, as it currently does. It would suffice to use a simple XML DOM, because that is all HtmlUnit requires (and uses). This would improve effciency during parsing, and could be achieved by configuring Neko accordingly. 2. there would be a really significant performance improvement, and simplification of the code, if the 2 DOMs would be unified into one. Basically this would require implementing the whole DOM interface in HtmlUnit - which isnt that hard. I am considering to use HU in a load test scenario - thats why I am concerned about performance. I realize this may not be the case with many others. comments? Christian |
From: SourceForge.net <no...@so...> - 2003-06-20 13:21:36
|
Bugs item #757225, was opened at 2003-06-19 09:33 Message generated for change (Comment added) made by barnabycourt You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=757225&group_id=47038 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Barnaby Court (barnabycourt) Assigned to: Nobody/Anonymous (nobody) Summary: Javascript: Support changing the TYPE,ID and NAME attributes Initial Comment: Add support for changing the type of INPUT elments and the ID and NAME of all html elements through javascript. Attached is a test case for the desired functionality. ---------------------------------------------------------------------- >Comment By: Barnaby Court (barnabycourt) Date: 2003-06-20 09:21 Message: Logged In: YES user_id=591975 Tha attached patch adds the methods needed to support this functionality. For some reason not all the methods are getting called. Perhaps someone could take a look at the patch and see why. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=757225&group_id=47038 |
From: SourceForge.net <no...@so...> - 2003-06-20 13:18:43
|
Patches item #757873, was opened at 2003-06-20 09:18 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448268&aid=757873&group_id=47038 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Barnaby Court (barnabycourt) Assigned to: Nobody/Anonymous (nobody) Summary: Update CVS Building instructions Initial Comment: The current instructions for building HtmlUnit from CVS do not include the "ant initialize" task. Without this task the build fails. This patch adds information about this task to the instructions for building HtmlUnit from CVS. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448268&aid=757873&group_id=47038 |
From: SourceForge.net <no...@so...> - 2003-06-19 13:34:51
|
Bugs item #730915, was opened at 2003-05-01 13:58 Message generated for change (Comment added) made by barnabycourt You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=730915&group_id=47038 Category: None Group: None >Status: Closed >Resolution: Fixed Priority: 6 Submitted By: Barnaby Court (barnabycourt) Assigned to: Nobody/Anonymous (nobody) Summary: Javascript ECMA error on Document.createElement("INPUT") Initial Comment: Hi, I am getting an ECMA exception "com.gargoylesoftware.htmlunit.ScriptExceptio n: undefined is not a function" when I try to use the javascript method document.createElement("INPUT"). A definition of this mehtod can be found on the <a href="http://www.mozilla.org/docs/dom/domref/dom_doc_ ref46.html"> mozilla site </a>. ---------------------------------------------------------------------- >Comment By: Barnaby Court (barnabycourt) Date: 2003-06-19 09:34 Message: Logged In: YES user_id=591975 This bug was fixed with the simplification of the javascript INPUT element to be handled by one class. ---------------------------------------------------------------------- Comment By: Barnaby Court (barnabycourt) Date: 2003-05-22 14:50 Message: Logged In: YES user_id=591975 After looking through the HtmlUnit source it appears that there is no simple way to support the javascript createElement () call. The principal problem, given my current understanding, is that Input elements can not be created without knowing the type ahead of time. I am proposing that a new version of the javascript.Host.Input element be created that supports all the methods that are needed. Are there other other major issues that I am missing? I need to have support for this method to testing. If there is support for making the changes necessary to support these 2 calls I would be happy to do the groundwork. I am a big fan of HTMLUnit but I need support for these 2 mehods. If support for this is not going to be made available I need to know so I can find another product that supports this now or will in the future. ---------------------------------------------------------------------- Comment By: Barnaby Court (barnabycourt) Date: 2003-05-01 15:11 Message: Logged In: YES user_id=591975 I am immediately calling the form.appendChild(...) method after creating the input element. After looking through com.gargoylesoftware.htmlunit.javascript.host.Form.java I did not see that method implemented either. If you have any pointers on what would have to be done to implement these methods I would be happy to help. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=730915&group_id=47038 |
From: SourceForge.net <no...@so...> - 2003-06-19 13:33:28
|
Bugs item #757225, was opened at 2003-06-19 09:33 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=757225&group_id=47038 Category: None Group: None Status: Open Resolution: None Priority: 5 Submitted By: Barnaby Court (barnabycourt) Assigned to: Nobody/Anonymous (nobody) Summary: Javascript: Support changing the TYPE,ID and NAME attributes Initial Comment: Add support for changing the type of INPUT elments and the ID and NAME of all html elements through javascript. Attached is a test case for the desired functionality. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=757225&group_id=47038 |
From: <no...@us...> - 2003-06-18 22:13:06
|
Log Message: ----------- Fix for broken input test - patch from Barnaby Court Modified Files: -------------- /cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript: SimpleScriptableTest.java Removed Files: ------------- /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/host: Submit.java Radio.java Password.java FileUpload.java Checkbox.java Hidden.java Text.java Reset.java Revision Data ------------- --- Submit.java DELETED --- --- Radio.java DELETED --- --- Password.java DELETED --- --- FileUpload.java DELETED --- --- Checkbox.java DELETED --- --- Hidden.java DELETED --- --- Text.java DELETED --- --- Reset.java DELETED --- Index: SimpleScriptableTest.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/SimpleScriptableTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- SimpleScriptableTest.java 10 Jun 2003 11:57:01 -0000 1.4 +++ SimpleScriptableTest.java 18 Jun 2003 22:13:04 -0000 1.5 @@ -58,6 +58,7 @@ * * @version $Revision$ * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> + * @author <a href="mailto:Bar...@us...">Barnaby Court</a> */ public class SimpleScriptableTest extends WebTestCase { public SimpleScriptableTest( final String name ) { @@ -106,7 +107,6 @@ // Now pull out those names that we know don't have html equivilents names.remove("Document"); names.remove("History"); - names.remove("Input"); // <- this one is abstract names.remove("Location"); names.remove("Navigator"); names.remove("Screen"); |
From: SourceForge.net <no...@so...> - 2003-06-17 18:06:26
|
Feature Requests item #756086, was opened at 2003-06-17 20:06 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448269&aid=756086&group_id=47038 Category: None Group: Next Release (example) Status: Open Priority: 5 Submitted By: JHoltman (jholtman) Assigned to: Nobody/Anonymous (nobody) Summary: Please implement window.setTimeout(..) Initial Comment: Please implement the window.setTimeout(...) feature. This method is called quite often in the websites I like to test. Because it returns "not found" I can't test these websites. The current implementation in the source code is commented. (At the moment I don't have the time to dig deep in the source code to suggest a patch). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448269&aid=756086&group_id=47038 |
From: <no...@us...> - 2003-06-16 21:03:28
|
Log Message: ----------- Patch from Barnaby Court to consolidate all the input logic into HtmlInput. One test is currently broken. Modified Files: -------------- /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript: SimpleScriptable.java FormElementsArray.java JavaScriptEngine.java /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html: HtmlSubmitInput.java HtmlForm.java HtmlPage.java HtmlCheckBoxInput.java HtmlButtonInput.java HtmlInput.java HtmlHiddenInput.java HtmlFileInput.java HtmlPasswordInput.java HtmlTextInput.java HtmlRadioButtonInput.java HtmlImageInput.java HtmlResetInput.java /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/host: Input.java Button.java Revision Data ------------- Index: HtmlSubmitInput.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlSubmitInput.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- HtmlSubmitInput.java 10 Jun 2003 11:56:58 -0000 1.9 +++ HtmlSubmitInput.java 16 Jun 2003 21:03:24 -0000 1.10 @@ -37,9 +37,6 @@ */ package com.gargoylesoftware.htmlunit.html; -import com.gargoylesoftware.htmlunit.ElementNotFoundException; -import com.gargoylesoftware.htmlunit.Page; -import java.io.IOException; import org.w3c.dom.Element; /** @@ -60,56 +57,5 @@ super( page, element ); } - - /** - * Submit the form that contains this input - * - * @deprecated Use {@link #click()} instead - * @return The Page that is the result of submitting this page to the - * server - * @exception IOException If an io error occurs - * @exception ElementNotFoundException If a particular xml element could - * not be found in the dom model - */ - public Page submit() - throws - IOException, - ElementNotFoundException { - - return click(); - } - - - /** - * Submit the form that contains this input - * - * @return The Page that is the result of submitting this page to the - * server - * @exception IOException If an io error occurs - */ - public Page click() throws IOException { - return super.click(); - } - - - /** - * This method will be called if there either wasn't an onclick handler or there was - * but the result of that handler was true. This is the default behaviour of clicking - * the element. In this case, the method will submit the form. - * - * @return The page that is currently loaded after execution of this method - * @throws IOException If an IO error occured - */ - protected Page doClickAction() throws IOException { - return getEnclosingFormOrDie().submit(this); - } - - - /** - * Reset the value of this element to its initial state. This is a no-op for - * this component. - */ - public void reset() { - } } Index: HtmlForm.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlForm.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- HtmlForm.java 10 Jun 2003 11:56:57 -0000 1.20 +++ HtmlForm.java 16 Jun 2003 21:03:24 -0000 1.21 @@ -99,7 +99,7 @@ final Iterator iterator = inputList.iterator(); while( iterator.hasNext() ) { final HtmlInput input = (HtmlInput)iterator.next(); - if( input instanceof HtmlSubmitInput ) { + if( input.getTypeAttribute().equals("submit")) { return submit( ( SubmittableElement )input ); } } Index: HtmlPage.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java,v retrieving revision 1.46 retrieving revision 1.47 diff -u -d -r1.46 -r1.47 --- HtmlPage.java 10 Jun 2003 11:56:58 -0000 1.46 +++ HtmlPage.java 16 Jun 2003 21:03:24 -0000 1.47 @@ -1132,11 +1132,8 @@ if( element instanceof HtmlButton ) { newPage = ((HtmlButton)element).click(); } - else if( element instanceof HtmlSubmitInput ) { - newPage = ((HtmlSubmitInput)element).click(); - } - else if( element instanceof HtmlResetInput ) { - newPage = ((HtmlResetInput)element).click(); + else if( element instanceof HtmlInput ) { + newPage = ((HtmlInput)element).click(); } else { newPage = this; Index: HtmlCheckBoxInput.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- HtmlCheckBoxInput.java 10 Jun 2003 11:56:57 -0000 1.12 +++ HtmlCheckBoxInput.java 16 Jun 2003 21:03:24 -0000 1.13 @@ -37,8 +37,6 @@ */ package com.gargoylesoftware.htmlunit.html; -import com.gargoylesoftware.htmlunit.Page; -import java.io.IOException; import org.w3c.dom.Element; /** @@ -49,8 +47,6 @@ */ public class HtmlCheckBoxInput extends HtmlInput { - private final boolean initialCheckedState_; - /** * Create an instance * @@ -59,52 +55,6 @@ */ HtmlCheckBoxInput( final HtmlPage page, final Element element ) { super( page, element ); - initialCheckedState_ = isAttributeDefined("checked"); - } - - - /** - * Set the "checked" attribute - * - * @param isChecked true if this element is to be selected - */ - public void setChecked( final boolean isChecked ) { - if( isChecked ) { - getElement().setAttribute( "checked", "checked" ); - } - else { - getElement().removeAttribute( "checked" ); - } - } - - - /** - * Return true if this element is currently selected - * - * @return See above - */ - public boolean isChecked() { - return isAttributeDefined("checked"); - } - - - /** - * Return the value of this element to what it was at the time the page was loaded. - */ - public void reset() { - setChecked(initialCheckedState_); - } - - - /** - * Submit the form that contains this input - * - * @return The Page that is the result of submitting this page to the - * server - * @exception IOException If an io error occurs - */ - public Page click() throws IOException { - return super.click(); } } Index: HtmlButtonInput.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlButtonInput.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- HtmlButtonInput.java 10 Jun 2003 11:56:57 -0000 1.8 +++ HtmlButtonInput.java 16 Jun 2003 21:03:24 -0000 1.9 @@ -37,8 +37,6 @@ */ package com.gargoylesoftware.htmlunit.html; -import com.gargoylesoftware.htmlunit.Page; -import java.io.IOException; import org.w3c.dom.Element; /** @@ -57,25 +55,6 @@ */ HtmlButtonInput( final HtmlPage page, final Element element ) { super( page, element ); - } - - - /** - * Reset this element to its original values. This is a no-op for a button. - */ - public void reset() { - } - - - /** - * Submit the form that contains this input - * - * @return The Page that is the result of submitting this page to the - * server - * @exception IOException If an io error occurs - */ - public Page click() throws IOException { - return super.click(); } } Index: HtmlInput.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlInput.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- HtmlInput.java 10 Jun 2003 11:56:57 -0000 1.22 +++ HtmlInput.java 16 Jun 2003 21:03:24 -0000 1.23 @@ -38,6 +38,7 @@ package com.gargoylesoftware.htmlunit.html; import com.gargoylesoftware.htmlunit.Assert; +import com.gargoylesoftware.htmlunit.ElementNotFoundException; import com.gargoylesoftware.htmlunit.KeyValuePair; import com.gargoylesoftware.htmlunit.Page; import com.gargoylesoftware.htmlunit.ScriptResult; @@ -50,7 +51,7 @@ * @version $Revision$ * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> */ -public abstract class HtmlInput +public class HtmlInput extends HtmlElement implements SubmittableElement { @@ -65,6 +66,9 @@ HtmlInput( final HtmlPage page, final Element element ) { super( page, element ); originalValue_ = element.getAttribute("value"); + //From the checkbox creator + initialCheckedState_ = isAttributeDefined("checked"); + initialValue_ = getValueAttribute(); } @@ -94,6 +98,16 @@ * @return See above */ public KeyValuePair[] getSubmitKeyValuePairs() { + if (getTypeAttribute().equals("image")) { + final String name = getNameAttribute(); + if( wasPositionSpecified_ == true ) { + return new KeyValuePair[]{ + new KeyValuePair( name, getValueAttribute() ), + new KeyValuePair( name+".x", String.valueOf(xPosition_) ), + new KeyValuePair( name+".y", String.valueOf(yPosition_) ) + }; + } + } return new KeyValuePair[]{new KeyValuePair( getNameAttribute(), getValueAttribute() )}; } @@ -107,7 +121,17 @@ * server * @exception IOException If an io error occurs */ - protected Page click() throws IOException { + public Page click() throws IOException { + + String type = this.getTypeAttribute(); + if (type.equals("file") || type.equals("hidden") || type.equals("password") || type.equals("text")) { + return getPage(); + } + if (type.equals("image")){ + if (! processingClick_ ) { + wasPositionSpecified_ = false; + } + } if( isDisabled() == true ) { return getPage(); @@ -137,7 +161,16 @@ * @throws IOException If an IO error occured */ protected Page doClickAction() throws IOException { - return getPage(); + final String type = getTypeAttribute(); + if (type.equals("image") || type.equals("submit")) { + return getEnclosingFormOrDie().submit(this); + } + else if (type.equals("reset")){ + return getEnclosingFormOrDie().reset(); + } + else { + return getPage(); + } } /** @@ -414,7 +447,7 @@ */ public final String getValueAttribute() { String value = getAttributeValue("value"); - if( value == ATTRIBUTE_NOT_DEFINED && this instanceof HtmlCheckBoxInput ) { + if( value == ATTRIBUTE_NOT_DEFINED && getTypeAttribute().equals("checkbox")) { value = "on"; } return value; @@ -636,4 +669,141 @@ public final String getAlignAttribute() { return getAttributeValue("align"); } + + //For Checkbox, radio + private final boolean initialCheckedState_; + //for Hidden, password + private final String initialValue_; + //For Image + private boolean wasPositionSpecified_ = false; + private boolean processingClick_ = false; + private int xPosition_; + private int yPosition_; + + /** + * Reset this element to its original values. + */ + public void reset() { + String type = this.getTypeAttribute(); + if( type.equals("checkbox")) { + setChecked(initialCheckedState_); + } + else if (type.equals("hidden") || type.equals("password")|| type.equals("text")) { + setValueAttribute(initialValue_); + } + else if (type.equals("radio")) { + if( initialCheckedState_ ) { + getElement().setAttribute("checked", "checked"); + } + else { + getElement().removeAttribute("checked"); + } + } + } + + /** + * Set the "checked" attribute + * + * @param isChecked true if this element is to be selected + */ + public void setChecked( final boolean isChecked ) { + String type = this.getTypeAttribute(); + if (type.equals("checkbox") ) { + setCheckedCheckBox(isChecked); + } + else if (type.equals("radio")){ + setCheckedRadio(isChecked); + } + } + + /** + * Set the "checked" attribute + * + * @param isChecked true if this element is to be selected + */ + private void setCheckedCheckBox( final boolean isChecked ) { + if( isChecked ) { + getElement().setAttribute( "checked", "checked" ); + } + else { + getElement().removeAttribute( "checked" ); + } + } + + /** + * Set the "checked" attribute + * + * @param isChecked true if this element is to be selected + */ + private final void setCheckedRadio( final boolean isChecked ) { + final HtmlForm form = getEnclosingForm(); + + if( isChecked ) { + try { + form.setCheckedRadioButton( getNameAttribute(), getValueAttribute() ); + } + catch( final ElementNotFoundException e ) { + // Shouldn't be possible + throw new IllegalStateException("Can't find this element when going up to the form and back down."); + } + } + else { + getElement().removeAttribute( "checked" ); + } + } + + + /** + * Return true if this element is currently selected + * + * @return See above + */ + public boolean isChecked() { + return isAttributeDefined("checked"); + } + /** + * Simulate clicking this input with a pointing device. The x and y coordinates + * of the pointing device will be sent to the server. + * + * @param x The x coordinate of the pointing device at the time of clicking + * @param y The y coordinate of the pointing device at the time of clicking + * @return The page that is loaded after the click has taken place. + * @exception IOException If an io error occurs + * @exception ElementNotFoundException If a particular xml element could + * not be found in the dom model + */ + public Page click( final int x, final int y ) + throws + IOException, + ElementNotFoundException { + + wasPositionSpecified_ = true; + xPosition_ = x; + yPosition_ = y; + processingClick_ = true; + Page returnValue = this.click(); + processingClick_ = false; + + return returnValue; + } + + /** + * Submit the form that contains this input + * + * @deprecated Use {@link #click()} instead + * @return The Page that is the result of submitting this page to the + * server + * @exception IOException If an io error occurs + * @exception ElementNotFoundException If a particular xml element could + * not be found in the dom model + */ + public Page submit() + throws + IOException, + ElementNotFoundException { + + return click(); + } + + } Index: HtmlHiddenInput.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlHiddenInput.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- HtmlHiddenInput.java 10 Jun 2003 11:56:57 -0000 1.5 +++ HtmlHiddenInput.java 16 Jun 2003 21:03:24 -0000 1.6 @@ -46,9 +46,6 @@ * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> */ public class HtmlHiddenInput extends HtmlInput { - - private final String initialValue_; - /** * Create an instance * @@ -57,15 +54,7 @@ */ HtmlHiddenInput( final HtmlPage page, final Element element ) { super( page, element ); - initialValue_ = getValueAttribute(); } - - /** - * Reset the value of this element to its initial state. - */ - public void reset() { - setValueAttribute(initialValue_); - } } Index: HtmlFileInput.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlFileInput.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- HtmlFileInput.java 10 Jun 2003 11:56:57 -0000 1.5 +++ HtmlFileInput.java 16 Jun 2003 21:03:24 -0000 1.6 @@ -56,13 +56,5 @@ HtmlFileInput( final HtmlPage page, final Element element ) { super( page, element ); } - - - /** - * Reset the value of this element to its initial state. This is a no-op for - * this component. - */ - public void reset() { - } } Index: HtmlPasswordInput.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlPasswordInput.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- HtmlPasswordInput.java 10 Jun 2003 11:56:58 -0000 1.5 +++ HtmlPasswordInput.java 16 Jun 2003 21:03:24 -0000 1.6 @@ -47,8 +47,6 @@ */ public class HtmlPasswordInput extends HtmlInput { - private final String initialValue_; - /** * Create an instance * @@ -57,15 +55,7 @@ */ HtmlPasswordInput( final HtmlPage page, final Element element ) { super( page, element ); - initialValue_ = getValueAttribute(); } - - /** - * Reset the value of this element to its initial state. - */ - public void reset() { - setValueAttribute(initialValue_); - } } Index: HtmlTextInput.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlTextInput.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- HtmlTextInput.java 10 Jun 2003 11:56:58 -0000 1.5 +++ HtmlTextInput.java 16 Jun 2003 21:03:24 -0000 1.6 @@ -46,7 +46,6 @@ * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> */ public class HtmlTextInput extends HtmlInput { - private final String initialValue_; /** * Create an instance @@ -56,15 +55,6 @@ */ HtmlTextInput( final HtmlPage page, final Element element ) { super( page, element ); - initialValue_ = getValueAttribute(); - } - - - /** - * Return the value of this element to what it was at the time the page was loaded. - */ - public void reset() { - setValueAttribute(initialValue_); } } Index: HtmlRadioButtonInput.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlRadioButtonInput.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- HtmlRadioButtonInput.java 10 Jun 2003 11:56:58 -0000 1.10 +++ HtmlRadioButtonInput.java 16 Jun 2003 21:03:24 -0000 1.11 @@ -37,9 +37,6 @@ */ package com.gargoylesoftware.htmlunit.html; -import com.gargoylesoftware.htmlunit.Page; -import com.gargoylesoftware.htmlunit.ElementNotFoundException; -import java.io.IOException; import org.w3c.dom.Element; /** @@ -49,7 +46,6 @@ * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> */ public class HtmlRadioButtonInput extends HtmlInput { - private final boolean initialCheckedState_; /** * Create an instance @@ -59,65 +55,6 @@ */ HtmlRadioButtonInput( final HtmlPage page, final Element element ) { super( page, element ); - initialCheckedState_ = isAttributeDefined("checked"); - } - - - /** - * Set the "checked" attribute - * - * @param isChecked true if this element is to be selected - */ - public final void setChecked( final boolean isChecked ) { - final HtmlForm form = getEnclosingForm(); - - if( isChecked ) { - try { - form.setCheckedRadioButton( getNameAttribute(), getValueAttribute() ); - } - catch( final ElementNotFoundException e ) { - // Shouldn't be possible - throw new IllegalStateException("Can't find this element when going up to the form and back down."); - } - } - else { - getElement().removeAttribute( "checked" ); - } - } - - - /** - * Return true if this element is currently selected - * - * @return See above - */ - public final boolean isChecked() { - return isAttributeDefined("checked"); - } - - - /** - * Return the value of this element to what it was at the time the page was loaded. - */ - public void reset() { - if( initialCheckedState_ ) { - getElement().setAttribute("checked", "checked"); - } - else { - getElement().removeAttribute("checked"); - } - } - - - /** - * Submit the form that contains this input - * - * @return The Page that is the result of submitting this page to the - * server - * @exception IOException If an io error occurs - */ - public Page click() throws IOException { - return super.click(); } } Index: HtmlImageInput.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlImageInput.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- HtmlImageInput.java 10 Jun 2003 11:56:57 -0000 1.11 +++ HtmlImageInput.java 16 Jun 2003 21:03:24 -0000 1.12 @@ -37,10 +37,6 @@ */ package com.gargoylesoftware.htmlunit.html; -import com.gargoylesoftware.htmlunit.ElementNotFoundException; -import com.gargoylesoftware.htmlunit.KeyValuePair; -import com.gargoylesoftware.htmlunit.Page; -import java.io.IOException; import org.w3c.dom.Element; /** @@ -50,11 +46,6 @@ * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> */ public class HtmlImageInput extends HtmlInput { - private boolean wasPositionSpecified_ = false; - private int xPosition_; - private int yPosition_; - - /** * Create an instance * @@ -65,85 +56,5 @@ super( page, element ); } - - /** - * Simulate clicking this input in some way other than with a pointing device. - * No x,y coordinates will be sent to the server. - * - * @return The page that is loaded after the click has taken place. - * @exception IOException If an io error occurs - */ - public Page click() throws IOException { - wasPositionSpecified_ = false; - return super.click(); - } - - - /** - * This method will be called if there either wasn't an onclick handler or there was - * but the result of that handler was true. This is the default behaviour of clicking - * the element. In this case, the method will submit the form. - * - * @return The page that is currently loaded after execution of this method - * @throws IOException If an IO error occured - */ - protected Page doClickAction() throws IOException { - return getEnclosingFormOrDie().submit(this); - } - - - /** - * Simulate clicking this input with a pointing device. The x and y coordinates - * of the pointing device will be sent to the server. - * - * @param x The x coordinate of the pointing device at the time of clicking - * @param y The y coordinate of the pointing device at the time of clicking - * @return The page that is loaded after the click has taken place. - * @exception IOException If an io error occurs - * @exception ElementNotFoundException If a particular xml element could - * not be found in the dom model - */ - public Page click( final int x, final int y ) - throws - IOException, - ElementNotFoundException { - - wasPositionSpecified_ = true; - xPosition_ = x; - yPosition_ = y; - return super.click(); - } - - - /** - * Return an array of KeyValuePairs that are the values that will be sent - * back to the server whenever the current form is submitted.<p> - * - * THIS METHOD IS INTENDED FOR THE USE OF THE FRAMEWORK ONLY AND SHOULD NOT - * BE USED BY CONSUMERS OF HTMLUNIT. USE AT YOUR OWN RISK. - * - * @return See above - */ - public KeyValuePair[] getSubmitKeyValuePairs() { - final String name = getNameAttribute(); - if( wasPositionSpecified_ == true ) { - return new KeyValuePair[]{ - new KeyValuePair( name, getValueAttribute() ), - new KeyValuePair( name+".x", String.valueOf(xPosition_) ), - new KeyValuePair( name+".y", String.valueOf(yPosition_) ) - }; - } - else { - return new KeyValuePair[]{new KeyValuePair( name, getValueAttribute() )}; - } - } - - - /** - * Reset the value of this element to its initial state. This is a no-op for - * this component. - */ - public void reset() { - } } Index: HtmlResetInput.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/html/HtmlResetInput.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- HtmlResetInput.java 10 Jun 2003 11:56:58 -0000 1.9 +++ HtmlResetInput.java 16 Jun 2003 21:03:24 -0000 1.10 @@ -37,8 +37,6 @@ */ package com.gargoylesoftware.htmlunit.html; -import com.gargoylesoftware.htmlunit.Page; -import java.io.IOException; import org.w3c.dom.Element; /** @@ -59,37 +57,5 @@ super( page, element ); } - - /** - * Reset the form that contains this input - * - * @return The Page that is the result of reseting this page. Typically this - * will be the current page but if javascript is invoked by this click then - * another page could have been loaded. - * @exception IOException If an io error occurs - */ - public Page click() throws IOException { - return super.click(); - } - - - /** - * This method will be called if there either wasn't an onclick handler or there was - * but the result of that handler was true. This is the default behaviour of clicking - * the element. In this case, the method will reset the form. - * - * @return The page that is currently loaded after execution of this method - * @throws IOException If an IO error occured - */ - protected Page doClickAction() throws IOException { - return getEnclosingFormOrDie().reset(); - } - - - /** - * Reset this element to its original values. This is a no-op for a button. - */ - public void reset() { - } } Index: SimpleScriptable.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/SimpleScriptable.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- SimpleScriptable.java 10 Jun 2003 11:56:58 -0000 1.29 +++ SimpleScriptable.java 16 Jun 2003 21:03:24 -0000 1.30 @@ -40,7 +40,6 @@ import com.gargoylesoftware.htmlunit.Assert; import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.ScriptException; -import com.gargoylesoftware.htmlunit.html.HtmlButton; import com.gargoylesoftware.htmlunit.html.HtmlElement; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -95,20 +94,20 @@ final String[][] mapping = { {"HtmlAnchor", "Anchor"}, {"HtmlButton", "Button"}, - {"HtmlButtonInput", "Button"}, - {"HtmlCheckBoxInput", "Checkbox"}, - {"HtmlFileInput", "FileUpload"}, + {"HtmlInput", "Input"}, + {"HtmlCheckBoxInput", "Input"}, + {"HtmlFileInput", "Input"}, {"HtmlForm", "Form"}, - {"HtmlHiddenInput", "Hidden"}, + {"HtmlHiddenInput", "Input"}, {"HtmlImage", "Image"}, {"HtmlInlineFrame", "Window"}, {"HtmlOption", "Option"}, - {"HtmlPasswordInput", "Password"}, - {"HtmlRadioButtonInput", "Radio"}, - {"HtmlResetInput", "Reset"}, + {"HtmlPasswordInput", "Input"}, + {"HtmlRadioButtonInput", "Input"}, + {"HtmlResetInput", "Input"}, {"HtmlSelect", "Select"}, - {"HtmlSubmitInput", "Submit"}, - {"HtmlTextInput", "Text"}, + {"HtmlSubmitInput", "Input"}, + {"HtmlTextInput", "Input"}, {"HtmlTextArea", "Textarea"}, {"HtmlElement", "HTMLElement"}, }; @@ -464,14 +463,7 @@ } final String javaScriptClassName; - if( htmlElement instanceof HtmlButton ) { - // TODO: The proper solution is to make HtmlButton abstract and have a hierarchy just like HtmlInput - // Until that happens, we touch up the javascript name here. - javaScriptClassName = getJavaScriptClassNameForButtonKludge((HtmlButton)htmlElement); - } - else { - javaScriptClassName = (String)getHtmlJavaScriptMapping().get(htmlElement.getClass()); - } + javaScriptClassName = (String)getHtmlJavaScriptMapping().get(htmlElement.getClass()); if( javaScriptClassName == null ) { // We don't have a specific subclass for this element so create something generic. final SimpleScriptable scriptable = makeJavaScriptObject("HTMLElement"); @@ -484,47 +476,6 @@ scriptable.setHtmlElement(htmlElement); return scriptable; } - } - - - private String getJavaScriptClassNameForButtonKludge( final HtmlButton button ) { - final String typeAttribute = button.getTypeAttribute(); - final String className; - if( typeAttribute == HtmlButton.ATTRIBUTE_NOT_DEFINED ) { - className = "Button"; - } - else if( typeAttribute.equals("submit") ) { - className = "Submit"; - } - else if( typeAttribute.equals("reset") ) { - className = "Reset"; - } - else if( typeAttribute.equals("checkbox") ) { - className = "Checkbox"; - } - else if( typeAttribute.equals("radio") ) { - className = "Radio"; - } - else if( typeAttribute.equals("text") ) { - className = "Text"; - } - else if( typeAttribute.equals("hidden") ) { - className = "Hidden"; - } - else if( typeAttribute.equals("password") ) { - className = "Password"; - } - else if( typeAttribute.equals("image") ) { - className = "Image"; - } - else if( typeAttribute.equals("file") ) { - className = "File"; - } - else { - className = "Button"; - } - - return className; } Index: FormElementsArray.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/FormElementsArray.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- FormElementsArray.java 10 Jun 2003 11:56:58 -0000 1.7 +++ FormElementsArray.java 16 Jun 2003 21:03:24 -0000 1.8 @@ -40,7 +40,7 @@ import com.gargoylesoftware.htmlunit.Assert; import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlForm; -import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput; +import com.gargoylesoftware.htmlunit.html.HtmlInput; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -124,13 +124,13 @@ while( iterator.hasNext() ) { htmlElement = (HtmlElement)iterator.next(); if( htmlElement.getAttributeValue("name").equals(name) ) { - if( htmlElement instanceof HtmlRadioButtonInput ) { + if( htmlElement instanceof HtmlInput ) { final List collectedRadioButtons = new ArrayList(elementList.size()); collectedRadioButtons.add(getScriptableFor(htmlElement)); while( iterator.hasNext() ) { htmlElement = (HtmlElement)iterator.next(); - if( htmlElement instanceof HtmlRadioButtonInput - && ((HtmlRadioButtonInput)htmlElement).getNameAttribute().equals(name) ) { + if( htmlElement instanceof HtmlInput + && ((HtmlInput)htmlElement).getNameAttribute().equals(name) ) { collectedRadioButtons.add(getScriptableFor(htmlElement)); } } Index: JavaScriptEngine.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/JavaScriptEngine.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- JavaScriptEngine.java 10 Jun 2003 11:56:58 -0000 1.17 +++ JavaScriptEngine.java 16 Jun 2003 21:03:24 -0000 1.18 @@ -133,9 +133,8 @@ final String hostClassNames[] = { "HTMLElement" ,"Window", "Document", "Form", "Input", "Navigator", - "Screen", "History", "Radio", "Location", "Text", "Button", "Checkbox", - "FileUpload", "Hidden", "Select", "Password", "Reset", "Submit", "Textarea", - "Image", "Style", "Option", "Anchor" + "Screen", "History", "Location", "Button", "Select", "Textarea", + "Style", "Option", "Anchor", "Image" }; for( int i=0; i<hostClassNames.length; i++ ) { Index: Input.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/host/Input.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Input.java 10 Jun 2003 11:56:59 -0000 1.9 +++ Input.java 16 Jun 2003 21:03:24 -0000 1.10 @@ -39,6 +39,8 @@ import org.w3c.dom.Element; +import com.gargoylesoftware.htmlunit.html.HtmlInput; + /** * The javascript object that represents something that can be put in a form. * @@ -123,8 +125,14 @@ * set */ public void jsSet_checked( final boolean checked ) { - getLog().debug( "Input.jsSet_checked(" + checked - + ") was called for class " + getClass().getName() ); + String type = getHtmlElementOrDie().getAttributeValue("type"); + if (type.equals("checkbox") || type.equals("radio")){ + ((HtmlInput)getHtmlElementOrDie()).setChecked(checked); + } + else { + getLog().debug( "Input.jsSet_checked(" + checked + + ") was called for class " + getClass().getName() ); + } } @@ -137,8 +145,14 @@ *@return The checked property. */ public boolean jsGet_checked() { - getLog().warn( "Input.jsGet_checked() was called for class " + getClass().getName() ); - return false; + String type = getHtmlElementOrDie().getAttributeValue("type"); + if (type.equals("checkbox") || type.equals("radio")){ + return ((HtmlInput)getHtmlElementOrDie()).isChecked(); + } + else { + getLog().warn( "Input.jsGet_checked() was called for class " + getClass().getName() ); + return false; + } } Index: Button.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/host/Button.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Button.java 10 Jun 2003 11:56:59 -0000 1.4 +++ Button.java 16 Jun 2003 21:03:24 -0000 1.5 @@ -60,13 +60,5 @@ public void jsConstructor() { } - - /** - * Return the type of this input. - * @return The type - */ - public String jsGet_type() { - return "button"; - } } |
From: <no...@us...> - 2003-06-16 21:01:06
|
Log Message: ----------- Fixed SanityCheck target Modified Files: -------------- /cvsroot/htmlunit/htmlunit: build.xml Revision Data ------------- Index: build.xml =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/build.xml,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- build.xml 27 May 2003 21:01:50 -0000 1.40 +++ build.xml 16 Jun 2003 21:01:05 -0000 1.41 @@ -300,7 +300,7 @@ <target name="SanityCheck" description="DO NOT RUN THIS TASK"> - <java fork="yes" classname="com.gargoylesoftware.htmlunit.test.SanityCheck" dir="src/java"> + <java fork="yes" classname="com.gargoylesoftware.htmlunit.SanityCheck" dir="src/java"> <classpath refid="base.class.path"/> <classpath refid="test.class.path"/> </java> |
From: SourceForge.net <no...@so...> - 2003-06-14 15:58:52
|
Bugs item #750487, was opened at 2003-06-07 03:38 Message generated for change (Comment added) made by mbowler You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=750487&group_id=47038 Category: None Group: None Status: Open Resolution: Remind Priority: 7 Submitted By: Suheal Hanjgikar (suheal) Assigned to: Mike Bowler (mbowler) Summary: The undefined value has no properties Initial Comment: Tried to write a sample test program using HtmlUnit. Unfortunately it is throwing an exception. The bug 727718 mentions the same problem. I have attached the source code of the sample test program. Here is the exception it throws: I think the Redirect statement can be safely neglected. The exception that it throws. /****************************************** ****************************************** ***********/ [INFO] HttpMethod - -Redirect requested but followRedirects is disabled com.gargoylesoftware.htmlunit.ScriptException: The undefined value has no properties. at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngin e.execute(JavaScriptEngine.java:199) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJav aScriptIfPossible(HtmlPage.java:770) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeBod yOnLoadHandlerIfNeeded(HtmlPage.java:900) at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize (HtmlPage.java:134) at com.gargoylesoftware.htmlunit.WebClient.getPage (WebClient.java:322) at com.gargoylesoftware.htmlunit.WebClient.getPage (WebClient.java:242) at com.gargoylesoftware.htmlunit.WebClient.getPage (WebClient.java:186) at testhtml.main(testhtml.java:23) /****************************************** ****************************************** ***********/ ---------------------------------------------------------------------- >Comment By: Mike Bowler (mbowler) Date: 2003-06-14 11:58 Message: Logged In: YES user_id=46756 I can't presently get far enough to see the error that you are seeing. NekoHTML is generating multiple body tags from the html at http://www.mail.yahoo.com which means that it blows up before the point that you are seeing. I have opened a bug with NekoHTML and will revisit this when I've got a response. If you have a different sample that reproduces the same problem then please post it here. BTW this is not likely related to bug 727718. The error message in question just means that the rhino engine has tried to call a method that hasn't been implemented yet. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=750487&group_id=47038 |
From: SourceForge.net <no...@so...> - 2003-06-14 15:07:13
|
Bugs item #753776, was opened at 2003-06-13 03:15 Message generated for change (Comment added) made by mbowler You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=753776&group_id=47038 Category: Interface (example) Group: None Status: Open Resolution: None Priority: 5 Submitted By: JHoltman (jholtman) Assigned to: Nobody/Anonymous (nobody) Summary: Refreshing a frame in a frameset Initial Comment: Hi, I guess that refreshing frames in a frameset is not working as expected. I have a frameset with a "contents" frame on the left (with 2 hypertext links "Second" and "Third") and on the right another "maincontents" frame. Initially the "maincontents" frame contains a "maincontents_initial.html" page. OK, works for me. If I click on the "Second" link (on the contents frame), the "maincontents" frame should be refreshed with the "maincontents_second.html" file. I expect a webwindow event with a webwindow of type "HtmlFrame", but I get "ToplevelWindow". I expect the webwindow (via newPage().getEnclosingWindow()) to be pointing to a previous initialized "maincontents" frame. Not so. There is also no name of the webwindow (via getName). The output of the test program: =======================8<================= [1] - access the frameset WinEvent: name=Contents, class=com.gargoylesoftware.htmlunit.html.HtmlFrame, new page title=Contents Contents frame with page title: Contents WinEvent: name=maincontents, class=com.gargoylesoftware.htmlunit.html.HtmlFrame, new page title=Initial Main Contents MainContents frame with page title: Initial Main Contents WinEvent: name=, class=com.gargoylesoftware.htmlunit.TopLevelWindow, new page title=Frameset test Unknown webwindow not equal to other webwindows [2] - check the contents frame [3] - check the maincontents frame [4] - push the "Second" html-link WinEvent: name=, class=com.gargoylesoftware.htmlunit.TopLevelWindow, new page title=Second Main Contents Unknown webwindow not equal to other webwindows [5] - check the maincontents frame - should be HtmlFrame update with Second Main Contents Expected "second" main contents page =======================8<================= (For me less important) When adding the getOldPage() in the code (see NOTICE) the an exception occurs. Attached: (1) HTML code: - frameset.html (with the frameset) - contents.html (the left frame of the frameset with 2 links) - maincontents_initial.html (the initial contents of the maincontents / right frame) - maincontents_second.html (after clicking on the "Second" this shoudl be in maincontents - maincontents_third.html (also for "Third" link) (2) Java code: - TestWindowReload.java (main test program) - TestWebWindowEventListener.java (simple web window event listener) I hope you can spend some time on this one because framesets are quite important in a number of websites. And by removing the NOTICE the stack trace is shown. Greetings, Johan Holtman ---------------------------------------------------------------------- >Comment By: Mike Bowler (mbowler) Date: 2003-06-14 11:07 Message: Logged In: YES user_id=46756 Contrary to what the comment above says, there are no attached files. Please add these files so we can reproduce the problem. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=753776&group_id=47038 |
From: SourceForge.net <no...@so...> - 2003-06-13 07:15:32
|
Bugs item #753776, was opened at 2003-06-13 09:15 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=753776&group_id=47038 Category: Interface (example) Group: None Status: Open Resolution: None Priority: 5 Submitted By: JHoltman (jholtman) Assigned to: Nobody/Anonymous (nobody) Summary: Refreshing a frame in a frameset Initial Comment: Hi, I guess that refreshing frames in a frameset is not working as expected. I have a frameset with a "contents" frame on the left (with 2 hypertext links "Second" and "Third") and on the right another "maincontents" frame. Initially the "maincontents" frame contains a "maincontents_initial.html" page. OK, works for me. If I click on the "Second" link (on the contents frame), the "maincontents" frame should be refreshed with the "maincontents_second.html" file. I expect a webwindow event with a webwindow of type "HtmlFrame", but I get "ToplevelWindow". I expect the webwindow (via newPage().getEnclosingWindow()) to be pointing to a previous initialized "maincontents" frame. Not so. There is also no name of the webwindow (via getName). The output of the test program: =======================8<================= [1] - access the frameset WinEvent: name=Contents, class=com.gargoylesoftware.htmlunit.html.HtmlFrame, new page title=Contents Contents frame with page title: Contents WinEvent: name=maincontents, class=com.gargoylesoftware.htmlunit.html.HtmlFrame, new page title=Initial Main Contents MainContents frame with page title: Initial Main Contents WinEvent: name=, class=com.gargoylesoftware.htmlunit.TopLevelWindow, new page title=Frameset test Unknown webwindow not equal to other webwindows [2] - check the contents frame [3] - check the maincontents frame [4] - push the "Second" html-link WinEvent: name=, class=com.gargoylesoftware.htmlunit.TopLevelWindow, new page title=Second Main Contents Unknown webwindow not equal to other webwindows [5] - check the maincontents frame - should be HtmlFrame update with Second Main Contents Expected "second" main contents page =======================8<================= (For me less important) When adding the getOldPage() in the code (see NOTICE) the an exception occurs. Attached: (1) HTML code: - frameset.html (with the frameset) - contents.html (the left frame of the frameset with 2 links) - maincontents_initial.html (the initial contents of the maincontents / right frame) - maincontents_second.html (after clicking on the "Second" this shoudl be in maincontents - maincontents_third.html (also for "Third" link) (2) Java code: - TestWindowReload.java (main test program) - TestWebWindowEventListener.java (simple web window event listener) I hope you can spend some time on this one because framesets are quite important in a number of websites. And by removing the NOTICE the stack trace is shown. Greetings, Johan Holtman ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=753776&group_id=47038 |
From: SourceForge.net <no...@so...> - 2003-06-12 14:10:26
|
Bugs item #750487, was opened at 2003-06-07 07:38 Message generated for change (Settings changed) made by suheal You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=750487&group_id=47038 Category: None Group: None Status: Open >Resolution: Remind >Priority: 7 Submitted By: Suheal Hanjgikar (suheal) >Assigned to: Mike Bowler (mbowler) Summary: The undefined value has no properties Initial Comment: Tried to write a sample test program using HtmlUnit. Unfortunately it is throwing an exception. The bug 727718 mentions the same problem. I have attached the source code of the sample test program. Here is the exception it throws: I think the Redirect statement can be safely neglected. The exception that it throws. /****************************************** ****************************************** ***********/ [INFO] HttpMethod - -Redirect requested but followRedirects is disabled com.gargoylesoftware.htmlunit.ScriptException: The undefined value has no properties. at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngin e.execute(JavaScriptEngine.java:199) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJav aScriptIfPossible(HtmlPage.java:770) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeBod yOnLoadHandlerIfNeeded(HtmlPage.java:900) at com.gargoylesoftware.htmlunit.html.HtmlPage.initialize (HtmlPage.java:134) at com.gargoylesoftware.htmlunit.WebClient.getPage (WebClient.java:322) at com.gargoylesoftware.htmlunit.WebClient.getPage (WebClient.java:242) at com.gargoylesoftware.htmlunit.WebClient.getPage (WebClient.java:186) at testhtml.main(testhtml.java:23) /****************************************** ****************************************** ***********/ ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=448266&aid=750487&group_id=47038 |
From: <no...@us...> - 2003-06-10 19:58:56
|
Log Message: ----------- Initial checkin - this class will dynamically generate tests for the majority of getXXAttribute() methods to ensure they are working correctly. Added Files: ----------- /cvsroot/htmlunit/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html: AttributesTest.java Revision Data ------------- --- NEW FILE: AttributesTest.java --- /* * Copyright (c) 2002, 2003 Gargoyle Software Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The end-user documentation included with the redistribution, if any, must * include the following acknowledgment: * * "This product includes software developed by Gargoyle Software Inc. * (http://www.GargoyleSoftware.com/)." * * Alternately, this acknowledgment may appear in the software itself, if * and wherever such third-party acknowledgments normally appear. * 4. The name "Gargoyle Software" must not be used to endorse or promote * products derived from this software without prior written permission. * For written permission, please contact in...@Ga.... * 5. Products derived from this software may not be called "HtmlUnit", nor may * "HtmlUnit" appear in their name, without prior written permission of * Gargoyle Software Inc. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARGOYLE * SOFTWARE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package com.gargoylesoftware.htmlunit.html; import com.gargoylesoftware.htmlunit.FakeWebConnection; import com.gargoylesoftware.htmlunit.SubmitMethod; import com.gargoylesoftware.htmlunit.WebClient; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.w3c.dom.Attr; import org.w3c.dom.Element; /** * <p>Tests for all the generated attribute accessors. This test case will * dynamically generate tests for all the various attributes. The code * is fairly complicated but doing it this way is much easier than writing * individual tests for all the attributes.</p> * * @version $Revision: 1.1 $ * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> */ public class AttributesTest extends TestCase { private final Class classUnderTest_; private final Method method_; private final HtmlPage page_; private final String attributeName_; private static final List EXCLUDED_METHODS = new ArrayList(); static { EXCLUDED_METHODS.add("getHtmlElementsByAttribute"); EXCLUDED_METHODS.add("getOneHtmlElementByAttribute"); }; /** * Return a test suite containing a seperate test for each attribute * on each element. * * @return The test suite * @throws Exception If the tests cannot be created. */ public static Test suite() throws Exception { final HtmlPage page = createDummyPage(); final TestSuite suite = new TestSuite(); final String[] classesToTest = new String[] { "HtmlAddress", "HtmlAnchor", "HtmlApplet", "HtmlArea", "HtmlBase", "HtmlBaseFont", "HtmlBidirectionalOverride", "HtmlBlockQuote", "HtmlBody", "HtmlBreak", "HtmlButton", "HtmlButtonInput", "HtmlCaption", "HtmlCenter", "HtmlCheckBoxInput", "HtmlDefinitionDescription", "HtmlDefinitionList", "HtmlDefinitionTerm", "HtmlDeletedText", "HtmlDivision", "HtmlElement", "HtmlFieldSet", "HtmlFileInput", "HtmlFont", "HtmlForm", "HtmlFrame", "HtmlFrameSet", "HtmlHead", "HtmlHeader1", "HtmlHeader2", "HtmlHeader3", "HtmlHeader4", "HtmlHeader5", "HtmlHeader6", "HtmlHiddenInput", "HtmlHorizontalRule", "HtmlImage", "HtmlImageInput", "HtmlInlineFrame", "HtmlInlineQuotation", "HtmlInsertedText", "HtmlIsIndex", "HtmlLabel", "HtmlLegend", "HtmlLink", "HtmlListItem", "HtmlMap", "HtmlMenu", "HtmlMeta", "HtmlNoFrames", "HtmlNoScript", "HtmlObject", "HtmlOption", "HtmlOptionGroup", "HtmlOrderedList", /*"HtmlPage",*/ "HtmlParagraph", "HtmlParameter", "HtmlPasswordInput", "HtmlPreformattedText", "HtmlRadioButtonInput", "HtmlResetInput", "HtmlScript", "HtmlSelect", "HtmlSpan", "HtmlStyle", "HtmlSubmitInput", "HtmlTable", "HtmlTableBody", /*"HtmlTableCell",*/ "HtmlTableColumn", "HtmlTableColumnGroup", "HtmlTableData", "HtmlTableDataCell", "HtmlTableFooter", "HtmlTableHeader", "HtmlTableHeaderCell", "HtmlTableRow", "HtmlTextArea", "HtmlTextDirection", "HtmlTextInput", "HtmlTitle", "HtmlUnorderedList" }; for( int i=0; i<classesToTest.length; i++ ) { final Class clazz = Class.forName( "com.gargoylesoftware.htmlunit.html."+classesToTest[i]); addTestsForClass( clazz, page, suite ); } return suite; } /** * Add all the tests for a given class. * * @param clazz The class to create tests for. * @param page The HtmlPage that will be passed into the constructor of the * objects to be tested. * @param suite The suite that all the tests will be placed inside. * @throws Exception If the tests cannot be created. */ private static void addTestsForClass( final Class clazz, final HtmlPage page, final TestSuite suite ) throws Exception { final Method[] methods = clazz.getMethods(); for( int i=0; i<methods.length; i++ ) { final String methodName = methods[i].getName(); if( methodName.startsWith("get") && methodName.endsWith("Attribute") && EXCLUDED_METHODS.contains(methodName) == false ) { String attributeName = methodName.substring(3, methodName.length()-9).toLowerCase(); if( attributeName.equals("xmllang") ) { attributeName = "xml:lang"; } else if( attributeName.equals("columns") ) { attributeName = "cols"; } else if( attributeName.equals("columnspan") ) { attributeName = "colspan"; } else if( attributeName.equals("textdirection") ) { attributeName = "dir"; } else if( attributeName.equals("httpequiv") ) { attributeName = "http-equiv"; } else if( attributeName.equals("acceptcharset") ) { attributeName = "accept-charset"; } suite.addTest( new AttributesTest(attributeName, clazz, methods[i], page) ); } } } /** * Create an instance of the test. This will test one specific attribute * on one specific class. * @param attributeName The name of the attribute to test. * @param classUnderTest The class containing the attribute. * @param method The "getter" method for the specified attribute. * @param page The page that will be passed into the constructor of the object * to be tested. */ public AttributesTest ( final String attributeName, final Class classUnderTest, final Method method, final HtmlPage page ) { super( createTestName(classUnderTest, method) ); classUnderTest_ = classUnderTest; method_ = method; page_ = page; if( attributeName.equals("TextDirection") ) { attributeName_ = "dir"; } else { attributeName_ = attributeName; } } /** * Create a name for this particular test that reflect the attribute being tested. * @param clazz The class containing the attribute. * @param method The getter method for the attribute. * @return The new name. */ private static String createTestName( final Class clazz, final Method method ) { String className = clazz.getName(); final int index = className.lastIndexOf('.'); className = className.substring(index+1); return "testAttributes_"+className+"_"+method.getName(); } /** * Run the actual test. * @throws Exception If the test fails. */ protected void runTest() throws Exception { final String value = new String("value"); final List collectedAttributeRequests = new ArrayList(); final Element proxyElement = createProxyElement(value, collectedAttributeRequests); final Object objectToTest = getNewInstanceForClassUnderTest(proxyElement); collectedAttributeRequests.clear(); final Object noObjects[] = new Object[0]; final Object result = method_.invoke( objectToTest, noObjects ); assertSame( value, result ); final List expectedAttributeRequests = new ArrayList(); expectedAttributeRequests.add(attributeName_.toUpperCase()); assertEquals( expectedAttributeRequests, collectedAttributeRequests); } /** * Create a new instance of the class being tested. * @param proxyElement The element that is being wrapped by the class. * @return The new instance. * @throws Exception If the new object cannot be created. */ private Object getNewInstanceForClassUnderTest(final Element proxyElement ) throws Exception { final Object newInstance; if( classUnderTest_ == HtmlTableRow.class ) { newInstance = new HtmlTableRow( page_, proxyElement, 1 ); } else if( classUnderTest_ == HtmlTableHeaderCell.class ) { newInstance = new HtmlTableHeaderCell(page_, proxyElement, 1, 1 ); } else if( classUnderTest_ == HtmlTableDataCell.class ) { newInstance = new HtmlTableDataCell(page_, proxyElement, 1, 1 ); } else { final Constructor constructor = classUnderTest_.getDeclaredConstructor( new Class[]{ HtmlPage.class, Element.class } ); newInstance = constructor.newInstance( new Object[]{page_, proxyElement}); } return newInstance; } /** * Create a {@link Proxy} {@link Element} * @param value The value that will be returned when the attribute value is * requested. * @param collectedAttributeRequests A list into which all the attribute * requests will be placed. * @return The new proxy. */ private Element createProxyElement( final String value, final List collectedAttributeRequests ) { final Class clazz = Element.class; final InvocationHandler handler = new InvocationHandler() { public Object invoke( Object proxy, Method method, Object[] args ) { final String methodName = method.getName(); if( methodName.equals( "equals" ) && args.length == 1 ) { return new Boolean( proxy == args[0] ); } else if( methodName.equals( "toString" ) ) { return "Proxy(" + clazz.getName() + ")"; } else if( methodName.endsWith("getAttributeNode") ) { collectedAttributeRequests.add( args[0] ); return createProxyAttributeNode(value); } return null; } }; return (Element) Proxy.newProxyInstance( getClass().getClassLoader(), new Class[]{clazz}, handler ); } /** * Create a {@link Proxy} {@link Attr} object. * @param value The object that will be returned by any method call to the proxy. * @return The new proxy. */ private Attr createProxyAttributeNode( final String value ) { final Class clazz = Attr.class; final InvocationHandler handler = new InvocationHandler() { public Object invoke( Object proxy, Method method, Object[] args ) { return value; } }; return (Attr) Proxy.newProxyInstance( getClass().getClassLoader(), new Class[]{clazz}, handler ); } /** * Create an HtmlPage that will be used through the tests. * @return The new page. * @throws Exception If the page cannot be created. */ private static HtmlPage createDummyPage() throws Exception { final String htmlContent = "<html><head><title>foo</title></head><body>" + "</body></html>"; final WebClient client = new WebClient(); final FakeWebConnection webConnection = new FakeWebConnection( client ); webConnection.setContent( htmlContent ); client.setWebConnection( webConnection ); return (HtmlPage)client.getPage( new URL( "http://first" ), SubmitMethod.POST, Collections.EMPTY_LIST ); } public static void main( final String args[] ) { junit.textui.TestRunner.main( new String[]{ "com.gargoylesoftware.htmlunit.html.AttributesTest" } ); }} |
From: <no...@us...> - 2003-06-10 11:59:53
|
Log Message: ----------- Changed license.xml to LICENSE.txt to be more maven friendly Added Files: ----------- /cvsroot/htmlunit/htmlunit: LICENSE.txt Removed Files: ------------- /cvsroot/htmlunit/htmlunit/src/xdocs: license.xml Revision Data ------------- --- NEW FILE: LICENSE.txt --- /* * Copyright (c) 2002, 2003 Gargoyle Software Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The end-user documentation included with the redistribution, if any, must * include the following acknowledgment: * * "This product includes software developed by Gargoyle Software Inc. * (http://www.GargoyleSoftware.com/)." * * Alternately, this acknowledgment may appear in the software itself, if * and wherever such third-party acknowledgments normally appear. * 4. The name "Gargoyle Software" must not be used to endorse or promote * products derived from this software without prior written permission. * For written permission, please contact in...@Ga.... * 5. Products derived from this software may not be called "HtmlUnit", nor may * "HtmlUnit" appear in their name, without prior written permission of * Gargoyle Software Inc. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GARGOYLE * SOFTWARE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ --- license.xml DELETED --- |