From: <rb...@us...> - 2014-01-04 12:26:50
|
Revision: 8948 http://sourceforge.net/p/htmlunit/code/8948 Author: rbri Date: 2014-01-04 12:26:46 +0000 (Sat, 04 Jan 2014) Log Message: ----------- missing stuff from last commit Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ApplicationCache.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ApplicationCacheTest.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ApplicationCache.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ApplicationCache.java 2014-01-04 11:42:57 UTC (rev 8947) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/ApplicationCache.java 2014-01-04 12:26:46 UTC (rev 8948) @@ -14,7 +14,10 @@ */ package com.gargoylesoftware.htmlunit.javascript.host; +import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_APPCACHE_NAME_OFFLINERESOURCELIST; +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; import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; @@ -24,8 +27,7 @@ import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; /** - * <p>A collection of offline resources as defined in the - * <a href="http://www.w3.org/TR/2008/WD-html5-20080122/#appcache">HTML5 spec</a>. + * <p>A collection of offline resources as defined in the HTML5 spec. * Intended to support offline web applications.</p> * * <p><b>NOTE:</b> This class is essentially a skeleton implementation providing minimal @@ -35,10 +37,13 @@ * * @version $Revision$ * @author Daniel Gredler + * @author Frank Danek + * @see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/offline.html#application-cache-api"> + * HTML5 spec</a> * @see <a href="https://developer.mozilla.org/en/offline_resources_in_firefox">Offline Resources in Firefox</a> * @see <a href="https://developer.mozilla.org/en/nsIDOMOfflineResourceList">Mozilla Documentation</a> */ -@JsxClass(browsers = @WebBrowser(FF)) +@JsxClass(browsers = { @WebBrowser(CHROME), @WebBrowser(FF), @WebBrowser(value = IE, minVersion = 11) }) public class ApplicationCache extends SimpleScriptable { /** The object isn't associated with an application cache. */ @@ -64,6 +69,19 @@ private Object oncached_; /** + * {@inheritDoc} + */ + @Override + public String getClassName() { + if (getWindow().getWebWindow() != null) { + if (getBrowserVersion().hasFeature(JS_APPCACHE_NAME_OFFLINERESOURCELIST)) { + return "OfflineResourceList"; + } + } + return super.getClassName(); + } + + /** * Returns the event listener to be called when fetching the application cache manifest and checking for updates. * @return the event listener to be called when fetching the application cache manifest and checking for updates */ Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ApplicationCacheTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ApplicationCacheTest.java 2014-01-04 11:42:57 UTC (rev 8947) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/ApplicationCacheTest.java 2014-01-04 12:26:46 UTC (rev 8948) @@ -19,10 +19,11 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.html.HtmlPageTest; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** - * Unit tests for {@link OfflineResourceList}. + * Tests for {@link ApplicationCache}. * * @version $Revision$ * @author Daniel Gredler @@ -32,20 +33,22 @@ public class ApplicationCacheTest extends WebDriverTestCase { /** - * @throws Exception if an error occurs + * @throws Exception if the test fails */ @Test - @Alerts(FF = "[object OfflineResourceList]", - IE = "undefined", - IE11 = "[object ApplicationCache]") - public void existence() throws Exception { - final String html - = "<html><body>\n" - + "<script>\n" - + " alert(window.applicationCache);\n" - + "</script>\n" + @Alerts(DEFAULT = "[object ApplicationCache]", + FF = "[object OfflineResourceList]", + IE8 = "undefined") + public void scriptableToString() throws Exception { + final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_ + + "<html><head><title>foo</title><script>\n" + + " function test() {\n" + + " alert(window.applicationCache);\n" + + " }\n" + + "</script></head>\n" + + "<body onload='test()'>\n" + "</body></html>"; + loadPageWithAlerts2(html); } - } |