From: <mgu...@us...> - 2013-01-08 09:32:51
|
Revision: 7957 http://sourceforge.net/p/htmlunit/code/7957 Author: mguillem Date: 2013-01-08 09:32:48 +0000 (Tue, 08 Jan 2013) Log Message: ----------- fill HashChangeEvent's old and new URLs when set from JS (makes Location2Test.onHashChangeJS working for FF10+) Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/HashChangeEvent.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/HashChangeEvent.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/HashChangeEvent.java 2013-01-08 09:04:33 UTC (rev 7956) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/HashChangeEvent.java 2013-01-08 09:32:48 UTC (rev 7957) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.javascript.host; +import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.CHROME; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.IE; @@ -30,12 +31,13 @@ * * @version $Revision$ * @author Ronald Brill + * @author Marc Guillemot */ -@JsxClass(browsers = { @WebBrowser(value = IE, minVersion = 8), @WebBrowser(FF) }) +@JsxClass(browsers = { @WebBrowser(value = IE, minVersion = 8), @WebBrowser(FF), @WebBrowser(CHROME) }) public class HashChangeEvent extends UIEvent { - private Object oldURL_; - private Object newURL_; + private String oldURL_; + private String newURL_; /** * Creates a new UI event instance. @@ -53,7 +55,7 @@ * @param newUrl the new url */ public HashChangeEvent(final SimpleScriptable scriptable, final String type, - final Object oldUrl, final Object newUrl) { + final String oldUrl, final String newUrl) { super(scriptable, type); oldURL_ = oldUrl; newURL_ = newUrl; @@ -63,7 +65,7 @@ * Returns the old URL. * @return the old URL */ - @JsxGetter + @JsxGetter({ @WebBrowser(value = FF, minVersion = 10), @WebBrowser(CHROME) }) public Object getOldURL() { return oldURL_; } @@ -72,7 +74,7 @@ * Returns the new URL. * @return the new URL */ - @JsxGetter + @JsxGetter({ @WebBrowser(value = FF, minVersion = 10), @WebBrowser(CHROME) }) public Object getNewURL() { return newURL_; } Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java 2013-01-08 09:04:33 UTC (rev 7956) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Location.java 2013-01-08 09:32:48 UTC (rev 7957) @@ -24,8 +24,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.sourceforge.htmlunit.corejs.javascript.Undefined; - import org.apache.commons.lang3.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -305,11 +303,13 @@ } } final boolean hasChanged = hash != null && !hash.equals(hash_); + final String oldUrl = getHref(); hash_ = hash; + final String newUrl = getHref(); if (hasChanged) { final HashChangeEvent event = new HashChangeEvent(getWindow(), Event.TYPE_HASH_CHANGE, - Undefined.instance, Undefined.instance); + oldUrl, newUrl); getWindow().executeEvent(event); } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java 2013-01-08 09:04:33 UTC (rev 7956) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/Location2Test.java 2013-01-08 09:32:48 UTC (rev 7957) @@ -23,6 +23,8 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.Browser; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -467,6 +469,7 @@ IE6 = { }, IE7 = { }, IE8 = { "supported", "onhashchange -" }) + @NotYetImplemented({ Browser.FF10, Browser.FF17 }) public void onHashChange() throws Exception { final String html = "<html><head>\n" |