From: <asa...@us...> - 2014-03-06 01:03:55
|
Revision: 9154 http://sourceforge.net/p/htmlunit/code/9154 Author: asashour Date: 2014-03-06 01:03:48 +0000 (Thu, 06 Mar 2014) Log Message: ----------- JavaScript: fix setting value to toString() function. Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/FunctionWrapper.java Added Paths: ----------- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/FunctionsWrapperTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2014-03-05 19:10:38 UTC (rev 9153) +++ trunk/htmlunit/src/changes/changes.xml 2014-03-06 01:03:48 UTC (rev 9154) @@ -8,6 +8,9 @@ <body> <release version="2.15" date="???" description="Bugfixes"> + <action type="fix" dev="asashour"> + JavaScript: fix setting value to toString() function. + </action> <action type="update" dev="asashour"> Upgrade Apache commons-lang to 3.3. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/FunctionWrapper.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/FunctionWrapper.java 2014-03-05 19:10:38 UTC (rev 9153) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/FunctionWrapper.java 2014-03-06 01:03:48 UTC (rev 9154) @@ -20,8 +20,10 @@ /** * Wrapper for a {@link Function} delegating all calls to the wrapped instance. + * * @version $Revision$ * @author Marc Guillemot + * @author Ahmed Ashour */ class FunctionWrapper implements Function { private final Function wrapped_; @@ -59,7 +61,7 @@ } public void put(final String name, final Scriptable start, final Object value) { - wrapped_.put(name, start, value); + wrapped_.put(name, wrapped_, value); } public void put(final int index, final Scriptable start, final Object value) { Added: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/FunctionsWrapperTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/FunctionsWrapperTest.java (rev 0) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/FunctionsWrapperTest.java 2014-03-06 01:03:48 UTC (rev 9154) @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2002-2014 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; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.gargoylesoftware.htmlunit.BrowserRunner; +import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.WebDriverTestCase; + +/** + * Tests for {@link FunctionWrapper}. + * + * @version $Revision$ + * @author Ahmed Ashour + */ +@RunWith(BrowserRunner.class) +public class FunctionsWrapperTest extends WebDriverTestCase { + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts("1") + public void function_toString() throws Exception { + final String html + = "<html><head><title>foo</title><script>\n" + + "function test() {\n" + + " var x = test.toString;\n" + + " x.guid = 1;\n" + + " alert(x.guid);\n" + + "}\n" + + "</script></head><body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } +} Property changes on: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/FunctionsWrapperTest.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property 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 |