From: <asa...@us...> - 2012-11-09 11:07:43
|
Revision: 7704 http://sourceforge.net/p/htmlunit/code/7704 Author: asashour Date: 2012-11-09 11:07:39 +0000 (Fri, 09 Nov 2012) Log Message: ----------- JavaScript: implement "dataset" property (FF). Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java Added Paths: ----------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMStringMap.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2012-11-09 06:35:04 UTC (rev 7703) +++ trunk/htmlunit/src/changes/changes.xml 2012-11-09 11:07:39 UTC (rev 7704) @@ -8,6 +8,9 @@ <body> <release version="2.12" date="???" description="Bugfixes"> + <action type="add" dev="asashour"> + JavaScript: implement "dataset" property (FF). + </action> <action type="remove" dev="asashour" issue="1420"> JavaScript: remove "constructor" property of host objects (IE). </action> Added: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMStringMap.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMStringMap.java (rev 0) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMStringMap.java 2012-11-09 11:07:39 UTC (rev 7704) @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2002-2012 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 com.gargoylesoftware.htmlunit.javascript.SimpleScriptable; +import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass; + +/** + * A JavaScript object for DOMStringMap. + * + * @version $Revision$ + * @author Ahmed Ashour + */ +@JsxClass +public final class DOMStringMap extends SimpleScriptable { + + /** + * Creates an instance. JavaScript objects must have a default constructor. + */ + public DOMStringMap() { + } + + /** + * Creates an instance. + * @param node the node which contains the underlying string + */ + public DOMStringMap(final Node node) { + setDomNode(node.getDomNodeOrDie(), false); + setParentScope(node.getParentScope()); + setPrototype(getPrototype(getClass())); + } + +} Property changes on: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/DOMStringMap.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native 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 2012-11-09 06:35:04 UTC (rev 7703) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java 2012-11-09 11:07:39 UTC (rev 7704) @@ -101,6 +101,7 @@ import com.gargoylesoftware.htmlunit.javascript.host.Attr; import com.gargoylesoftware.htmlunit.javascript.host.BoxObject; import com.gargoylesoftware.htmlunit.javascript.host.ClientRect; +import com.gargoylesoftware.htmlunit.javascript.host.DOMStringMap; import com.gargoylesoftware.htmlunit.javascript.host.DOMTokenList; import com.gargoylesoftware.htmlunit.javascript.host.Element; import com.gargoylesoftware.htmlunit.javascript.host.Event; @@ -2797,4 +2798,14 @@ public Element getParentElement() { return super.getParentElement(); } + + /** + * Returns the "dataset" attribute. + * @return the "dataset" attribute + */ + @JsxGetter({ @WebBrowser(value = FF, minVersion = 10), @WebBrowser(CHROME) }) + public DOMStringMap getDataset() { + return new DOMStringMap(this); + } + } 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 2012-11-09 06:35:04 UTC (rev 7703) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2012-11-09 11:07:39 UTC (rev 7704) @@ -2536,4 +2536,24 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(IE = "undefined", FF3_6 = "undefined", DEFAULT = "[object DOMStringMap]") + public void dataset() throws Exception { + final String html + = "<html><head>\n" + + "<script>\n" + + " function test() {\n" + + " alert(document.body.dataset);\n" + + " }\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |