From: <mgu...@us...> - 2013-07-09 09:04:50
|
Revision: 8381 http://sourceforge.net/p/htmlunit/code/8381 Author: mguillem Date: 2013-07-09 09:04:47 +0000 (Tue, 09 Jul 2013) Log Message: ----------- JavaScript: add basic support for window.navigator.security (FF only) Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java Added Paths: ----------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Netscape.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NetscapeTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-07-07 21:27:49 UTC (rev 8380) +++ trunk/htmlunit/src/changes/changes.xml 2013-07-09 09:04:47 UTC (rev 8381) @@ -8,6 +8,9 @@ <body> <release version="2.13" date="???" description="Bugfixes"> + <action type="fix" dev="mguillem"> + JavaScript: add basic support for window.navigator.security (FF only). + </action> <action type="fix" dev="rbri" issue="1510"> Make the handling of empty responses more error proof. </action> Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Netscape.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Netscape.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Netscape.java 2013-07-09 09:04:47 UTC (rev 8381) @@ -0,0 +1,44 @@ +/* + * 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.javascript.host; + +import static com.gargoylesoftware.htmlunit.javascript.configuration.BrowserName.FF; +import net.sourceforge.htmlunit.corejs.javascript.Context; + +import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; +import com.gargoylesoftware.htmlunit.javascript.configuration.WebBrowser; + +/** + * A JavaScript object for window.netscape (FF simulation only). + * + * @version $Revision$ + * @author Marc Guillemot + */ +@JsxClass(browsers = @WebBrowser(FF)) +public class Netscape extends SimpleScriptable { + + Netscape(final Window window) { + setParentScope(window); + + // simply put "new Object()" for property "security" + put("security", this, Context.getCurrentContext().newObject(window)); + } + + @Override + public String getClassName() { + return "Object"; + } +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Netscape.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/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2013-07-07 21:27:49 UTC (rev 8380) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/Window.java 2013-07-09 09:04:47 UTC (rev 8381) @@ -1939,6 +1939,15 @@ } /** + * Returns the value of "netscape" property. + * @return the value of "netscape" property + */ + @JsxGetter(@WebBrowser(FF)) + public Netscape getNetscape() { + return new Netscape(this); + } + + /** * Executes the event on this object only (needed for instance for onload on (i)frame tags). * @param event the event * @return the result Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NetscapeTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NetscapeTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NetscapeTest.java 2013-07-09 09:04:47 UTC (rev 8381) @@ -0,0 +1,56 @@ +/* + * 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.javascript.host; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Browser; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; + +/** + * Tests for {@link Netscape}. + * + * @version $Revision$ + * @author Marc Guillemot + */ +@RunWith(BrowserRunner.class) +public class NetscapeTest extends WebDriverTestCase { + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "undefined", "undefined", "exception" }, + FF3_6 = { "[object Object]", "undefined", "[object Object]", "[object Object]" }, + FF = { "[object Object]", "undefined", "[object Object]", "undefined" }) + @NotYetImplemented(Browser.FF3_6) + public void netscape() throws Exception { + final String html = "<html><body><script>\n" + + "try {\n" + + " alert(window.netscape);\n" + + " alert(window.Netscape);\n" + + " alert(window.netscape.security);\n" + + " alert(window.netscape.security.PrivilegeManager);\n" + + "} catch(e) { alert('exception'); }\n" + + "</script></body></html>"; + + loadPageWithAlerts2(html); + } + +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/NetscapeTest.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 |