From: <rb...@us...> - 2013-10-30 20:18:52
|
Revision: 8716 http://sourceforge.net/p/htmlunit/code/8716 Author: rbri Date: 2013-10-30 20:18:48 +0000 (Wed, 30 Oct 2013) Log Message: ----------- HTMLElement.insertAdjacentHTML() is available in FF since version 8 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/html/HTMLParserListenerTest.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement3Test.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-10-30 19:38:15 UTC (rev 8715) +++ trunk/htmlunit/src/changes/changes.xml 2013-10-30 20:18:48 UTC (rev 8716) @@ -8,8 +8,11 @@ <body> <release version="2.14" date="???" description="Bugfixes"> + <action type="fix" dev="rbri"> + JavaScript: HTMLElement.insertAdjacentHTML() is available in FF since version 8. + </action> <action type="add" dev="rbri"> - JavaScript: Embed now supports the width and hight property. + JavaScript: Embed now supports the width and height property. </action> <action type="fix" dev="rbri" issue="1551"> JavaScript: send the correct Referer header when changing the location property. 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 2013-10-30 19:38:15 UTC (rev 8715) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement.java 2013-10-30 20:18:48 UTC (rev 8716) @@ -1209,7 +1209,7 @@ * beforeBegin, afterBegin, beforeEnd, afterEnd * @param text the HTML text to insert */ - @JsxFunction(@WebBrowser(IE)) + @JsxFunction({ @WebBrowser(IE), @WebBrowser(CHROME), @WebBrowser(value = FF, minVersion = 8) }) public void insertAdjacentHTML(final String where, final String text) { final Object[] values = getInsertAdjacentLocation(where); final DomNode node = (DomNode) values[0]; Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParserListenerTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParserListenerTest.java 2013-10-30 19:38:15 UTC (rev 8715) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HTMLParserListenerTest.java 2013-10-30 20:18:48 UTC (rev 8716) @@ -14,8 +14,6 @@ */ package com.gargoylesoftware.htmlunit.html; -import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.IE; - import java.net.URL; import java.util.ArrayList; import java.util.List; @@ -26,7 +24,6 @@ import org.junit.runner.RunWith; import com.gargoylesoftware.htmlunit.BrowserRunner; -import com.gargoylesoftware.htmlunit.BrowserRunner.Browsers; import com.gargoylesoftware.htmlunit.MockWebConnection; import com.gargoylesoftware.htmlunit.SimpleWebTestCase; import com.gargoylesoftware.htmlunit.WebClient; @@ -177,7 +174,6 @@ * @exception Exception If the test fails */ @Test - @Browsers(IE) public void parseFragment() throws Exception { final String html = "<html><head><title>foo</title>\n" + "<script>\n" Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement3Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement3Test.java 2013-10-30 19:38:15 UTC (rev 8715) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElement3Test.java 2013-10-30 20:18:48 UTC (rev 8716) @@ -133,55 +133,7 @@ * @throws Exception if the test fails */ @Test - @Browsers(IE) @Alerts({ "outside", "1", "middle", "2", "3", "4" }) - public void insertAdjacentHTML() throws Exception { - insertAdjacentHTML("beforeEnd", "afterEnd", "beforeBegin", "afterBegin"); - insertAdjacentHTML("BeforeEnd", "AfterEnd", "BeFoReBeGiN", "afterbegin"); - } - - /** - * @param beforeEnd data to insert - * @param afterEnd data to insert - * @param beforeBegin data to insert - * @param afterBegin data to insert - * @throws Exception if the test fails - */ - private void insertAdjacentHTML(final String beforeEnd, - final String afterEnd, final String beforeBegin, final String afterBegin) throws Exception { - final String html = "<html><head><title>First</title>\n" - + "<script>\n" - + "function test() {\n" - + " var oNode = document.getElementById('middle');\n" - + " oNode.insertAdjacentHTML('" + beforeEnd + "', ' <span id=3>before end</span> ');\n" - + " oNode.insertAdjacentHTML('" + afterEnd + "', ' <span id=4>after end</span> ');\n" - + " oNode.insertAdjacentHTML('" + beforeBegin + "', ' <span id=1>before begin</span> ');\n" - + " oNode.insertAdjacentHTML('" + afterBegin + "', ' <span id=2>after begin</span> ');\n" - + " var coll = document.getElementsByTagName('SPAN');\n" - + " for (var i=0; i<coll.length; i++) {\n" - + " alert(coll[i].id);\n" - + " }\n" - + "}\n" - + "</script>\n" - + "</head>\n" - + "<body onload='test()'>\n" - + "<span id='outside' style='color: #00ff00'>\n" - + "<span id='middle' style='color: #ff0000'>\n" - + "inside\n" - + "</span>\n" - + "</span>\n" - + "</body></html>"; - final HtmlPage page = loadPageWithAlerts(html); - final HtmlElement elt = page.getHtmlElementById("outside"); - assertEquals("before begin after begin inside before end after end", elt.asText()); - } - - /** - * @throws Exception if the test fails - */ - @Test - @Browsers(IE) - @Alerts({ "outside", "1", "middle", "2", "3", "4" }) public void insertAdjacentElement() throws Exception { insertAdjacentElement("beforeEnd", "afterEnd", "beforeBegin", "afterBegin"); insertAdjacentElement("BeforeEnd", "AfterEnd", "BeFoReBeGiN", "afterbegin"); 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 2013-10-30 19:38:15 UTC (rev 8715) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/html/HTMLElementTest.java 2013-10-30 20:18:48 UTC (rev 8716) @@ -4233,4 +4233,55 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts({ "outside", "1", "middle", "2", "3", "4", + "before begin after begin inside before end after end" }) + public void insertAdjacentHTML() throws Exception { + insertAdjacentHTML("beforeEnd", "afterEnd", "beforeBegin", "afterBegin"); + insertAdjacentHTML("BeforeEnd", "AfterEnd", "BeFoReBeGiN", "afterbegin"); + } + + /** + * @param beforeEnd data to insert + * @param afterEnd data to insert + * @param beforeBegin data to insert + * @param afterBegin data to insert + * @throws Exception if the test fails + */ + private void insertAdjacentHTML(final String beforeEnd, + final String afterEnd, final String beforeBegin, final String afterBegin) throws Exception { + final String html = "<html><head><title>First</title>\n" + + "<script>\n" + + "function test() {\n" + + " var oNode = document.getElementById('middle');\n" + + " oNode.insertAdjacentHTML('" + beforeEnd + "', ' <span id=3>before end</span> ');\n" + + " oNode.insertAdjacentHTML('" + afterEnd + "', ' <span id=4>after end</span> ');\n" + + " oNode.insertAdjacentHTML('" + beforeBegin + "', ' <span id=1>before begin</span> ');\n" + + " oNode.insertAdjacentHTML('" + afterBegin + "', ' <span id=2>after begin</span> ');\n" + + " var coll = document.getElementsByTagName('SPAN');\n" + + " for (var i=0; i<coll.length; i++) {\n" + + " alert(coll[i].id);\n" + + " }\n" + + " var outside = document.getElementById('outside');\n" + + " var text = outside.textContent ? outside.textContent : outside.innerText;\n" + + " text = text.replace(/(\\r\\n|\\r|\\n)/gm, '');\n" + + " text = text.replace(/(\\s{2,})/g, ' ');\n" + + " text = text.replace(/^\\s+|\\s+$/g, '');\n" + + " alert(text);\n" + + "}\n" + + "</script>\n" + + "</head>\n" + + "<body onload='test()'>\n" + + " <span id='outside' style='color: #00ff00'>\n" + + " <span id='middle' style='color: #ff0000'>\n" + + " inside\n" + + " </span>\n" + + " </span>\n" + + "</body></html>"; + loadPageWithAlerts2(html); + } } |