From: <mgu...@us...> - 2013-02-06 07:43:26
|
Revision: 8097 http://sourceforge.net/p/htmlunit/code/8097 Author: mguillem Date: 2013-02-06 07:43:21 +0000 (Wed, 06 Feb 2013) Log Message: ----------- JavaScript: add empty implementations of CanvasRenderingContext2D methods createImageData, createPattern, createRadialGradient, fillText, getImageData, getLineData, isPointInPath, measureText, putImageData, rect, rotate, setTransform, strokeText, and transform (FF). Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2D.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2DTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-02-05 13:29:25 UTC (rev 8096) +++ trunk/htmlunit/src/changes/changes.xml 2013-02-06 07:43:21 UTC (rev 8097) @@ -8,6 +8,11 @@ <body> <release version="2.12" date="???" description="Bugfixes, CSS3 Selectors"> + <action type="fix" dev="mguillem"> + JavaScript: add empty implementations of CanvasRenderingContext2D methods createImageData, + createPattern, createRadialGradient, fillText, getImageData, getLineData, isPointInPath, + measureText, putImageData, rect, rotate, setTransform, strokeText, and transform (FF). + </action> <action type="fix" dev="rbri"> Support for CSS pseudo selector ':target' added. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2D.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2D.java 2013-02-05 13:29:25 UTC (rev 8096) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2D.java 2013-02-06 07:43:21 UTC (rev 8097) @@ -322,4 +322,116 @@ final Context context, final Scriptable thisObj, final Object[] args, final Function function) { //empty } + + /** + * Creates a new, blank ImageData object with the specified dimensions. + */ + @JsxFunction + public void createImageData() { + //empty + } + + /** + * Creates a pattern. + */ + @JsxFunction + public void createPattern() { + //empty + } + + /** + * Creates a gradient. + */ + @JsxFunction + public void createRadialGradient() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void fillText() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void getImageData() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void getLineData() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void isPointInPath() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void measureText() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void putImageData() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void rect() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void rotate() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void setTransform() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void strokeText() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void transform() { + //empty + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2DTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2DTest.java 2013-02-05 13:29:25 UTC (rev 8096) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2DTest.java 2013-02-06 07:43:21 UTC (rev 8097) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.canvas; +import org.apache.commons.lang3.StringUtils; import org.junit.Test; import org.junit.runner.RunWith; @@ -58,6 +59,7 @@ + " ctx.lineTo(10, 10);\n" + " ctx.quadraticCurveTo(0, 10, 15, 10);\n" + " ctx.closePath();\n" + + " ctx.rotate(1.234);\n" + " alert('done');\n" + " } catch(e) { alert('exception'); }\n" + "}\n" @@ -67,4 +69,38 @@ + "</html>"; loadPageWithAlerts2(html); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(FF = { "drawCustomFocusRing", "drawSystemFocusRing", "getLineDash", "scrollPathIntoView", "setLineDash", + "33 methods" }, + IE = "exception") + public void methods() throws Exception { + final String[] methods = {"arc", "arcTo", "beginPath", "bezierCurveTo", "clearRect", "clip", "closePath", + "createImageData", "createLinearGradient", "createPattern", "createRadialGradient", "drawImage", + "drawCustomFocusRing", "drawSystemFocusRing", "fill", "fillRect", "fillText", "getImageData", + "getLineDash", "isPointInPath", "lineTo", "measureText", "moveTo", "putImageData", "quadraticCurveTo", + "rect", "restore", "rotate", "save", "scale", "scrollPathIntoView", "setLineDash", "setTransform", + "stroke", "strokeRect", "strokeText", "transform", "translate" }; + final String html = "<html><body>\n" + + "<canvas id='myCanvas'></canvas>\n" + + "<script>\n" + + " var canvas = document.getElementById('myCanvas');\n" + + " var nbMethods = 0;\n" + + " var methods = ['" + StringUtils.join(methods, "', '") + "'];\n" + + " try {\n" + + " var ctx = canvas.getContext('2d');\n" + + " for (var i=0; i<methods.length; ++i) {\n" + + " if (typeof ctx[methods[i]] == 'function')\n" + + " nbMethods++;\n" + + " else\n" + + " alert(methods[i]);\n" + + " }\n" + + " alert(nbMethods + ' methods');\n" + + " } catch(e) { alert('exception'); }\n" + + "</script></body></html>"; + loadPageWithAlerts2(html); + } } |
From: <mgu...@us...> - 2013-02-06 16:32:33
|
Revision: 8102 http://sourceforge.net/p/htmlunit/code/8102 Author: mguillem Date: 2013-02-06 16:32:30 +0000 (Wed, 06 Feb 2013) Log Message: ----------- Content-Type: text/plain;charset=utf-8 is an allowed header Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequestCORSTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java 2013-02-06 16:27:22 UTC (rev 8101) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequest.java 2013-02-06 16:32:30 UTC (rev 8102) @@ -728,14 +728,19 @@ */ private boolean isPreflightHeader(final String name, final String value) { if ("content-type".equals(name)) { - return !"application/x-www-form-urlencoded".equals(value) - && !"multipart/form-data".equals(value) && !"text/plain".equals(value); - } - if (!"accept".equals(name) && !"accept-language".equals(name) && !"content-language".equals(name) - && !"referer".equals(name) && !"accept-encoding".equals(name) && !"origin".equals(name)) { + if ("application/x-www-form-urlencoded".equals(value) + || "multipart/form-data".equals(value) + || "text/plain".equals(value) + || value.startsWith("text/plain;charset=")) { + return false; + } return true; } - return false; + if ("accept".equals(name) || "accept-language".equals(name) || "content-language".equals(name) + || "referer".equals(name) || "accept-encoding".equals(name) || "origin".equals(name)) { + return false; + } + return true; } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequestCORSTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequestCORSTest.java 2013-02-06 16:27:22 UTC (rev 8101) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLHttpRequestCORSTest.java 2013-02-06 16:32:30 UTC (rev 8102) @@ -176,10 +176,20 @@ @Alerts(IE = { "4", "200", "null", "null", "null", "null" }, DEFAULT = { "4", "200", "§§URL§§", "§§URL§§", "GET", "x-pingother" }) public void preflight() throws Exception { - doPreflightTestAllowedMethods("POST, GET, OPTIONS"); + doPreflightTestAllowedMethods("POST, GET, OPTIONS", "text/plain"); } /** + * @throws Exception if the test fails. + */ + @Test + @Alerts(IE = { "4", "200", "null", "null", "null", "null" }, + DEFAULT = { "4", "200", "§§URL§§", "§§URL§§", "GET", "x-pingother" }) + public void preflight_contentTypeWithCharset() throws Exception { + doPreflightTestAllowedMethods("POST, GET, OPTIONS", "text/plain;charset=utf-8"); + } + + /** * Seems that "Access-Control-Allow-Methods" is not considered by FF. * * @throws Exception if the test fails. @@ -188,10 +198,11 @@ @Alerts(IE = { "4", "200", "null", "null", "null", "null" }, DEFAULT = { "4", "200", "§§URL§§", "§§URL§§", "GET", "x-pingother" }) public void preflight_incorrect_methods() throws Exception { - doPreflightTestAllowedMethods(null); + doPreflightTestAllowedMethods(null, "text/plain"); } - private void doPreflightTestAllowedMethods(final String allowedMethods) throws Exception { + private void doPreflightTestAllowedMethods(final String allowedMethods, final String contentType) + throws Exception { expandExpectedAlertsVariables(new URL("http://localhost:" + PORT)); // url without trailing "/" final String html = "<html><head>\n" @@ -202,7 +213,7 @@ + " var url = 'http://' + window.location.hostname + ':" + PORT2 + "/preflight2';\n" + " xhr.open('GET', url, false);\n" + " xhr.setRequestHeader('X-PINGOTHER', 'pingpong');\n" - + " xhr.setRequestHeader('Content-Type' , 'text/plain');" + + " xhr.setRequestHeader('Content-Type' , '" + contentType + "');" + " xhr.send();\n" + " alert(xhr.readyState);\n" + " alert(xhr.status);\n" |
From: <mgu...@us...> - 2013-02-14 14:15:53
|
Revision: 8108 http://sourceforge.net/p/htmlunit/code/8108 Author: mguillem Date: 2013-02-14 14:15:49 +0000 (Thu, 14 Feb 2013) Log Message: ----------- CookieManager: changed getCookies to return a copy of the current set of cookies to avoid ConcurrentModificationException. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/CookieManager.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/CookieManager2Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-02-12 17:50:28 UTC (rev 8107) +++ trunk/htmlunit/src/changes/changes.xml 2013-02-14 14:15:49 UTC (rev 8108) @@ -9,6 +9,9 @@ <body> <release version="2.12" date="???" description="Bugfixes, CSS3 Selectors"> <action type="fix" dev="mguillem"> + CookieManager: changed getCookies to return a copy of the current set of cookies to avoid ConcurrentModificationException. + </action> + <action type="fix" dev="mguillem"> JavaScript: add empty implementations of CanvasRenderingContext2D methods createImageData, createPattern, createRadialGradient, fillText, getImageData, getLineData, isPointInPath, measureText, putImageData, rect, rotate, setTransform, strokeText, and transform (FF). Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/CookieManager.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/CookieManager.java 2013-02-12 17:50:28 UTC (rev 8107) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/CookieManager.java 2013-02-14 14:15:49 UTC (rev 8108) @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Date; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; @@ -89,7 +90,8 @@ * @return the currently configured cookies, in an unmodifiable set */ public synchronized Set<Cookie> getCookies() { - return Collections.unmodifiableSet(cookies_); + final Set<Cookie> copy = new HashSet<Cookie>(cookies_); + return Collections.unmodifiableSet(copy); } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/CookieManager2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/CookieManager2Test.java 2013-02-12 17:50:28 UTC (rev 8107) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/CookieManager2Test.java 2013-02-14 14:15:49 UTC (rev 8108) @@ -16,6 +16,7 @@ import java.net.URL; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.Set; @@ -121,4 +122,31 @@ final Set<Cookie> cookies = webClient.getCookieManager().getCookies(htmlPage.getUrl()); assertTrue(cookies.toString(), cookies.isEmpty()); } + + /** + * This was causing a ConcurrentModificationException. + * In "real life" the problem was arising due to changes to the cookies made from + * the JS processing thread. + * @throws Exception if the test fails + */ + @Test + public void getCookiesShouldReturnACopyOfCurentState() throws Exception { + final String html = "<html><body>" + + "<button id='it' onclick=\"document.cookie = 'foo=bla'\">click me</button>\n" + + "<script>\n" + + "document.cookie = 'cookie1=value1';\n" + + "</script></body></html>"; + + final WebClient webClient = getWebClient(); + + final HtmlPage page = loadPage(html); + final Set<Cookie> initialCookies = webClient.getCookieManager().getCookies(); + assertEquals(1, initialCookies.size()); + final Iterator<Cookie> iterator = initialCookies.iterator(); + + page.getHtmlElementById("it").click(); + iterator.next(); // ConcurrentModificationException was here + assertEquals(1, initialCookies.size()); + assertEquals(2, webClient.getCookieManager().getCookies().size()); + } } |
From: <mgu...@us...> - 2013-02-15 08:29:33
|
Revision: 8116 http://sourceforge.net/p/htmlunit/code/8116 Author: mguillem Date: 2013-02-15 08:29:30 +0000 (Fri, 15 Feb 2013) Log Message: ----------- - don't bubble focus event if the element is not "focusable" - HtmlAnchor is "focusable" Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/FocusableElementTest.java Added Paths: ----------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/FocusableElement2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2013-02-14 21:29:25 UTC (rev 8115) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2013-02-15 08:29:30 UTC (rev 8116) @@ -854,6 +854,10 @@ return null; } + if (!event.applies(this)) { + return null; + } + if (LOG.isDebugEnabled()) { LOG.debug("Firing " + event); } @@ -1181,7 +1185,8 @@ mouseDown(shiftKey, ctrlKey, altKey, MouseEvent.BUTTON_LEFT); // give focus to current element (if possible) or only remove it from previous one - final HtmlElement elementToFocus = this instanceof SubmittableElement ? this : null; + final HtmlElement elementToFocus = (this instanceof SubmittableElement || this instanceof HtmlAnchor) + ? this : null; ((HtmlPage) getPage()).setFocusedElement(elementToFocus); mouseUp(shiftKey, ctrlKey, altKey, MouseEvent.BUTTON_LEFT); Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java 2013-02-14 21:29:25 UTC (rev 8115) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java 2013-02-15 08:29:30 UTC (rev 8116) @@ -84,6 +84,7 @@ import com.gargoylesoftware.htmlunit.html.DomText; import com.gargoylesoftware.htmlunit.html.HTMLParser; import com.gargoylesoftware.htmlunit.html.HtmlAnchor; +import com.gargoylesoftware.htmlunit.html.HtmlArea; import com.gargoylesoftware.htmlunit.html.HtmlBody; import com.gargoylesoftware.htmlunit.html.HtmlDivision; import com.gargoylesoftware.htmlunit.html.HtmlElement; @@ -91,6 +92,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage; import com.gargoylesoftware.htmlunit.html.HtmlTable; import com.gargoylesoftware.htmlunit.html.HtmlTableDataCell; +import com.gargoylesoftware.htmlunit.html.SubmittableElement; import com.gargoylesoftware.htmlunit.javascript.NamedNodeMap; import com.gargoylesoftware.htmlunit.javascript.ScriptableWithFallbackGetter; import com.gargoylesoftware.htmlunit.javascript.background.BackgroundJavaScriptFactory; @@ -1974,7 +1976,13 @@ */ @JsxFunction public void focus() { - getDomNodeOrDie().focus(); + final HtmlElement domNode = getDomNodeOrDie(); + if (domNode instanceof SubmittableElement || domNode instanceof HtmlAnchor + || domNode instanceof HtmlArea) { + domNode.focus(); + } + + // no action otherwise! } /** Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/FocusableElement2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/FocusableElement2Test.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/FocusableElement2Test.java 2013-02-15 08:29:30 UTC (rev 8116) @@ -0,0 +1,275 @@ +/* + * Copyright (c) 2002-2013 Gargoyle Software Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gargoylesoftware.htmlunit.html; + +import java.util.Arrays; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.BuggyWebDriver; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; + +/** + * Tests for elements with onblur and onfocus attributes. + * + * @version $Revision$ + * @author David D. Kilzer + * @author Marc Guillemot + * @author Ahmed Ashour + */ +@RunWith(BrowserRunner.class) +public class FocusableElement2Test extends WebDriverTestCase { + private static final String COMMON_ID = " id='focusId'"; + private static final String COMMON_EVENTS = " onblur=\"alert('onblur')\" onfocus=\"alert('onfocus')\""; + private static final String COMMON_ATTRIBUTES = COMMON_ID + COMMON_EVENTS; + + /** + * Full page driver for onblur and onfocus tests. + * + * @param html HTML fragment for body of page with a focusable element identified by a focusId ID attribute + * Must have onfocus event that raises an alert of "foo1 onfocus" and an onblur event that raises an alert of "foo + * onblur" on the second element. + * @throws Exception if the test fails + */ + private void testTagWithClick(String tag) throws Exception { + tag = tag.replaceFirst(">", COMMON_ATTRIBUTES + ">"); + testWithClick(tag); + } + + private void testWithClick(final String body) throws Exception { + final String html = "<html><head><title>foo</title></head><body>\n" + + body + + "<div id='other'>other</div>\n" + + "</body></html>"; + + final WebDriver driver = loadPage2(html); + + driver.findElement(By.id("focusId")).click(); + driver.findElement(By.id("other")).click(); + + assertEquals(getExpectedAlerts(), getCollectedAlerts(driver)); + } + + private void testWithCallFocusBlur(String tag) throws Exception { + tag = tag.replaceFirst(">", COMMON_ATTRIBUTES + ">"); + + final String html = "<html><head><title>foo</title></head><body>\n" + + tag + + "<script type=\"text/javascript\" language=\"JavaScript\">\n" + + "document.getElementById('focusId').focus();\n" + + "document.getElementById('focusId').blur();\n" + + "</script>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * Test onblur and onfocus handlers and blur() and focus() methods of anchor element. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "onfocus", "onblur" }) + public void anchor_onblur_onfocus() throws Exception { + testTagWithClick("<a href='javascript:void(0)'>link</a>"); + } + + /** + * Test onblur and onfocus handlers and blur() and focus() methods of anchor element. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "onfocus", "onblur" }) + public void anchor_onblur_onfocus_methodsCalls() throws Exception { + testWithCallFocusBlur("<a href='.'>link</a>"); + } + + /** + * Test onblur and onfocus handlers and blur() and focus() methods of anchor element. + * + * @throws Exception if the test fails + */ + @Test + public void div_onblur_onfocus() throws Exception { + testTagWithClick("<div>hello</div>"); + } + + /** + * Test onblur and onfocus handlers and blur() and focus() methods of anchor element. + * + * @throws Exception if the test fails + */ + @Test + public void div_onblur_onfocus_methods() throws Exception { + testTagWithClick("<div>hello</div>"); + } + + /** + * Test onblur and onfocus handlers and blur() and focus() methods of button element. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "onfocus", "onblur" }) + public void testButton_onblur_onfocus() throws Exception { + testTagWithClick("<button name='foo' value='bar' type='button'>button</button>"); + } + + /** + * Test onblur and onfocus handlers and blur() and focus() methods of label element surrounding input element. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "onfocus", "onblur" }) + public void testLabelContainsInput_onblur_onfocus() throws Exception { + final String body = "<form><label " + COMMON_ID + ">" + + "Foo<input type=\"text\" name=\"foo\"" + COMMON_EVENTS + "></label></form>\n"; + testWithClick(body); + } + + /** + * Test onblur and onfocus handlers and blur() and focus() methods of label element referencing an input element. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "onfocus", "onblur" }) + public void testLabelReferencesInput_onblur_onfocus() throws Exception { + final String body = "<form><label " + COMMON_ID + " for=\"fooId\">Foo</label>\n" + + "<input type=\"text\" name=\"foo\" id=\"fooId\"" + COMMON_EVENTS + "></form>\n"; + testWithClick(body); + } + + /** + * Test onblur and onfocus handlers and blur() and focus() methods of select element. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "onfocus", "onblur" }) + public void testSelect_onblur_onfocus() throws Exception { + testTagWithClick("<select><option>1</option></select>"); + } + + /** + * Test onblur and onfocus handlers and blur() and focus() methods of textarea element. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "onfocus", "onblur" }) + public void testTextarea_onblur_onfocus() throws Exception { + testTagWithClick("<textarea>Text</textarea>"); + } + + /** + * Test that focus() called on a non focusable element doesn't trigger document's focus handlers. + * + * @throws Exception if the test fails + */ + @Test + public void focusOnNonFocusableElementShouldNotTriggerDocumentFocus() throws Exception { + final String html = "<html><body>\n" + + "<div id='it'>div</div>\n" + + "<textarea id='log'></textarea>\n" + + "<script>\n" + + "function log(x) {\n" + + " document.getElementById('log').value += x + '\\n';\n" + + "}\n" + + "function ff() {\n" + + " log('focus');\n" + + "}\n" + + "if (document.addEventListener) {\n" + + " document.addEventListener('focus', ff, true);\n" + + "}\n" + + "else {\n" + + " document.attachEvent('onfocus', ff);\n" + + "}\n" + + "document.getElementById('it').focus();\n" + + "document.getElementById('it').blur();\n" + + "log('done');\n" + + "</script>\n" + + "</body></html>"; + + final WebDriver driver = loadPageWithAlerts2(html); + assertEquals("done", driver.findElement(By.id("log")).getAttribute("value").trim()); + } + + /** + * Test that focus() called on a non focusable element doesn't let focused element loose the focus. + * + * @throws Exception if the test fails + */ + @Test + @BuggyWebDriver + @Alerts({ "input1", "focus1", "div", "input2", "blur1", "focus2" }) + public void focusOnNonFocusableElementShouldNotChangeCurrentFocus() throws Exception { + final String html = "<html><body>\n" + + "<textarea id='log'></textarea>\n" + + "<div id='div' onblur=\"log('blur')\" onfocus=\"log('focus')\">div</div>\n" + + "<input id='input1' onblur=\"log('blur1')\" onfocus=\"log('focus1')\">\n" + + "<input id='input2' onblur=\"log('blur2')\" onfocus=\"log('focus2')\">\n" + + "<script>\n" + + " function log(x) {\n" + + " document.getElementById('log').value += x + '\\n';\n" + + " }\n" + + " \n" + + " log('input1');\n" + + " document.getElementById('input1').focus();\n" + + " log('div');\n" + + " document.getElementById('div').focus();\n" + + " log('input2');\n" + + " document.getElementById('input2').focus();\n" + + "</script></body></html>"; + + final WebDriver driver = loadPage2(html); + final String[] alerts = driver.findElement(By.id("log")).getAttribute("value").split("\r?\n"); + assertEquals(getExpectedAlerts(), Arrays.asList(alerts)); + } + + /** + * Test that click called on a non focusable element removes focus from focused element. + * + * @throws Exception if the test fails + */ + @Test + @Alerts({ "focus1", "blur1" }) + public void clickOnNonFocusableElementChangesCurrentFocus() throws Exception { + final String html = "<html><body>\n" + + "<textarea id='log'></textarea>\n" + + "<div id='div' onblur=\"log('blur')\" onfocus=\"log('focus')\">div</div>\n" + + "<input id='input1' onblur=\"log('blur1')\" onfocus=\"log('focus1')\">\n" + + "<script>\n" + + " function log(x) {\n" + + " document.getElementById('log').value += x + '\\n';\n" + + " }\n" + + " \n" + + "</script></body></html>"; + + final WebDriver driver = loadPage2(html); + driver.findElement(By.id("input1")).click(); + driver.findElement(By.id("div")).click(); + final String[] alerts = driver.findElement(By.id("log")).getAttribute("value").split("\r?\n"); + assertEquals(getExpectedAlerts(), Arrays.asList(alerts)); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/FocusableElement2Test.java ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Author Date Id Revision \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/FocusableElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/FocusableElementTest.java 2013-02-14 21:29:25 UTC (rev 8115) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/FocusableElementTest.java 2013-02-15 08:29:30 UTC (rev 8116) @@ -14,9 +14,6 @@ */ package com.gargoylesoftware.htmlunit.html; -import java.util.ArrayList; -import java.util.List; - import org.junit.Test; import org.junit.runner.RunWith; @@ -34,132 +31,7 @@ @RunWith(BrowserRunner.class) public class FocusableElementTest extends SimpleWebTestCase { - private static final String COMMON_ID = " id='focusId'"; - private static final String COMMON_EVENTS = " onblur=\"alert('foo onblur')\" onfocus=\"alert('foo onfocus')\""; - private static final String COMMON_ATTRIBUTES = COMMON_ID + COMMON_EVENTS; - /** - * Full page driver for onblur and onfocus tests. - * - * @param htmlContent HTML fragment for body of page with a focusable element identified by a focusId ID attribute - * Must have onfocus event that raises an alert of "foo1 onfocus" and an onblur event that raises an alert of "foo - * onblur" on the second element. - * @throws Exception if the test fails - */ - private void onClickPageTest(final String htmlContent) throws Exception { - final List<String> collectedAlerts = new ArrayList<String>(); - final HtmlPage page = loadPage(getBrowserVersion(), htmlContent, collectedAlerts); - final HtmlElement element = page.getHtmlElementById("focusId"); - - element.focus(); - element.blur(); - - final String[] expectedAlerts = {"foo onfocus", "foo onblur", "foo onfocus", "foo onblur"}; - assertEquals(expectedAlerts, collectedAlerts); - } - - /** - * Body driver for onblur and onfocus tests. - * - * @param htmlBodyContent HTML tag name for simple tag with text body - * @throws Exception if the test fails - */ - private void onClickBodyTest(final String htmlBodyContent) throws Exception { - onClickPageTest("<html><head><title>foo</title></head><body>\n" - + htmlBodyContent - + "<script type=\"text/javascript\" language=\"JavaScript\">\n" - + "document.getElementById('focusId').focus();\n" - + "document.getElementById('focusId').blur();\n" - + "</script></body></html>"); - } - - /** - * Simple tag name driver for onblur and onfocus tests. - * - * @param tagName HTML tag name for simple tag with text body - * @param tagAttributes additional attribute(s) to add to the generated tag - * @throws Exception if the test fails - */ - private void onClickSimpleTest(final String tagName, final String tagAttributes) throws Exception { - onClickBodyTest("<" + tagName + COMMON_ATTRIBUTES - + " " + tagAttributes + ">Text</" + tagName + ">"); - } - - /** - * Test onblur and onfocus handlers and blur() and focus() methods of anchor element. - * - * @throws Exception if the test fails - */ - @Test - public void anchor_onblur_onfocus() throws Exception { - onClickSimpleTest("a", "href=\".\""); - } - - /** - * Test onblur and onfocus handlers and blur() and focus() methods of area element. - * - * @throws Exception if the test fails - */ - @Test - public void area_onblur_onfocus() throws Exception { - onClickBodyTest("<map><area " + COMMON_ATTRIBUTES - + " shape=\"rect\" coords=\"0,0,1,1\" href=\".\">\n" - + "</area></map>"); - } - - /** - * Test onblur and onfocus handlers and blur() and focus() methods of button element. - * - * @throws Exception if the test fails - */ - @Test - public void testButton_onblur_onfocus() throws Exception { - onClickSimpleTest("button", "name=\"foo\" value=\"bar\" type=\"button\""); - } - - /** - * Test onblur and onfocus handlers and blur() and focus() methods of label element surrounding input element. - * - * @throws Exception if the test fails - */ - @Test - public void testLabelContainsInput_onblur_onfocus() throws Exception { - onClickBodyTest("<form><label " + COMMON_ID + ">" - + "Foo<input type=\"text\" name=\"foo\"" + COMMON_EVENTS + "></label></form>\n"); - } - - /** - * Test onblur and onfocus handlers and blur() and focus() methods of label element referencing an input element. - * - * @throws Exception if the test fails - */ - @Test - public void testLabelReferencesInput_onblur_onfocus() throws Exception { - onClickBodyTest("<form><label " + COMMON_ID + " for=\"fooId\">Foo</label>\n" - + "<input type=\"text\" name=\"foo\" id=\"fooId\"" + COMMON_EVENTS + "></form>\n"); - } - - /** - * Test onblur and onfocus handlers and blur() and focus() methods of select element. - * - * @throws Exception if the test fails - */ - @Test - public void testSelect_onblur_onfocus() throws Exception { - onClickBodyTest("<form><select " + COMMON_ATTRIBUTES + "><option>1</option></select></form>\n"); - } - - /** - * Test onblur and onfocus handlers and blur() and focus() methods of textarea element. - * - * @throws Exception if the test fails - */ - @Test - public void testTextarea_onblur_onfocus() throws Exception { - onClickBodyTest("<form><textarea " + COMMON_ATTRIBUTES + ">Text</textarea></form>\n"); - } - - /** * Regression test for https://sourceforge.net/tracker/?func=detail&atid=448266&aid=1161705&group_id=47038. * @throws Exception if the test fails */ |
From: <mgu...@us...> - 2013-02-19 08:25:13
|
Revision: 8122 http://sourceforge.net/p/htmlunit/code/8122 Author: mguillem Date: 2013-02-19 08:25:09 +0000 (Tue, 19 Feb 2013) Log Message: ----------- Fixed synchronization problem causing a task triggered by setTimeout to be executed to early, before event handlers. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-02-18 23:17:16 UTC (rev 8121) +++ trunk/htmlunit/src/changes/changes.xml 2013-02-19 08:25:09 UTC (rev 8122) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes, CSS3 Selectors"> + <action type="fix"> + Fixed synchronization problem causing a task triggered by setTimeout to be executed to early, before event handlers. + </action> <action type="fix" dev="mguillem"> CookieManager: changed getCookies to return a copy of the current set of cookies to avoid ConcurrentModificationException. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2013-02-18 23:17:16 UTC (rev 8121) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlElement.java 2013-02-19 08:25:09 UTC (rev 8122) @@ -1176,24 +1176,27 @@ throws IOException { // make enclosing window the current one - getPage().getWebClient().setCurrentWindow(getPage().getEnclosingWindow()); + final SgmlPage page = getPage(); + page.getWebClient().setCurrentWindow(page.getEnclosingWindow()); if (this instanceof DisabledElement && ((DisabledElement) this).isDisabled()) { - return (P) getPage(); + return (P) page; } - mouseDown(shiftKey, ctrlKey, altKey, MouseEvent.BUTTON_LEFT); + synchronized (page) { + mouseDown(shiftKey, ctrlKey, altKey, MouseEvent.BUTTON_LEFT); - // give focus to current element (if possible) or only remove it from previous one - final HtmlElement elementToFocus = (this instanceof SubmittableElement || this instanceof HtmlAnchor) - ? this : null; - ((HtmlPage) getPage()).setFocusedElement(elementToFocus); + // give focus to current element (if possible) or only remove it from previous one + final HtmlElement elementToFocus = (this instanceof SubmittableElement || this instanceof HtmlAnchor) + ? this : null; + ((HtmlPage) page).setFocusedElement(elementToFocus); - mouseUp(shiftKey, ctrlKey, altKey, MouseEvent.BUTTON_LEFT); + mouseUp(shiftKey, ctrlKey, altKey, MouseEvent.BUTTON_LEFT); - final Event event = new MouseEvent(getEventTargetElement(), MouseEvent.TYPE_CLICK, shiftKey, ctrlKey, altKey, - MouseEvent.BUTTON_LEFT); - return (P) click(event); + final Event event = new MouseEvent(getEventTargetElement(), MouseEvent.TYPE_CLICK, shiftKey, + ctrlKey, altKey, MouseEvent.BUTTON_LEFT); + return (P) click(event); + } } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java 2013-02-18 23:17:16 UTC (rev 8121) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java 2013-02-19 08:25:09 UTC (rev 8122) @@ -21,6 +21,8 @@ import org.apache.commons.lang3.StringUtils; import org.junit.Test; import org.junit.runner.RunWith; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; import org.openqa.selenium.htmlunit.HtmlUnitDriver; import com.gargoylesoftware.htmlunit.BrowserRunner; @@ -1085,4 +1087,39 @@ loadPageWithAlerts2(html); } + + /** + * As of 2.12-SNAPSHOT on 19.02.2013, a task started by setTimeout in an event handler could be executed before + * all events handlers have been executed due to a missing synchronization. + * @throws Exception if the test fails + */ + @Test + public void setTimeoutShouldNotBeExecutedBeforeHandlers() throws Exception { + final String html + = "<html><body><script>\n" + + "function stop() {\n" + + " window.stopIt = true;\n" + + "}\n" + + "for (var i=0; i<1000; ++i) {\n" + + " var handler = function(e) {\n" + + " if (window.stopIt) {\n" + + " e.preventDefault ? e.preventDefault() : e.returnValue = false;\n" + + " }\n" + + " }\n" + + " if (window.addEventListener)\n" + + " window.addEventListener('click', handler, false);\n" + + " else\n" + + " window.attachEvent('onclick', handler);\n" + + "}\n" + + "</script>\n" + + "<form action='page2' method='post'>\n" + + "<input id='it' type='submit' onclick='setTimeout(stop, 0)'>\n" + + "</form>" + + "</body></html>"; + + final WebDriver driver = loadPage2(html); + driver.findElement(By.id("it")).click(); + + assertEquals(getDefaultUrl() + "page2", driver.getCurrentUrl()); + } } |
From: <rb...@us...> - 2013-02-19 16:17:58
|
Revision: 8126 http://sourceforge.net/p/htmlunit/code/8126 Author: rbri Date: 2013-02-19 16:17:51 +0000 (Tue, 19 Feb 2013) Log Message: ----------- checkstyle fixes Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/DefaultJavaScriptExecutor.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Document.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/CookieManagerTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/DefaultJavaScriptExecutor.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/DefaultJavaScriptExecutor.java 2013-02-19 11:18:02 UTC (rev 8125) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/background/DefaultJavaScriptExecutor.java 2013-02-19 16:17:51 UTC (rev 8126) @@ -135,7 +135,7 @@ /** Runs the eventLoop. */ public void run() { - boolean trace = LOG.isTraceEnabled(); + final boolean trace = LOG.isTraceEnabled(); // this has to be a multiple of 10ms // otherwise the VM has to fight with the OS to get such small periods final long sleepInterval = 10; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Document.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Document.java 2013-02-19 11:18:02 UTC (rev 8125) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Document.java 2013-02-19 16:17:51 UTC (rev 8126) @@ -192,7 +192,7 @@ // IE ignores designMode changes for documents that aren't in frames. return; } - + if ("on".equalsIgnoreCase(mode)) { designMode_ = "On"; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2013-02-19 11:18:02 UTC (rev 8125) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2013-02-19 16:17:51 UTC (rev 8126) @@ -1593,7 +1593,7 @@ style = new ComputedCSSStyleDeclaration(original); final StyleSheetList sheets = ((HTMLDocument) document_).getStyleSheets(); - boolean trace = LOG.isTraceEnabled(); + final boolean trace = LOG.isTraceEnabled(); for (int i = 0; i < sheets.getLength(); i++) { final CSSStyleSheet sheet = (CSSStyleSheet) sheets.item(i); if (sheet.isActive()) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/CookieManagerTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/CookieManagerTest.java 2013-02-19 11:18:02 UTC (rev 8125) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/CookieManagerTest.java 2013-02-19 16:17:51 UTC (rev 8126) @@ -184,7 +184,6 @@ driver.get(URL_SECOND.toExternalForm()); - // strange check, but there is no order final String lastCookies = getMockWebConnection().getLastAdditionalHeaders().get("Cookie"); assertEquals(26, lastCookies.length()); |
From: <mgu...@us...> - 2013-02-21 14:29:58
|
Revision: 8127 http://sourceforge.net/p/htmlunit/code/8127 Author: mguillem Date: 2013-02-21 14:29:53 +0000 (Thu, 21 Feb 2013) Log Message: ----------- JavaScript: add support for window.onchange handler (FF10+ and Chrome) (thanks to Hartmut Arlt) Issue 1484 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-02-19 16:17:51 UTC (rev 8126) +++ trunk/htmlunit/src/changes/changes.xml 2013-02-21 14:29:53 UTC (rev 8127) @@ -8,7 +8,10 @@ <body> <release version="2.12" date="???" description="Bugfixes, CSS3 Selectors"> - <action type="fix"> + <action type="fix" dev="mguillem" issue="1484" due-to="Hartmut Arlt"> + JavaScript: add support for window.onchange handler (FF10+ and Chrome). + </action> + <action type="fix" dev="mguillem"> Fixed synchronization problem causing a task triggered by setTimeout to be executed to early, before event handlers. </action> <action type="fix" dev="mguillem"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2013-02-19 16:17:51 UTC (rev 8126) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2013-02-21 14:29:53 UTC (rev 8127) @@ -2010,6 +2010,24 @@ final ScriptResult result = Node.fireEvent(this, event); return !event.isAborted(result); } + + /** + * Getter for the onchange event handler. + * @return the handler + */ + @JsxGetter({@WebBrowser(value = FF, minVersion = 10), @WebBrowser(CHROME) }) + public Object getOnchange() { + return getHandlerForJavaScript(Event.TYPE_CHANGE); + } + + /** + * Setter for the onchange event handler. + * @param onchange the handler + */ + @JsxSetter({@WebBrowser(value = FF, minVersion = 10), @WebBrowser(CHROME) }) + public void setOnchange(final Object onchange) { + setHandlerForJavaScript(Event.TYPE_CHANGE, onchange); + } } class HTMLCollectionFrames extends HTMLCollection { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java 2013-02-19 16:17:51 UTC (rev 8126) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Window2Test.java 2013-02-21 14:29:53 UTC (rev 8127) @@ -1122,4 +1122,43 @@ assertEquals(getDefaultUrl() + "page2", driver.getCurrentUrl()); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "true", "null" }, + FF3_6 = { "false", "undefined" }, + IE = { "false", "undefined" }) + public void onchange_noHandler() throws Exception { + final String html + = "<html><body><script>\n" + + "alert('onchange' in window);\n" + + "alert(window.onchange);\n" + + "</script></body></html>"; + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "changed" }, + FF3_6 = { }, + IE = { }) + public void onchange_withHandler() throws Exception { + final String html + = "<html><body>\n" + + "<input id='it'/>\n" + + "<script>\n" + + "window.onchange = function() {\n" + + " alert('changed');\n" + + "}\n" + + "</script></body></html>"; + final WebDriver driver = loadPage2(html); + driver.findElement(By.id("it")).sendKeys("hello"); + driver.findElement(By.tagName("body")).click(); + + assertEquals(getExpectedAlerts(), getCollectedAlerts(driver)); + } } |
From: <mgu...@us...> - 2013-02-25 11:05:28
|
Revision: 8134 http://sourceforge.net/p/htmlunit/code/8134 Author: mguillem Date: 2013-02-25 11:05:24 +0000 (Mon, 25 Feb 2013) Log Message: ----------- BrowserVersion: support FF17, deprecate FF3.6. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-02-25 08:37:44 UTC (rev 8133) +++ trunk/htmlunit/src/changes/changes.xml 2013-02-25 11:05:24 UTC (rev 8134) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes, CSS3 Selectors"> + <action type="update" dev="mguillem"> + BrowserVersion: support FF17, deprecate FF3.6. + </action> <action type="fix" dev="mguillem" issue="1484" due-to="Hartmut Arlt"> JavaScript: add support for window.onchange handler (FF10+ and Chrome). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2013-02-25 08:37:44 UTC (rev 8133) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersion.java 2013-02-25 11:05:24 UTC (rev 8134) @@ -110,7 +110,11 @@ */ private static final String PLATFORM_WIN32 = "Win32"; - /** Firefox 3.6. */ + /** + * Firefox 3.6. + * @deprecated as of 2.12. Use FF17 instead. + **/ + @Deprecated public static final BrowserVersion FIREFOX_3_6 = new BrowserVersion( NETSCAPE, "5.0 (Windows; en-US)", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28", @@ -118,7 +122,7 @@ /** * Firefox 10. Warning: experimental!!!. - * @deprecated as of 2.12 + * @deprecated as of 2.12. Use FF17 instead. */ @Deprecated public static final BrowserVersion FIREFOX_10 = new BrowserVersion( @@ -126,7 +130,10 @@ "Mozilla/5.0 (Windows NT 6.1; rv:10.0.11) Gecko/20100101 Firefox/10.0.11", (float) 10.0, "FF10", null); - /** Firefox 17 ESR. Work In Progress!!! */ + /** + * Firefox 17 ESR. + * @since 2.12 + **/ public static final BrowserVersion FIREFOX_17 = new BrowserVersion( NETSCAPE, "5.0 (Windows)", "Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0", |
From: <asa...@us...> - 2013-03-07 10:04:17
|
Revision: 8146 http://sourceforge.net/p/htmlunit/code/8146 Author: asashour Date: 2013-03-07 10:04:13 +0000 (Thu, 07 Mar 2013) Log Message: ----------- Remove deprecated BaseFrame. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFrame.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlInlineFrame.java Removed Paths: ------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrame.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-03-06 08:58:49 UTC (rev 8145) +++ trunk/htmlunit/src/changes/changes.xml 2013-03-07 10:04:13 UTC (rev 8146) @@ -7,6 +7,11 @@ </properties> <body> + <release version="2.13" date="???" description="Bugfixes"> + <action type="remove" dev="asashour"> + Remove deprecated BaseFrame. + </action> + </release> <release version="2.12" date="Mar 6, 2013" description="Bugfixes, CSS3 Selectors"> <action type="update" dev="mguillem"> BrowserVersion: support FF17, deprecate FF3.6. Deleted: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrame.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrame.java 2013-03-06 08:58:49 UTC (rev 8145) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrame.java 2013-03-07 10:04:13 UTC (rev 8146) @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2002-2013 Gargoyle Software Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.gargoylesoftware.htmlunit.html; - -import java.util.Map; - -import com.gargoylesoftware.htmlunit.SgmlPage; - -/** - * Base class for frame and iframe. - * - * @version $Revision$ - * @author <a href="mailto:mb...@Ga...">Mike Bowler</a> - * @author David K. Taylor - * @author <a href="mailto:cs...@dy...">Christian Sell</a> - * @author Marc Guillemot - * @author David D. Kilzer - * @author Stefan Anzinger - * @author Ahmed Ashour - * @author Dmitri Zoubkov - * @author Daniel Gredler - * @author Ronald Brill - * @deprecated as of 2.11, please use {@link BaseFrameElement} instead - */ -@Deprecated -public abstract class BaseFrame extends BaseFrameElement { - - /** - * Creates an instance of BaseFrame. - * - * @param namespaceURI the URI that identifies an XML namespace - * @param qualifiedName the qualified name of the element type to instantiate - * @param page the HtmlPage that contains this element - * @param attributes the initial attributes - */ - protected BaseFrame(final String namespaceURI, final String qualifiedName, final SgmlPage page, - final Map<String, DomAttr> attributes) { - super(namespaceURI, qualifiedName, page, attributes); - } -} Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFrame.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFrame.java 2013-03-06 08:58:49 UTC (rev 8145) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlFrame.java 2013-03-07 10:04:13 UTC (rev 8146) @@ -28,7 +28,7 @@ * @author Marc Guillemot * @author Ahmed Ashour */ -public class HtmlFrame extends BaseFrame { +public class HtmlFrame extends BaseFrameElement { /** The HTML tag represented by this element. */ public static final String TAG_NAME = "frame"; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlInlineFrame.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlInlineFrame.java 2013-03-06 08:58:49 UTC (rev 8145) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlInlineFrame.java 2013-03-07 10:04:13 UTC (rev 8146) @@ -28,7 +28,7 @@ * @author Marc Guillemot * @author Ahmed Ashour */ -public class HtmlInlineFrame extends BaseFrame { +public class HtmlInlineFrame extends BaseFrameElement { /** The HTML tag represented by this element. */ public static final String TAG_NAME = "iframe"; |
From: <asa...@us...> - 2013-03-07 10:07:32
|
Revision: 8147 http://sourceforge.net/p/htmlunit/code/8147 Author: asashour Date: 2013-03-07 10:07:29 +0000 (Thu, 07 Mar 2013) Log Message: ----------- Remove deprecated Htmlpage.getElementByAccessKey(), HtmlPage.getElementsByAccessKey() Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-03-07 10:04:13 UTC (rev 8146) +++ trunk/htmlunit/src/changes/changes.xml 2013-03-07 10:07:29 UTC (rev 8147) @@ -9,7 +9,7 @@ <body> <release version="2.13" date="???" description="Bugfixes"> <action type="remove" dev="asashour"> - Remove deprecated BaseFrame. + Remove deprecated BaseFrame, Htmlpage.getElementByAccessKey(), HtmlPage.getElementsByAccessKey() </action> </release> <release version="2.12" date="Mar 6, 2013" description="Bugfixes, CSS3 Selectors"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2013-03-07 10:04:13 UTC (rev 8146) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2013-03-07 10:07:29 UTC (rev 8147) @@ -845,58 +845,15 @@ * @param accessKey the key to look for * @return the HTML element that is assigned to the specified key or null * if no elements can be found that match the specified key. - * - * @deprecated as of 2.11, use {@link #getHtmlElementByAccessKey(char)} instead */ - @Deprecated - public HtmlElement getElementByAccessKey(final char accessKey) { - return getHtmlElementByAccessKey(accessKey); - } - - /** - * Returns the HTML element that is assigned to the specified access key. An - * access key (aka mnemonic key) is used for keyboard navigation of the - * page.<p> - * - * Only the following HTML elements may have <tt>accesskey</tt>s defined: A, AREA, - * BUTTON, INPUT, LABEL, LEGEND, and TEXTAREA. - * - * @param accessKey the key to look for - * @return the HTML element that is assigned to the specified key or null - * if no elements can be found that match the specified key. - */ public HtmlElement getHtmlElementByAccessKey(final char accessKey) { - final List<HtmlElement> elements = getElementsByAccessKey(accessKey); + final List<HtmlElement> elements = getHtmlElementsByAccessKey(accessKey); if (elements.isEmpty()) { return null; } return elements.get(0); } - /** - * Returns all the HTML elements that are assigned to the specified access key. An - * access key (aka mnemonic key) is used for keyboard navigation of the - * page.<p> - * - * The HTML specification seems to indicate that one accesskey cannot be used - * for multiple elements however Internet Explorer does seem to support this. - * It's worth noting that Mozilla does not support multiple elements with one - * access key so you are making your HTML browser specific if you rely on this - * feature.<p> - * - * Only the following HTML elements may have <tt>accesskey</tt>s defined: A, AREA, - * BUTTON, INPUT, LABEL, LEGEND, and TEXTAREA. - * - * @param accessKey the key to look for - * @return the elements that are assigned to the specified accesskey - * - * @deprecated as of 2.11, please use {@link #getHtmlElementsByAccessKey(char)} instead - */ - @Deprecated - public List<HtmlElement> getElementsByAccessKey(final char accessKey) { - return getHtmlElementsByAccessKey(accessKey); - } - /** * Returns all the HTML elements that are assigned to the specified access key. An * access key (aka mnemonic key) is used for keyboard navigation of the @@ -1511,7 +1468,7 @@ * would only happen if the access key triggered a button which in turn caused a page load) */ public HtmlElement pressAccessKey(final char accessKey) throws IOException { - final HtmlElement element = getElementByAccessKey(accessKey); + final HtmlElement element = getHtmlElementByAccessKey(accessKey); if (element != null) { element.focus(); final Page newPage; |
From: <asa...@us...> - 2013-03-08 02:58:22
|
Revision: 8148 http://sourceforge.net/p/htmlunit/code/8148 Author: asashour Date: 2013-03-08 02:58:17 +0000 (Fri, 08 Mar 2013) Log Message: ----------- WebClient: remove deprecated setPrintContentOnFailingStatusCode(), getPrintContentOnFailingStatusCode(), setThrowExceptionOnFailingStatusCode(), isThrowExceptionOnFailingStatusCode(), setJavaScriptEnabled(), isJavaScriptEnabled(), setCssEnabled(), isCssEnabled(), setAppletEnabled(), isAppletEnabled(), setPopupBlockerEnabled(), isPopupBlockerEnabled(), getHomePage(), setHomePage(), getProxyConfig(), setProxyConfig(), setRedirectEnabled(), isRedirectEnabled(), setUseInsecureSSL(), setActiveXNative(), isActiveXNative(), getTimeout(), setTimeout(), isThrowExceptionOnScriptError(), setThrowExceptionOnScriptError() and setSSLClientCertificate(). Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-03-07 10:07:29 UTC (rev 8147) +++ trunk/htmlunit/src/changes/changes.xml 2013-03-08 02:58:17 UTC (rev 8148) @@ -9,8 +9,17 @@ <body> <release version="2.13" date="???" description="Bugfixes"> <action type="remove" dev="asashour"> - Remove deprecated BaseFrame, Htmlpage.getElementByAccessKey(), HtmlPage.getElementsByAccessKey() + WebClient: remove deprecated setPrintContentOnFailingStatusCode(), getPrintContentOnFailingStatusCode(), + setThrowExceptionOnFailingStatusCode(), isThrowExceptionOnFailingStatusCode(), setJavaScriptEnabled(), + isJavaScriptEnabled(), setCssEnabled(), isCssEnabled(), setAppletEnabled(), isAppletEnabled(), + setPopupBlockerEnabled(), isPopupBlockerEnabled(), getHomePage(), setHomePage(), getProxyConfig(), + setProxyConfig(), setRedirectEnabled(), isRedirectEnabled(), setUseInsecureSSL(), setActiveXNative(), + isActiveXNative(), getTimeout(), setTimeout(), isThrowExceptionOnScriptError(), + setThrowExceptionOnScriptError() and setSSLClientCertificate(). </action> + <action type="remove" dev="asashour"> + Remove deprecated BaseFrame, Htmlpage.getElementByAccessKey(), HtmlPage.getElementsByAccessKey(). + </action> </release> <release version="2.12" date="Mar 6, 2013" description="Bugfixes, CSS3 Selectors"> <action type="update" dev="mguillem"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2013-03-07 10:07:29 UTC (rev 8147) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebClient.java 2013-03-08 02:58:17 UTC (rev 8148) @@ -31,7 +31,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; -import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.Collections; import java.util.ConcurrentModificationException; @@ -459,33 +458,6 @@ } /** - * Specify whether or not the content of the resulting document will be - * printed to the console in the event of a failing response code. - * Successful response codes are in the range 200-299. The default is true. - * - * @param enabled True to enable this feature - * @deprecated as of 2.11, please use {@link #getOptions()}.setPrintContentOnFailingStatusCode instead. - */ - @Deprecated - public void setPrintContentOnFailingStatusCode(final boolean enabled) { - getOptions().setPrintContentOnFailingStatusCode(enabled); - } - - /** - * Returns <tt>true</tt> if the content of the resulting document will be printed to - * the console in the event of a failing response code. - * - * @return <tt>true</tt> if the content of the resulting document will be printed to - * the console in the event of a failing response code - * @see #setPrintContentOnFailingStatusCode - * @deprecated as of 2.11, please use {@link #getOptions()}.getPrintContentOnFailingStatusCode instead. - */ - @Deprecated - public boolean getPrintContentOnFailingStatusCode() { - return getOptions().getPrintContentOnFailingStatusCode(); - } - - /** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span> * * <p>Logs the response's content if its status code indicates a request failure and @@ -504,30 +476,6 @@ } /** - * Specify whether or not an exception will be thrown in the event of a - * failing status code. Successful status codes are in the range 200-299. - * The default is true. - * - * @param enabled <tt>true</tt> to enable this feature - * @deprecated as of 2.11, please use {@link #getOptions()}.setThrowExceptionOnFailingStatusCode instead. - */ - @Deprecated - public void setThrowExceptionOnFailingStatusCode(final boolean enabled) { - getOptions().setThrowExceptionOnFailingStatusCode(enabled); - } - - /** - * Returns <tt>true</tt> if an exception will be thrown in the event of a failing response code. - * @return <tt>true</tt> if an exception will be thrown in the event of a failing response code - * @see #setThrowExceptionOnFailingStatusCode - * @deprecated as of 2.11, please use {@link #getOptions()}.isThrowExceptionOnFailingStatusCode instead. - */ - @Deprecated - public boolean isThrowExceptionOnFailingStatusCode() { - return getOptions().isThrowExceptionOnFailingStatusCode(); - } - - /** * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span> * * <p>Throws a {@link FailingHttpStatusCodeException} if the request's status code indicates a request @@ -609,139 +557,6 @@ } /** - * Enables/disables JavaScript support. By default, this property is enabled. - * - * @param enabled <tt>true</tt> to enable JavaScript support - * @deprecated as of 2.11, please use {@link #getOptions()}.setJavaScriptEnabled instead. - */ - @Deprecated - public void setJavaScriptEnabled(final boolean enabled) { - getOptions().setJavaScriptEnabled(enabled); - } - - /** - * Returns <tt>true</tt> if JavaScript is enabled and the script engine was loaded successfully. - * - * @return <tt>true</tt> if JavaScript is enabled - * @deprecated as of 2.11, please use {@link #getOptions()}.isJavaScriptEnabled instead. - */ - @Deprecated - public boolean isJavaScriptEnabled() { - return getOptions().isJavaScriptEnabled(); - } - - /** - * Enables/disables CSS support. By default, this property is enabled. - * - * @param enabled <tt>true</tt> to enable CSS support - * @deprecated as of 2.11, please use {@link #getOptions()}.setCssEnabled instead. - */ - @Deprecated - public void setCssEnabled(final boolean enabled) { - getOptions().setCssEnabled(enabled); - } - - /** - * Returns <tt>true</tt> if CSS is enabled. - * - * @return <tt>true</tt> if CSS is enabled - * @deprecated as of 2.11, please use {@link #getOptions()}.isCssEnabled instead. - */ - @Deprecated - public boolean isCssEnabled() { - return getOptions().isCssEnabled(); - } - - /** - * Enables/disables Applet support. By default, this property is disabled.<br/> - * <p> - * Note: as of HtmlUnit-2.4, Applet support is experimental and minimal - * </p> - * @param enabled <tt>true</tt> to enable Applet support - * @since HtmlUnit-2.4 - * @deprecated as of 2.11, please use {@link #getOptions()}.setAppletEnabled instead. - */ - @Deprecated - public void setAppletEnabled(final boolean enabled) { - getOptions().setAppletEnabled(enabled); - } - - /** - * Returns <tt>true</tt> if Applet are enabled. - * - * @return <tt>true</tt> if Applet is enabled - * @deprecated as of 2.11, please use {@link #getOptions()}.isAppletEnabled instead. - */ - @Deprecated - public boolean isAppletEnabled() { - return getOptions().isAppletEnabled(); - } - - /** - * Enable/disable the popup window blocker. By default, the popup blocker is disabled, and popup - * windows are allowed. When set to <tt>true</tt>, <tt>window.open()</tt> has no effect and - * returns <tt>null</tt>. - * - * @param enabled <tt>true</tt> to enable the popup window blocker - * @deprecated as of 2.11, please use {@link #getOptions()}.setPopupBlockerEnabled instead. - */ - @Deprecated - public void setPopupBlockerEnabled(final boolean enabled) { - getOptions().setPopupBlockerEnabled(enabled); - } - - /** - * Returns <tt>true</tt> if the popup window blocker is enabled. - * - * @return <tt>true</tt> if the popup window blocker is enabled - * @deprecated as of 2.11, please use {@link #getOptions()}.isPopupBlockerEnabled instead. - */ - @Deprecated - public boolean isPopupBlockerEnabled() { - return getOptions().isPopupBlockerEnabled(); - } - - /** - * Returns the client's current homepage. - * @return the client's current homepage - * @deprecated as of 2.11, please use {@link #getOptions()}.getHomePage instead. - */ - @Deprecated - public String getHomePage() { - return getOptions().getHomePage(); - } - - /** - * Sets the client's homepage. - * @param homePage the new homepage URL - * @deprecated as of 2.11, please use {@link #getOptions()}.setHomePage instead. - */ - @Deprecated - public void setHomePage(final String homePage) { - getOptions().setHomePage(homePage); - } - - /** - * Returns the proxy configuration for this client. - * @return the proxy configuration for this client - * @deprecated as of 2.11, please use {@link #getOptions()}.getProxyConfig instead. - */ - @Deprecated - public ProxyConfig getProxyConfig() { - return getOptions().getProxyConfig(); - } - - /** - * Sets the proxy configuration for this client. - * @param proxyConfig the proxy configuration for this client - * @deprecated as of 2.11, please use {@link #getOptions()}.setProxyConfig instead. - */ - @Deprecated - public void setProxyConfig(final ProxyConfig proxyConfig) { - getOptions().setProxyConfig(proxyConfig); - } - - /** * Returns the cookie manager used by this web client. * @return the cookie manager used by this web client */ @@ -1085,46 +900,6 @@ } /** - * Sets whether or not redirections will be followed automatically on receipt of a redirect - * status code from the server. - * @param enabled true to enable automatic redirection - * @deprecated as of 2.11, please use {@link #getOptions()}.setRedirectEnabled instead. - */ - @Deprecated - public void setRedirectEnabled(final boolean enabled) { - getOptions().setRedirectEnabled(enabled); - } - - /** - * Returns whether or not redirections will be followed automatically on receipt of - * a redirect status code from the server. - * @return true if automatic redirection is enabled - * @deprecated as of 2.11, please use {@link #getOptions()}.isRedirectEnabled instead. - */ - @Deprecated - public boolean isRedirectEnabled() { - return getOptions().isRedirectEnabled(); - } - - /** - * If set to <code>true</code>, the client will accept connections to any host, regardless of - * whether they have valid certificates or not. This is especially useful when you are trying to - * connect to a server with expired or corrupt certificates. - * <p> - * This method works only if {@link #getWebConnection()} returns an {@link HttpWebConnection} - * (which is the default) or a {@link com.gargoylesoftware.htmlunit.util.WebConnectionWrapper} - * wrapping an {@link HttpWebConnection}. - * </p> - * @param useInsecureSSL whether or not to use insecure SSL - * @throws GeneralSecurityException if a security error occurs - * @deprecated as of 2.11, please use {@link #getOptions()}.setUseInsecureSSL instead. - */ - @Deprecated - public void setUseInsecureSSL(final boolean useInsecureSSL) throws GeneralSecurityException { - getOptions().setUseInsecureSSL(useInsecureSSL); - } - - /** * Sets the object that will be used to create pages. Set this if you want * to customize the type of page that is returned for a given content type. * @@ -1640,29 +1415,6 @@ } /** - * Sets whether to allow native ActiveX or no. Default value is false. - * Beware that you should never allow running native ActiveX components unless you fully trust - * the JavaScript code, as it is not controlled by the Java Virtual Machine. - * - * @param allow whether to allow or no - * @deprecated as of 2.11, please use {@link #getOptions()}.setActiveXNative instead. - */ - @Deprecated - public void setActiveXNative(final boolean allow) { - getOptions().setActiveXNative(allow); - } - - /** - * Returns whether native ActiveX components are allowed or no. - * @return whether native ActiveX components are allowed or no - * @deprecated as of 2.11, please use {@link #getOptions()}.isActiveXNative instead. - */ - @Deprecated - public boolean isActiveXNative() { - return getOptions().isActiveXNative(); - } - - /** * Sets the listener for messages generated by the HTML parser. * @param listener the new listener, <code>null</code> if messages should be totally ignored */ @@ -1720,53 +1472,6 @@ } /** - * Gets the timeout value for the {@link WebConnection}. - * - * @return the timeout value in milliseconds - * @see WebClient#setTimeout(int) - * @deprecated as of 2.11, please use {@link #getOptions()}.{@link WebClientOptions#getTimeout getTimeout()} - * instead. - */ - @Deprecated - public int getTimeout() { - return getOptions().getTimeout(); - } - - /** - * <p>Sets the timeout of the {@link WebConnection}.</p> - * - * @param timeout the value of the timeout in milliseconds - * @deprecated as of 2.11, please use {@link #getOptions()}.{@link WebClientOptions#setTimeout setTimeout()} - * instead. - */ - @Deprecated - public void setTimeout(final int timeout) { - getOptions().setTimeout(timeout); - } - - /** - * Indicates if an exception should be thrown when a script execution fails - * (the default) or if it should be caught and just logged to allow page - * execution to continue. - * @return <code>true</code> if an exception is thrown on script error (the default) - * @deprecated as of 2.11, please use {@link #getOptions()}.isThrowExceptionOnScriptError instead. - */ - @Deprecated - public boolean isThrowExceptionOnScriptError() { - return getOptions().isThrowExceptionOnScriptError(); - } - - /** - * Changes the behavior of this webclient when a script error occurs. - * @param newValue indicates if exception should be thrown or not - * @deprecated as of 2.11, please use {@link #getOptions()}.setThrowExceptionOnScriptError instead. - */ - @Deprecated - public void setThrowExceptionOnScriptError(final boolean newValue) { - getOptions().setThrowExceptionOnScriptError(newValue); - } - - /** * Gets the current listener for encountered incorrectness (except HTML parsing messages that * are handled by the HTML parser listener). Default value is an instance of * {@link IncorrectnessListenerImpl}. @@ -2066,26 +1771,6 @@ } /** - * Sets the SSL client certificate to use. - * The needed parameters are used to construct a {@link java.security.KeyStore}. - * - * If the web server requires Renegotiation, you have to set sytem property - * "sun.security.ssl.allowUnsafeRenegotiation" to true, as hinted in - * <a href="http://www.oracle.com/technetwork/java/javase/documentation/tlsreadme2-176330.html"> - * TLS Renegotiation Issue</a>. - * - * @param certificateUrl the URL which locates the certificate - * @param certificatePassword the certificate password - * @param certificateType the type of certificate, usually "jks" or "pkcs12". - * @deprecated as of 2.11, please use {@link #getOptions()}.setSSLClientCertificate instead. - */ - @Deprecated - public void setSSLClientCertificate(final URL certificateUrl, final String certificatePassword, - final String certificateType) { - getOptions().setSSLClientCertificate(certificateUrl, certificatePassword, certificateType); - } - - /** * Returns the aggregate background JavaScript job count across all windows. * @return the aggregate background JavaScript job count across all windows */ |
From: <rb...@us...> - 2013-03-08 20:43:40
|
Revision: 8150 http://sourceforge.net/p/htmlunit/code/8150 Author: rbri Date: 2013-03-08 20:43:37 +0000 (Fri, 08 Mar 2013) Log Message: ----------- attribute.expando now returns the correct value instead of the so far hard coded true (IE only) Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Attr.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/AttrTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-03-08 03:01:20 UTC (rev 8149) +++ trunk/htmlunit/src/changes/changes.xml 2013-03-08 20:43:37 UTC (rev 8150) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="fix" dev="rbri" issue="1493" due-to="Barry Pitman"> + JavaScript: Attribute.expando now returns the correct value instead of the so far hard coded true (IE only). + </action> <action type="remove" dev="asashour"> WebClient: remove deprecated setPrintContentOnFailingStatusCode(), getPrintContentOnFailingStatusCode(), setThrowExceptionOnFailingStatusCode(), isThrowExceptionOnFailingStatusCode(), setJavaScriptEnabled(), Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Attr.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Attr.java 2013-03-08 03:01:20 UTC (rev 8149) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Attr.java 2013-03-08 20:43:37 UTC (rev 8150) @@ -17,6 +17,8 @@ import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ATTR_FIRST_LAST_CHILD_RETURNS_NULL; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; +import net.sourceforge.htmlunit.corejs.javascript.Scriptable; +import net.sourceforge.htmlunit.corejs.javascript.ScriptableObject; import com.gargoylesoftware.htmlunit.html.DomAttr; import com.gargoylesoftware.htmlunit.html.DomElement; @@ -36,6 +38,7 @@ * @author Chris Erskine * @author Ahmed Ashour * @author Sudhan Moghe + * @author Ronald Brill */ @JsxClass(domClasses = DomAttr.class) public class Attr extends Node { @@ -67,12 +70,16 @@ } /** - * Returns <tt>true</tt> if arbitrary properties can be added to this attribute. - * @return <tt>true</tt> if arbitrary properties can be added to this attribute + * Returns <tt>true</tt> if the attribute is an custom property. + * @return <tt>true</tt> if the attribute is an custom property */ @JsxGetter(@WebBrowser(IE)) public boolean getExpando() { - return true; + final Object owner = getOwnerElement(); + if (null == owner) { + return false; + } + return !ScriptableObject.hasProperty((Scriptable) owner, getName()); } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/AttrTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/AttrTest.java 2013-03-08 03:01:20 UTC (rev 8149) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/AttrTest.java 2013-03-08 20:43:37 UTC (rev 8150) @@ -132,8 +132,9 @@ + " alert(d.getAttributeNode('name').isId);\n" + " alert(d.getAttributeNode('width').isId);\n" + "}\n" - + "</script></head><body onload='test()'>\n" - + "<div iD='d' name='d' width='40'>\n" + + "</script></head>\n" + + "<body onload='test()'>\n" + + "<div iD='d' name='d' width='40'></div>\n" + "</body></html>"; loadPageWithAlerts2(html); @@ -143,6 +144,53 @@ * @throws Exception if the test fails */ @Test + @Alerts(IE = { "false", "true", "false", "true", "true" }, + DEFAULT = { "undefined", "undefined", "undefined", "undefined", "undefined" }) + public void expando() throws Exception { + final String html + = "<html><head><script>\n" + + "function test() {\n" + + " var d = document.getElementById('d');\n" + + " alert(d.attributes['id'].expando);\n" + + " alert(d.attributes['name'].expando);\n" + + " alert(d.attributes['style'].expando);\n" + + " alert(d.attributes['custom'].expando);\n" + + " alert(d.attributes['other'].expando);\n" + + "}\n" + + "</script></head>\n" + + "<body onload='test()'>\n" + + " <div id='d' name='d' style='display: block' custom='value' other></div>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * Testcase for issue http://sourceforge.net/p/htmlunit/bugs/1493/. + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = "false", DEFAULT = "undefined") + public void expandoEvent() throws Exception { + final String html + = "<html><head><script>\n" + + "function test() {\n" + + " var d = document.getElementById('d');\n" + + " d.setAttribute('onfocusin', 't');\n" + + " alert(d.attributes['onfocusin'].expando);\n" + + "}\n" + + "</script></head>\n" + + "<body onload='test()'>\n" + + " <div id='d'></div>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(FF = "test()", IE = "undefined") public void textContent() throws Exception { final String html |
From: <asa...@us...> - 2013-03-09 13:27:45
|
Revision: 8154 http://sourceforge.net/p/htmlunit/code/8154 Author: asashour Date: 2013-03-09 13:27:42 +0000 (Sat, 09 Mar 2013) Log Message: ----------- - add @deprecation annotation - document the deprecation Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-03-09 12:22:22 UTC (rev 8153) +++ trunk/htmlunit/src/changes/changes.xml 2013-03-09 13:27:42 UTC (rev 8154) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="update" dev="rbri"> + WebRequest: deprecate constructor (WebRequest, URL). + </action> <action type="fix" dev="rbri" issue="1493" due-to="Barry Pitman"> JavaScript: Attribute.expando now returns the correct value instead of the so far hard coded true (IE only). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java 2013-03-09 12:22:22 UTC (rev 8153) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebRequest.java 2013-03-09 13:27:42 UTC (rev 8154) @@ -81,6 +81,7 @@ * * @deprecated as of 2.13 */ + @Deprecated public WebRequest(final WebRequest originalRequest, final URL url) { this(url); setProxyHost(originalRequest.getProxyHost()); |
From: <mgu...@us...> - 2013-03-10 13:54:30
|
Revision: 8155 http://sourceforge.net/p/htmlunit/code/8155 Author: mguillem Date: 2013-03-10 13:54:27 +0000 (Sun, 10 Mar 2013) Log Message: ----------- DomNode.removeAllChildren should not detach nested children from their parent node. Issue 1494 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-03-09 13:27:42 UTC (rev 8154) +++ trunk/htmlunit/src/changes/changes.xml 2013-03-10 13:54:27 UTC (rev 8155) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="fix" dev="mguillem" issue="1494"> + DomNode.removeAllChildren should not detach nested children from their parent node. + </action> <action type="update" dev="rbri"> WebRequest: deprecate constructor (WebRequest, URL). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java 2013-03-09 13:27:42 UTC (rev 8154) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java 2013-03-10 13:54:27 UTC (rev 8155) @@ -1384,14 +1384,9 @@ * Removes all of this node's children. */ public void removeAllChildren() { - if (getFirstChild() == null) { - return; + while (getFirstChild() != null) { + getFirstChild().remove(); } - - for (final Iterator<DomNode> it = getChildren().iterator(); it.hasNext();) { - it.next().removeAllChildren(); - it.remove(); - } } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2013-03-09 13:27:42 UTC (rev 8154) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2013-03-10 13:54:27 UTC (rev 8155) @@ -3836,4 +3836,22 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "[object Text]", "[object Text]" }, IE = { "[object]", "[object]" }) + public void textContentShouldNotDetachNestedNode() throws Exception { + final String html = "<html><body><div><div id='it'>foo</div></div><script>\n" + + "try {\n" + + " var elt = document.getElementById('it');\n" + + " alert(elt.firstChild);\n" + + " elt.parentNode.textContent = '';\n" + + " alert(elt.firstChild);\n" + + "} catch (e) { alert('exception'); }\n" + + "</script></body></html>"; + + loadPageWithAlerts2(html); + } } |
From: <mgu...@us...> - 2013-03-13 11:20:08
|
Revision: 8163 http://sourceforge.net/p/htmlunit/code/8163 Author: mguillem Date: 2013-03-13 11:20:01 +0000 (Wed, 13 Mar 2013) Log Message: ----------- JavaScript: JS click() method triggers onchange handler on checkbox and radio button. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-03-13 10:05:29 UTC (rev 8162) +++ trunk/htmlunit/src/changes/changes.xml 2013-03-13 11:20:01 UTC (rev 8163) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="fix" dev="mguillem"> + JavaScript: JS click() method triggers onchange handler on checkbox and radio button. + </action> <action type="fix" dev="mguillem" issue="1494"> DomNode.removeAllChildren should not detach nested children from their parent node. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java 2013-03-13 10:05:29 UTC (rev 8162) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLInputElement.java 2013-03-13 11:20:01 UTC (rev 8163) @@ -23,7 +23,9 @@ import org.apache.commons.lang3.math.NumberUtils; import org.xml.sax.helpers.AttributesImpl; +import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput; import com.gargoylesoftware.htmlunit.html.HtmlInput; +import com.gargoylesoftware.htmlunit.html.HtmlRadioButtonInput; import com.gargoylesoftware.htmlunit.html.HtmlTextInput; import com.gargoylesoftware.htmlunit.html.InputElementFactory; import com.gargoylesoftware.htmlunit.html.impl.SelectableTextInput; @@ -32,7 +34,9 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter; import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; +import com.gargoylesoftware.htmlunit.javascript.host.Event; import com.gargoylesoftware.htmlunit.javascript.host.FormField; +import com.gargoylesoftware.htmlunit.javascript.host.MouseEvent; /** * The JavaScript object for form input elements (html tag <input ...>). @@ -370,7 +374,18 @@ @Override @JsxFunction(@WebBrowser(FF)) public void click() throws IOException { - super.click(); + final HtmlInput domNode = (HtmlInput) getDomNodeOrDie(); + final boolean originalState = domNode.isChecked(); + final Event event = new MouseEvent(domNode, MouseEvent.TYPE_CLICK, false, + false, false, MouseEvent.BUTTON_LEFT); + domNode.click(event); + + final boolean newState = domNode.isChecked(); + + if (originalState != newState + && (domNode instanceof HtmlCheckBoxInput || domNode instanceof HtmlRadioButtonInput)) { + domNode.fireEvent(Event.TYPE_CHANGE); + } } /** Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java 2013-03-13 10:05:29 UTC (rev 8162) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java 2013-03-13 11:20:01 UTC (rev 8163) @@ -228,4 +228,22 @@ final WebElement checkbox = driver.findElement(By.id("checkbox")); assertFalse(checkbox.isSelected()); } + + /** + * Call to JS function click() should trigger the onchange handler but neither the onfocus handler + * nor the mousedown/up handlers. + * @throws Exception if the test fails + */ + @Test + @Alerts("changed") + public void clickShouldTriggerOnchange() throws Exception { + final String html = "<html><body>\n" + + "<input type='checkbox' id='it' onchange='alert(\"changed\")'" + + "onmousedown='alert(\"down\")' onmouseup='alert(\"up\")' onfocus='alert(\"focused\")'>Check me\n" + + "<script>\n" + + "var elt = document.getElementById('it');\n" + + "elt.click();\n" + + "</script></body></html>"; + loadPageWithAlerts2(html); + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2013-03-13 10:05:29 UTC (rev 8162) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2013-03-13 11:20:01 UTC (rev 8163) @@ -2708,7 +2708,6 @@ */ @Test @Alerts("0, 1, 1") - @NotYetImplemented(FF) public void event__trigger_click_on_checkbox__fires_change_event() throws Exception { runTest("event: trigger click on checkbox, fires change event"); } |
From: <mgu...@us...> - 2013-03-13 12:12:40
|
Revision: 8164 http://sourceforge.net/p/htmlunit/code/8164 Author: mguillem Date: 2013-03-13 12:12:37 +0000 (Wed, 13 Mar 2013) Log Message: ----------- DomNode.querySelectorAll: return nodes matched by many selectors only once. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-03-13 11:20:01 UTC (rev 8163) +++ trunk/htmlunit/src/changes/changes.xml 2013-03-13 12:12:37 UTC (rev 8164) @@ -9,6 +9,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> <action type="fix" dev="mguillem"> + DomNode.querySelectorAll: return nodes matched by many selectors only once. + </action> + <action type="fix" dev="mguillem"> JavaScript: JS click() method triggers onchange handler on checkbox and radio button. </action> <action type="fix" dev="mguillem" issue="1494"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java 2013-03-13 11:20:01 UTC (rev 8163) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java 2013-03-13 12:12:37 UTC (rev 8164) @@ -1578,6 +1578,7 @@ final Selector selector = selectorList.item(i); if (CSSStyleSheet.selects(browserVersion, selector, child)) { elements.add(child); + break; } } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java 2013-03-13 11:20:01 UTC (rev 8163) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java 2013-03-13 12:12:37 UTC (rev 8164) @@ -973,4 +973,25 @@ loadPageWithAlerts2(html); } + + /** + * querySelectorAll should return nodes matched by many rules only once. + * @throws Exception if the test fails + */ + @Test + @Alerts(FF = "1", IE = "undefined") + public void querySelectorAll_noDuplication() throws Exception { + final String html = "<html><body>\n" + + "<div><span>First</span></div>\n" + + "<script>\n" + + " if(document.body.querySelectorAll) {\n" + + " var tags = document.body.querySelectorAll('span, div > span');\n" + + " alert(tags.length);\n" + + " }\n" + + " else\n" + + " alert('undefined');\n" + + "</script></body></html>"; + + loadPageWithAlerts2(html); + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2013-03-13 11:20:01 UTC (rev 8163) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2013-03-13 12:12:37 UTC (rev 8164) @@ -6748,7 +6748,6 @@ */ @Test @Alerts("0, 36, 36") - @NotYetImplemented(FF) public void Sizzle__selector__element() throws Exception { runTest("Sizzle: selector: element"); } |
From: <mgu...@us...> - 2013-03-13 12:50:57
|
Revision: 8165 http://sourceforge.net/p/htmlunit/code/8165 Author: mguillem Date: 2013-03-13 12:50:52 +0000 (Wed, 13 Mar 2013) Log Message: ----------- validate syntax of the argument of nth-child() CSS selector Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-03-13 12:12:37 UTC (rev 8164) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-03-13 12:50:52 UTC (rev 8165) @@ -1117,6 +1117,9 @@ if (documentMode < 9) { return CSS2_PSEUDO_CLASSES.contains(value); } + if ("nth-child()".equals(value)) { + return pcc.getValue().matches("nth-child(\\w*[-+]?\\d*n\\w*[+-]\\w\\d*\\w*)"); + } return CSS3_PSEUDO_CLASSES.contains(value); default: LOG.warn("Unhandled CSS condition type '" + condition.getConditionType() + "'. Accepting it silently."); Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java 2013-03-13 12:12:37 UTC (rev 8164) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java 2013-03-13 12:50:52 UTC (rev 8165) @@ -939,13 +939,20 @@ for (final String selector : HTMLDocumentTest.JQUERY_CUSTOM_SELECTORS) { doTestQuerySelectorAll_badSelector(selector); } + + // some other bad selectors tested in jQuery 1.8.2 tests + final String[] otherBadSelectors = {":nth-child(2n+-0)", ":nth-child(2+0)", ":nth-child(- 1n)", + ":nth-child(-1 n)" }; + for (final String selector : otherBadSelectors) { + doTestQuerySelectorAll_badSelector(selector); + } } private void doTestQuerySelectorAll_badSelector(final String selector) throws Exception { final String html = "<html><body><div id='it'></div><script>\n" + "try {\n" + " document.getElementById('it').querySelectorAll('" + selector + "');\n" - + " alert('working');\n" + + " alert('working: + " + selector + "');\n" + "} catch(e) { alert('exception'); }\n" + "</script></body></html>"; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2013-03-13 12:12:37 UTC (rev 8164) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2013-03-13 12:50:52 UTC (rev 8165) @@ -6769,7 +6769,6 @@ */ @Test @Alerts("0, 21, 21") - @NotYetImplemented(FF) public void Sizzle__selector__broken() throws Exception { runTest("Sizzle: selector: broken"); } |
From: <mgu...@us...> - 2013-03-14 08:04:17
|
Revision: 8169 http://sourceforge.net/p/htmlunit/code/8169 Author: mguillem Date: 2013-03-14 08:04:13 +0000 (Thu, 14 Mar 2013) Log Message: ----------- oops, we can't yet reject some invalid selectors like ":nth-child(- 1n)" as CSSParser trims the spaces Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-03-13 17:13:38 UTC (rev 8168) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-03-14 08:04:13 UTC (rev 8169) @@ -124,7 +124,7 @@ private static final Log LOG = LogFactory.getLog(CSSStyleSheet.class); private static final Pattern NTH_NUMERIC = Pattern.compile("\\d+"); - private static final Pattern NTH_COMPLEX = Pattern.compile("[-+]?\\d*n\\w*([+-]\\w\\d*)?"); + private static final Pattern NTH_COMPLEX = Pattern.compile("[+-]?\\d*n\\w*([+-]\\w\\d*)?"); /** The parsed stylesheet which this host object wraps. */ private final org.w3c.dom.css.CSSStyleSheet wrapped_; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java 2013-03-13 17:13:38 UTC (rev 8168) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement2Test.java 2013-03-14 08:04:13 UTC (rev 8169) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.html; +import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.FF; import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.FF17; import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.IE; @@ -941,18 +942,31 @@ } // some other bad selectors tested in jQuery 1.8.2 tests - final String[] otherBadSelectors = {":nth-child(2n+-0)", ":nth-child(2+0)", ":nth-child(- 1n)", - ":nth-child(-1 n)" }; + final String[] otherBadSelectors = {":nth-child(2n+-0)", ":nth-child(2+0)" }; for (final String selector : otherBadSelectors) { doTestQuerySelectorAll_badSelector(selector); } } + /** + * To be moved in the above test once it works. + * The problem is that spaces are trimmed in the value of PseudoClassConditionImpl + * and therefore the selector is not invalid anymore. + * @throws Exception if the test fails + */ + @Test + @Alerts("exception") + @NotYetImplemented(FF) + public void querySelectorAll_badSelectorNYI() throws Exception { + doTestQuerySelectorAll_badSelector(":nth-child(- 1n)"); + doTestQuerySelectorAll_badSelector(":nth-child(-1 n)"); + } + private void doTestQuerySelectorAll_badSelector(final String selector) throws Exception { final String html = "<html><body><div id='it'></div><script>\n" + "try {\n" + " document.getElementById('it').querySelectorAll('" + selector + "');\n" - + " alert('working: + " + selector + "');\n" + + " alert('working: " + selector + "');\n" + "} catch(e) { alert('exception'); }\n" + "</script></body></html>"; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2013-03-13 17:13:38 UTC (rev 8168) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/libraries/JQuery182Test.java 2013-03-14 08:04:13 UTC (rev 8169) @@ -108,6 +108,7 @@ result = result.substring(0, result.indexOf("Rerun")).trim(); final String expected = testName + " (" + getExpectedAlerts()[0] + ")"; if (!expected.contains(result)) { + System.out.println("-> " + webdriver.findElement(By.id("qunit-tests")).getText()); fail(new ComparisonFailure("", expected, result).getMessage()); } } @@ -6769,6 +6770,7 @@ */ @Test @Alerts("0, 21, 21") + @NotYetImplemented(FF) public void Sizzle__selector__broken() throws Exception { runTest("Sizzle: selector: broken"); } |
From: <mgu...@us...> - 2013-03-20 11:56:59
|
Revision: 8177 http://sourceforge.net/p/htmlunit/code/8177 Author: mguillem Date: 2013-03-20 11:56:54 +0000 (Wed, 20 Mar 2013) Log Message: ----------- HtmlPage.getElementById: always return the first element in document order (and not the first parsed one). Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Document2Test.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-03-20 11:16:17 UTC (rev 8176) +++ trunk/htmlunit/src/changes/changes.xml 2013-03-20 11:56:54 UTC (rev 8177) @@ -9,6 +9,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> <action type="fix" dev="mguillem"> + HtmlPage.getElementById: always return the first element in document order (and not the first parsed one). + </action> + <action type="fix" dev="mguillem"> DomNode.querySelectorAll: return nodes matched by many selectors only once. </action> <action type="fix" dev="mguillem"> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2013-03-20 11:16:17 UTC (rev 8176) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlPage.java 2013-03-20 11:56:54 UTC (rev 8177) @@ -30,12 +30,15 @@ import java.net.URL; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.SortedSet; +import java.util.TreeSet; import net.sourceforge.htmlunit.corejs.javascript.Context; import net.sourceforge.htmlunit.corejs.javascript.Function; @@ -135,8 +138,8 @@ private HtmlUnitDOMBuilder builder_; private String originalCharset_; - private Map<String, List<DomElement>> idMap_ = new HashMap<String, List<DomElement>>(); - private Map<String, List<DomElement>> nameMap_ = new HashMap<String, List<DomElement>>(); + private Map<String, SortedSet<DomElement>> idMap_ = new HashMap<String, SortedSet<DomElement>>(); + private Map<String, SortedSet<DomElement>> nameMap_ = new HashMap<String, SortedSet<DomElement>>(); private HtmlElement elementWithFocus_; private int parserCount_; private int snippetParserCount_; @@ -148,7 +151,21 @@ private boolean cleaning_; private HtmlBase base_; private URL baseUrl_; + private static final Comparator<DomElement> documentPositionComparator = new Comparator<DomElement>() { + @Override + public int compare(final DomElement elt1, final DomElement elt2) { + final short relation = elt1.compareDocumentPosition(elt2); + if (relation == 0) { + return 0; // same node + } + if ((relation & DOCUMENT_POSITION_CONTAINS) != 0 || (relation & DOCUMENT_POSITION_PRECEDING) != 0) { + return 1; + } + return -1; + } + }; + /** * Creates an instance of HtmlPage. * An HtmlPage instance is normally retrieved with {@link WebClient#getPage(String)}. @@ -1630,7 +1647,7 @@ public <E extends DomElement> E getElementById(final String id, final boolean caseSensitive) throws ElementNotFoundException { - List<DomElement> elements = idMap_.get(id); + SortedSet<DomElement> elements = idMap_.get(id); // not found maybe we have to search case insensitive if (null == elements && !caseSensitive) { @@ -1643,7 +1660,7 @@ } if (elements != null) { - return (E) elements.get(0); + return (E) elements.first(); } throw new ElementNotFoundException("*", "id", id); } @@ -1659,9 +1676,9 @@ */ @SuppressWarnings("unchecked") public <E extends DomElement> E getElementByName(final String name) throws ElementNotFoundException { - final List<DomElement> elements = nameMap_.get(name); + final SortedSet<DomElement> elements = nameMap_.get(name); if (elements != null) { - return (E) elements.get(0); + return (E) elements.first(); } throw new ElementNotFoundException("*", "name", name); } @@ -1675,9 +1692,9 @@ * @return the elements with the specified name attribute */ public List<DomElement> getElementsByName(final String name) { - final List<DomElement> list = nameMap_.get(name); - if (list != null) { - return Collections.unmodifiableList(list); + final SortedSet<DomElement> elements = nameMap_.get(name); + if (elements != null) { + return new ArrayList<DomElement>(elements); } return Collections.emptyList(); } @@ -1690,8 +1707,8 @@ * @return the elements with the specified string for their name or ID */ public List<DomElement> getElementsByIdAndOrName(final String idAndOrName) { - final List<DomElement> list1 = idMap_.get(idAndOrName); - final List<DomElement> list2 = nameMap_.get(idAndOrName); + final Collection<DomElement> list1 = idMap_.get(idAndOrName); + final Collection<DomElement> list2 = nameMap_.get(idAndOrName); final List<DomElement> list = new ArrayList<DomElement>(); if (list1 != null) { list.addAll(list1); @@ -1726,13 +1743,13 @@ } } - private void addElement(final Map<String, List<DomElement>> map, final DomElement element, + private void addElement(final Map<String, SortedSet<DomElement>> map, final DomElement element, final String attribute, final boolean recurse) { final String value = element.getAttribute(attribute); if (DomElement.ATTRIBUTE_NOT_DEFINED != value) { - List<DomElement> elements = map.get(value); + SortedSet<DomElement> elements = map.get(value); if (elements == null) { - elements = new ArrayList<DomElement>(); + elements = new TreeSet<DomElement>(documentPositionComparator); elements.add(element); map.put(value, elements); } @@ -1768,11 +1785,11 @@ } } - private void removeElement(final Map<String, List<DomElement>> map, final DomElement element, final String att, - final boolean recurse) { + private void removeElement(final Map<String, SortedSet<DomElement>> map, final DomElement element, + final String att, final boolean recurse) { final String value = element.getAttribute(att); if (!StringUtils.isEmpty(value)) { - final List<DomElement> elements = map.remove(value); + final SortedSet<DomElement> elements = map.remove(value); if (elements != null && (elements.size() != 1 || !elements.contains(element))) { elements.remove(element); map.put(value, elements); @@ -2022,8 +2039,8 @@ protected HtmlPage clone() { final HtmlPage result = (HtmlPage) super.clone(); result.elementWithFocus_ = null; - result.idMap_ = new HashMap<String, List<DomElement>>(); - result.nameMap_ = new HashMap<String, List<DomElement>>(); + result.idMap_ = new HashMap<String, SortedSet<DomElement>>(); + result.nameMap_ = new HashMap<String, SortedSet<DomElement>>(); return result; } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Document2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Document2Test.java 2013-03-20 11:16:17 UTC (rev 8176) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Document2Test.java 2013-03-20 11:56:54 UTC (rev 8177) @@ -34,6 +34,7 @@ * * @version $Revision$ * @author Ronald Brill + * @author Marc Guillemot */ @RunWith(BrowserRunner.class) public class Document2Test extends WebDriverTestCase { @@ -442,4 +443,26 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "first", "newest" }) + public void getElementById_alwaysFirstOneInDocumentOrder() throws Exception { + final String html = "<html><body>\n" + + "<span id='it' class='first'></span>\n" + + "<span id='it' class='second'></span>\n" + + "<script>\n" + + "alert(document.getElementById('it').className);\n" + + "var s = document.createElement('span');\n" + + "s.id = 'it';\n" + + "s.className = 'newest';\n" + + "document.body.insertBefore(s, document.body.firstChild);\n" + + "alert(document.getElementById('it').className);\n" + + "</script></body></html>"; + + loadPageWithAlerts2(html); + } + } |
From: <mgu...@us...> - 2013-03-21 11:55:47
|
Revision: 8180 http://sourceforge.net/p/htmlunit/code/8180 Author: mguillem Date: 2013-03-21 11:55:44 +0000 (Thu, 21 Mar 2013) Log Message: ----------- handle weird case where document.write is silently ignored Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlScript.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentWrite2Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentWriteTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlScript.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlScript.java 2013-03-20 15:59:37 UTC (rev 8179) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlScript.java 2013-03-21 11:55:44 UTC (rev 8180) @@ -47,6 +47,7 @@ import com.gargoylesoftware.htmlunit.javascript.host.Event; import com.gargoylesoftware.htmlunit.javascript.host.EventHandler; import com.gargoylesoftware.htmlunit.javascript.host.Window; +import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument; import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLScriptElement; import com.gargoylesoftware.htmlunit.protocol.javascript.JavaScriptURLConnection; import com.gargoylesoftware.htmlunit.xml.XmlPage; @@ -248,22 +249,32 @@ final PostponedAction action = new PostponedAction(getPage()) { @Override public void execute() { - final boolean onReady = hasFeature(JS_SCRIPT_SUPPORTS_ONREADYSTATECHANGE); - if (onReady) { - if (!isDeferred()) { - if (SLASH_SLASH_COLON.equals(getSrcAttribute())) { - setAndExecuteReadyState(READY_STATE_COMPLETE); - executeScriptIfNeeded(); + final HTMLDocument jsDoc = (HTMLDocument) ((Window) getPage().getEnclosingWindow().getScriptObject()) + .getDocument(); + jsDoc.setExecutingDynamicExternalPosponed(getStartLineNumber() == -1 + && getSrcAttribute() != ATTRIBUTE_NOT_DEFINED); + + try { + final boolean onReady = hasFeature(JS_SCRIPT_SUPPORTS_ONREADYSTATECHANGE); + if (onReady) { + if (!isDeferred()) { + if (SLASH_SLASH_COLON.equals(getSrcAttribute())) { + setAndExecuteReadyState(READY_STATE_COMPLETE); + executeScriptIfNeeded(); + } + else { + setAndExecuteReadyState(READY_STATE_LOADING); + executeScriptIfNeeded(); + setAndExecuteReadyState(READY_STATE_LOADED); + } } - else { - setAndExecuteReadyState(READY_STATE_LOADING); - executeScriptIfNeeded(); - setAndExecuteReadyState(READY_STATE_LOADED); - } } + else { + executeScriptIfNeeded(); + } } - else { - executeScriptIfNeeded(); + finally { + jsDoc.setExecutingDynamicExternalPosponed(false); } } }; Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2013-03-20 15:59:37 UTC (rev 8179) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocument.java 2013-03-21 11:55:44 UTC (rev 8180) @@ -551,7 +551,19 @@ throw Context.reportRuntimeError("Function can't be used detached from document"); } + private boolean executionExternalPostponed_ = false; + /** + * This a hack!!! A cleaner way is welcome. + * Handle a case where document.write is simply ignored. + * See HTMLDocumentWrite2Test.write_fromScriptAddedWithAppendChild_external. + * @param executing indicates if executing or not + */ + public void setExecutingDynamicExternalPosponed(final boolean executing) { + executionExternalPostponed_ = executing; + } + + /** * JavaScript function "write". * * See http://www.whatwg.org/specs/web-apps/current-work/multipage/section-dynamic.html for @@ -560,6 +572,14 @@ * @param content the content to write */ protected void write(final String content) { + // really strange: if called from an external script loaded as postponed action, write is ignored!!! + if (executionExternalPostponed_) { + if (LOG.isDebugEnabled()) { + LOG.debug("skipping write for external posponed: " + content); + } + return; + } + if (LOG.isDebugEnabled()) { LOG.debug("write: " + content); } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentWrite2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentWrite2Test.java 2013-03-20 15:59:37 UTC (rev 8179) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentWrite2Test.java 2013-03-21 11:55:44 UTC (rev 8180) @@ -316,4 +316,70 @@ + "</html>"; loadPageWithAlerts2(html); } + + /** + * Regression test for bug 743241. + * @throws Exception if the test fails + */ + @Test + public void write_LoadScript() throws Exception { + final String html + = "<html><head><title>First</title></head><body>\n" + + "<script src='script.js'></script>\n" + + "</form></body></html>"; + + final String script = "document.write(\"<div id='div1'>hello</div>\");\n"; + getMockWebConnection().setDefaultResponse(script, JAVASCRIPT_MIME_TYPE); + + final WebDriver driver = loadPage2(html); + assertEquals("First", driver.getTitle()); + + assertEquals("hello", driver.findElement(By.id("div1")).getText()); + } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(IE = "exception") + public void write_fromScriptAddedWithAppendChild_inline() throws Exception { + final String html = "<html><head></head><body>\n" + + "<div id='it'><script>\n" + + "try {\n" + + " var s = document.createElement('script');\n" + + " var t = document.createTextNode(\"document.write('in inline script'); document.title = 'done';\");\n" + + " s.appendChild(t);\n" + + " document.body.appendChild(s);\n" + + "} catch (e) { alert('exception'); }\n" + + "</script></div></body></html>"; + final WebDriver driver = loadPageWithAlerts2(html); + + if (getExpectedAlerts().length == 0) { + assertEquals("done", driver.getTitle()); + assertEquals("in inline script", driver.findElement(By.id("it")).getText()); + } + } + + /** + * @throws Exception if an error occurs + */ + @Test + public void write_fromScriptAddedWithAppendChild_external() throws Exception { + final String html = "<html><head></head><body>\n" + + "<div id='it'>here</div><script>\n" + + " var s = document.createElement('script');\n" + + " s.src = 'foo.js'\n" + + " document.body.appendChild(s);\n" + + "</script></body></html>"; + + final String js = "document.write('from external script');\n" + + "document.title = 'done';"; + + getMockWebConnection().setDefaultResponse(js, JAVASCRIPT_MIME_TYPE); + final WebDriver driver = loadPage2(html); + + assertEquals("done", driver.getTitle()); + assertEquals("here", driver.findElement(By.id("it")).getText()); + assertEquals("here", driver.findElement(By.tagName("body")).getText()); + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentWriteTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentWriteTest.java 2013-03-20 15:59:37 UTC (rev 8179) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLDocumentWriteTest.java 2013-03-21 11:55:44 UTC (rev 8180) @@ -15,7 +15,6 @@ package com.gargoylesoftware.htmlunit.javascript.host.html; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; import java.net.URL; import java.util.ArrayList; @@ -27,7 +26,6 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; import com.gargoylesoftware.htmlunit.CollectingAlertHandler; -import com.gargoylesoftware.htmlunit.ElementNotFoundException; import com.gargoylesoftware.htmlunit.MockWebConnection; import com.gargoylesoftware.htmlunit.SimpleWebTestCase; import com.gargoylesoftware.htmlunit.WebClient; @@ -71,39 +69,6 @@ } /** - * Regression test for bug 743241. - * @throws Exception if the test fails - */ - @Test - public void write_LoadScript() throws Exception { - final WebClient webClient = getWebClient(); - final MockWebConnection webConnection = new MockWebConnection(); - webClient.setWebConnection(webConnection); - - final String html - = "<html><head><title>First</title></head><body>\n" - + "<script src='http://script'></script>\n" - + "</form></body></html>"; - webConnection.setResponse(URL_FIRST, html); - - final String script = "document.write(\"<div id='div1'></div>\");\n"; - webConnection.setResponse(new URL("http://script/"), script, JAVASCRIPT_MIME_TYPE); - - final List<String> collectedAlerts = new ArrayList<String>(); - webClient.setAlertHandler(new CollectingAlertHandler(collectedAlerts)); - - final HtmlPage page = webClient.getPage(URL_FIRST); - assertEquals("First", page.getTitleText()); - - try { - page.getHtmlElementById("div1"); - } - catch (final ElementNotFoundException e) { - fail("Element not written to page as expected"); - } - } - - /** * Regression test for bug 715379. * @throws Exception if the test fails */ |
From: <mgu...@us...> - 2013-03-21 15:17:51
|
Revision: 8181 http://sourceforge.net/p/htmlunit/code/8181 Author: mguillem Date: 2013-03-21 15:17:47 +0000 (Thu, 21 Mar 2013) Log Message: ----------- CSS3 pseudo selector "empty" should select nodes containing only a comment Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-03-21 11:55:44 UTC (rev 8180) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-03-21 15:17:47 UTC (rev 8181) @@ -79,6 +79,7 @@ import com.gargoylesoftware.htmlunit.html.DisabledElement; import com.gargoylesoftware.htmlunit.html.DomElement; import com.gargoylesoftware.htmlunit.html.DomNode; +import com.gargoylesoftware.htmlunit.html.DomText; import com.gargoylesoftware.htmlunit.html.HtmlCheckBoxInput; import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlHtml; @@ -692,7 +693,7 @@ return true; } else if ("empty".equals(value)) { - return element.getFirstChild() == null; + return isEmpty(element); } else if ("target".equals(value)) { final String ref = element.getPage().getUrl().getRef(); @@ -733,6 +734,15 @@ return false; } + private static boolean isEmpty(final DomElement element) { + for (DomNode n = element.getFirstChild(); n != null; n = n.getNextSibling()) { + if (n instanceof DomElement || n instanceof DomText) { + return false; + } + } + return true; + } + private static boolean getNth(final String nth, final int index) { if ("odd".equalsIgnoreCase(nth)) { return index % 2 != 0; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java 2013-03-21 11:55:44 UTC (rev 8180) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java 2013-03-21 15:17:47 UTC (rev 8181) @@ -862,7 +862,7 @@ * @throws Exception if an error occurs */ @Test - @Alerts(DEFAULT = "id2", IE8 = "exception") + @Alerts(DEFAULT = { "id2", "span1" }, IE8 = "exception") public void empty() throws Exception { final String html = "<html><head><title>First</title>\n" + "<meta http-equiv='X-UA-Compatible' content='IE=9'>\n" @@ -871,6 +871,7 @@ + " if (document.querySelectorAll) {\n" + " try {\n" + " alert(document.querySelectorAll('p:empty')[0].id);\n" + + " alert(document.querySelectorAll('span:empty')[0].id);\n" + " } catch(e) {alert('exception')}\n" + " }\n" + "}\n" @@ -878,6 +879,8 @@ + "<body onload='test()'>\n" + " <p id='id1'>Hello, World!</p>\n" + " <p id='id2'></p>\n" + + " <span id='span1'><!-- a comment --></span>\n" + + " <span id='span2'>a text</span>\n" + "</body></html>"; loadPageWithAlerts2(html); |
From: <mgu...@us...> - 2013-03-21 15:39:26
|
Revision: 8182 http://sourceforge.net/p/htmlunit/code/8182 Author: mguillem Date: 2013-03-21 15:39:23 +0000 (Thu, 21 Mar 2013) Log Message: ----------- CSS selector: handle escaped characters Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-03-21 15:17:47 UTC (rev 8181) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-03-21 15:39:23 UTC (rev 8182) @@ -474,7 +474,11 @@ case Condition.SAC_ATTRIBUTE_CONDITION: final AttributeCondition ac1 = (AttributeCondition) condition; if (ac1.getSpecified()) { - return element.getAttribute(ac1.getLocalName()).equals(ac1.getValue()); + String value = ac1.getValue(); + if (value.contains("\\")) { // handle \[, \] and \. (are there others?) + value = value.replaceAll("\\\\([\\[\\]\\.])", "$1"); + } + return element.getAttribute(ac1.getLocalName()).equals(value); } return element.hasAttribute(ac1.getLocalName()); case Condition.SAC_BEGIN_HYPHEN_ATTRIBUTE_CONDITION: Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java 2013-03-21 15:17:47 UTC (rev 8181) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java 2013-03-21 15:39:23 UTC (rev 8182) @@ -1086,4 +1086,25 @@ getMockWebConnection().setDefaultResponse(html); loadPageWithAlerts2(UrlUtils.getUrlWithNewRef(URL_FIRST, "id3")); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(DEFAULT = { "first", "second" }, IE8 = "exception") + public void escapedAttributeValue() throws Exception { + final String html = "<html><head>\n" + + "<meta http-equiv='X-UA-Compatible' content='IE=9'>\n" + + "</head><body>\n" + + " <input id='first' name='foo[bar]'>\n" + + " <input id='second' name='foo.bar'>\n" + + "<script>\n" + + "try {\n" + + " alert(document.querySelectorAll('input[name=foo\\\\[bar\\\\]]')[0].id);\n" + + " alert(document.querySelectorAll('input[name=foo\\\\.bar]')[0].id);\n" + + "} catch(e) {alert('exception')}\n" + + "</script></body></html>"; + + loadPageWithAlerts2(html); + } } |
From: <mgu...@us...> - 2013-03-21 16:06:33
|
Revision: 8183 http://sourceforge.net/p/htmlunit/code/8183 Author: mguillem Date: 2013-03-21 16:06:29 +0000 (Thu, 21 Mar 2013) Log Message: ----------- CSS selector: handle escaped characters in class name Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-03-21 15:39:23 UTC (rev 8182) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSStyleSheet.java 2013-03-21 16:06:29 UTC (rev 8183) @@ -464,7 +464,7 @@ return ac4.getValue().equals(element.getId()); case Condition.SAC_CLASS_CONDITION: final AttributeCondition ac3 = (AttributeCondition) condition; - final String v3 = ac3.getValue(); + final String v3 = unescape(ac3.getValue()); final String a3 = element.getAttribute("class"); return selects(v3, a3, ' '); case Condition.SAC_AND_CONDITION: @@ -474,10 +474,7 @@ case Condition.SAC_ATTRIBUTE_CONDITION: final AttributeCondition ac1 = (AttributeCondition) condition; if (ac1.getSpecified()) { - String value = ac1.getValue(); - if (value.contains("\\")) { // handle \[, \] and \. (are there others?) - value = value.replaceAll("\\\\([\\[\\]\\.])", "$1"); - } + final String value = unescape(ac1.getValue()); return element.getAttribute(ac1.getLocalName()).equals(value); } return element.hasAttribute(ac1.getLocalName()); @@ -530,6 +527,13 @@ } } + private static String unescape(final String value) { + if (value.indexOf('\\') == -1) { + return value; + } + return value.replaceAll("\\\\([\\[\\]\\.:])", "$1"); + } + private static boolean selects(final String condition, final String attribute, final char separator) { // attribute.equals(condition) // || attribute.startsWith(condition + " ") || attriubte.endsWith(" " + condition) Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java 2013-03-21 15:39:23 UTC (rev 8182) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/css/CSSSelectorTest.java 2013-03-21 16:06:29 UTC (rev 8183) @@ -1107,4 +1107,27 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts({ "first", "second", "third" }) + public void escapedClassName() throws Exception { + final String html = "<html><head>\n" + + "<meta http-equiv='X-UA-Compatible' content='IE=9'>\n" + + "</head><body>\n" + + " <input id='first' class='foo[bar]'>\n" + + " <input id='second' class='foo.bar'>\n" + + " <input id='third' class='foo:bar'>\n" + + "<script>\n" + + "try {\n" + + " alert(document.querySelectorAll('.foo\\\\[bar\\\\]')[0].id);\n" + + " alert(document.querySelectorAll('.foo\\\\.bar')[0].id);\n" + + " alert(document.querySelectorAll('.foo\\\\:bar')[0].id);\n" + + "} catch(e) {alert('exception')}\n" + + "</script></body></html>"; + + loadPageWithAlerts2(html); + } } |
From: <rb...@us...> - 2013-03-21 21:35:20
|
Revision: 8187 http://sourceforge.net/p/htmlunit/code/8187 Author: rbri Date: 2013-03-21 21:35:14 +0000 (Thu, 21 Mar 2013) Log Message: ----------- Removing frame tag removes the associated FrameWindow also. Issue 1497 Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebWindowImpl.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrameElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/FrameWindow.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-03-21 18:59:07 UTC (rev 8186) +++ trunk/htmlunit/src/changes/changes.xml 2013-03-21 21:35:14 UTC (rev 8187) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="fix" dev="rbri" issue="1497"> + JavaScript: Removing frame tag removes the associated FrameWindow also. + </action> <action type="fix" dev="mguillem"> HtmlPage.getElementById: always return the first element in document order (and not the first parsed one). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebWindowImpl.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebWindowImpl.java 2013-03-21 18:59:07 UTC (rev 8186) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebWindowImpl.java 2013-03-21 21:35:14 UTC (rev 8187) @@ -165,7 +165,10 @@ childWindows_.add(child); } - void destroyChildren() { + /** + * Destroy our childs. + */ + protected void destroyChildren() { if (LOG.isDebugEnabled()) { LOG.debug("destroyChildren"); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrameElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrameElement.java 2013-03-21 18:59:07 UTC (rev 8186) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrameElement.java 2013-03-21 21:35:14 UTC (rev 8187) @@ -408,4 +408,14 @@ ((BaseFrameElement) node).init(); return node; } + + /** + * Remove our window also. + * {@inheritDoc} + */ + @Override + protected void basicRemove() { + super.basicRemove(); + ((FrameWindow) getEnclosedWindow()).close(); + } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java 2013-03-21 18:59:07 UTC (rev 8186) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java 2013-03-21 21:35:14 UTC (rev 8187) @@ -1118,7 +1118,7 @@ /** * Cuts off all relationships this node has with siblings and parents. */ - private void basicRemove() { + protected void basicRemove() { if (parent_ != null && parent_.firstChild_ == this) { parent_.firstChild_ = nextSibling_; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/FrameWindow.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/FrameWindow.java 2013-03-21 18:59:07 UTC (rev 8186) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/FrameWindow.java 2013-03-21 21:35:14 UTC (rev 8187) @@ -131,4 +131,18 @@ public String toString() { return "FrameWindow[name=\"" + getName() + "\"]"; } + + /** + * Closes this frame window. + */ + public void close() { + setClosed(); + final Page page = getEnclosedPage(); + if (page != null) { + page.cleanUp(); + } + getJobManager().shutdown(); + destroyChildren(); + getWebClient().deregisterWebWindow(this); + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElementTest.java 2013-03-21 18:59:07 UTC (rev 8186) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElementTest.java 2013-03-21 21:35:14 UTC (rev 8187) @@ -32,6 +32,8 @@ import com.gargoylesoftware.htmlunit.MockWebConnection; import com.gargoylesoftware.htmlunit.SimpleWebTestCase; import com.gargoylesoftware.htmlunit.WebClient; +import com.gargoylesoftware.htmlunit.html.FrameWindow; +import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlInlineFrame; import com.gargoylesoftware.htmlunit.html.HtmlPage; @@ -121,7 +123,7 @@ + "</body></html>"; final WebClient webClient = getWebClient(); - final MockWebConnection webConnection = new MockWebConnection(); + final MockWebConnection webConnection = getMockWebConnection(); webConnection.setDefaultResponse(frameContent); webConnection.setResponse(URL_FIRST, firstContent); @@ -229,7 +231,7 @@ final String frame2 = "<html><head><script>alert(window.foo);</script></head></html>"; final WebClient webClient = getWebClient(); - final MockWebConnection webConnection = new MockWebConnection(); + final MockWebConnection webConnection = getMockWebConnection(); webConnection.setResponse(URL_FIRST, html); webConnection.setResponse(new URL(URL_FIRST, "1.html"), frame1); @@ -263,7 +265,7 @@ final String thirdContent = "<html><head><title>Third</title></head><body></body></html>"; final WebClient client = getWebClient(); - final MockWebConnection webConnection = new MockWebConnection(); + final MockWebConnection webConnection = getMockWebConnection(); webConnection.setResponse(URL_FIRST, firstContent); webConnection.setResponse(URL_SECOND, secondContent); webConnection.setResponse(URL_THIRD, thirdContent); @@ -313,7 +315,7 @@ final WebClient client = getWebClient(); client.getOptions().setJavaScriptEnabled(false); - final MockWebConnection conn = new MockWebConnection(); + final MockWebConnection conn = getMockWebConnection(); conn.setDefaultResponse(html); client.setWebConnection(conn); @@ -463,7 +465,7 @@ + "<body><script>alert(document.body);</script></html>"; final WebClient webClient = getWebClient(); - final MockWebConnection webConnection = new MockWebConnection(); + final MockWebConnection webConnection = getMockWebConnection(); webConnection.setResponse(URL_FIRST, html); webConnection.setDefaultResponse(frame); @@ -540,7 +542,7 @@ + "</script></body></html>"; final String html2 = "<html><body>foo</body></html>"; - final MockWebConnection conn = new MockWebConnection(); + final MockWebConnection conn = getMockWebConnection(); conn.setResponse(URL_FIRST, html); conn.setResponse(new URL(URL_FIRST, "frame.html"), html2); @@ -594,4 +596,44 @@ assertFalse(((HtmlPage) page.getFrames().get(0).getEnclosedPage()).asText().isEmpty()); } + /** + * @throws Exception if the test fails + */ + @Test + public void testRemoveFrameWindow() throws Exception { + final String index = "<html><head></head><body>" + + "<div id='content'>" + + " <iframe name='content' src='second/'></iframe>" + + "</div>" + + "<button id='clickId' " + + "onClick=\"document.getElementById('content').innerHTML = 'new content';\">Item</button>\n" + + "</body></html>"; + + final String frame1 = "<html><head></head><body>" + + "<p>frame content</p>" + + "</body></html>"; + + final WebClient webClient = getWebClient(); + final MockWebConnection webConnection = getMockWebConnection(); + + webConnection.setResponse(URL_SECOND, frame1); + webClient.setWebConnection(webConnection); + + final HtmlPage page = loadPage(index); + + assertEquals("", page.getElementById("content").asText()); + // check frame on page + List<FrameWindow> frames = page.getFrames(); + assertEquals(1, frames.size()); + assertEquals("frame content", ((HtmlPage) page.getFrameByName("content").getEnclosedPage()).asText()); + + // replace frame tag with javascript + ((HtmlElement) page.getElementById("clickId")).click(); + + assertEquals("new content", page.getElementById("content").asText()); + + // frame is still there + frames = page.getFrames(); + assertEquals(0, frames.size()); + } } |
From: <rb...@us...> - 2013-03-22 19:32:33
|
Revision: 8189 http://sourceforge.net/p/htmlunit/code/8189 Author: rbri Date: 2013-03-22 19:32:28 +0000 (Fri, 22 Mar 2013) Log Message: ----------- revert last change because of too many side effects Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebWindowImpl.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrameElement.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/FrameWindow.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-03-22 06:33:45 UTC (rev 8188) +++ trunk/htmlunit/src/changes/changes.xml 2013-03-22 19:32:28 UTC (rev 8189) @@ -8,9 +8,6 @@ <body> <release version="2.13" date="???" description="Bugfixes"> - <action type="fix" dev="rbri" issue="1497"> - JavaScript: Removing frame tag removes the associated FrameWindow also. - </action> <action type="fix" dev="mguillem"> HtmlPage.getElementById: always return the first element in document order (and not the first parsed one). </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebWindowImpl.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebWindowImpl.java 2013-03-22 06:33:45 UTC (rev 8188) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/WebWindowImpl.java 2013-03-22 19:32:28 UTC (rev 8189) @@ -165,10 +165,7 @@ childWindows_.add(child); } - /** - * Destroy our childs. - */ - protected void destroyChildren() { + void destroyChildren() { if (LOG.isDebugEnabled()) { LOG.debug("destroyChildren"); } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrameElement.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrameElement.java 2013-03-22 06:33:45 UTC (rev 8188) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/BaseFrameElement.java 2013-03-22 19:32:28 UTC (rev 8189) @@ -408,14 +408,4 @@ ((BaseFrameElement) node).init(); return node; } - - /** - * Remove our window also. - * {@inheritDoc} - */ - @Override - protected void basicRemove() { - super.basicRemove(); - ((FrameWindow) getEnclosedWindow()).close(); - } } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java 2013-03-22 06:33:45 UTC (rev 8188) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java 2013-03-22 19:32:28 UTC (rev 8189) @@ -1118,7 +1118,7 @@ /** * Cuts off all relationships this node has with siblings and parents. */ - protected void basicRemove() { + private void basicRemove() { if (parent_ != null && parent_.firstChild_ == this) { parent_.firstChild_ = nextSibling_; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/FrameWindow.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/FrameWindow.java 2013-03-22 06:33:45 UTC (rev 8188) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/FrameWindow.java 2013-03-22 19:32:28 UTC (rev 8189) @@ -131,18 +131,4 @@ public String toString() { return "FrameWindow[name=\"" + getName() + "\"]"; } - - /** - * Closes this frame window. - */ - public void close() { - setClosed(); - final Page page = getEnclosedPage(); - if (page != null) { - page.cleanUp(); - } - getJobManager().shutdown(); - destroyChildren(); - getWebClient().deregisterWebWindow(this); - } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElementTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElementTest.java 2013-03-22 06:33:45 UTC (rev 8188) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLIFrameElementTest.java 2013-03-22 19:32:28 UTC (rev 8189) @@ -600,6 +600,7 @@ * @throws Exception if the test fails */ @Test + @NotYetImplemented public void testRemoveFrameWindow() throws Exception { final String index = "<html><head></head><body>" + "<div id='content'>" |