From: <rb...@us...> - 2013-04-26 18:49:04
|
Revision: 8244 http://sourceforge.net/p/htmlunit/code/8244 Author: rbri Date: 2013-04-26 18:48:58 +0000 (Fri, 26 Apr 2013) Log Message: ----------- more generic test, more tests and again some fixes for IE8 Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java 2013-04-26 16:57:34 UTC (rev 8243) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/DomNode.java 2013-04-26 18:48:58 UTC (rev 8244) @@ -930,6 +930,9 @@ domNode.onAllChildrenAddedToPage(true); } } + if (this instanceof DomDocumentFragment) { + onAddedToDocumentFragment(); + } fireNodeAdded(this, domNode); } @@ -1202,6 +1205,20 @@ } /** + * Lifecycle method invoked whenever a node is added to a document fragment. Intended to + * be overridden by nodes which need to perform custom logic when they are + * added to a fragment. This method is recursive, so if you override it, please + * be sure to call <tt>super.onAddedToPage()</tt>. + */ + protected void onAddedToDocumentFragment() { + if (firstChild_ != null) { + for (final DomNode child : getChildren()) { + child.onAddedToDocumentFragment(); + } + } + } + + /** * @return an Iterable over the children of this node */ public final Iterable<DomNode> getChildren() { Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java 2013-04-26 16:57:34 UTC (rev 8243) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput.java 2013-04-26 18:48:58 UTC (rev 8244) @@ -188,6 +188,8 @@ */ @Override protected void onAddedToPage() { + super.onAddedToPage(); + if (hasFeature(HTMLINPUT_SET_CHECKED_TO_DEFAULT_WHEN_ADDED)) { reset(); } @@ -205,6 +207,26 @@ * {@inheritDoc} */ @Override + protected void onAddedToDocumentFragment() { + super.onAddedToDocumentFragment(); + + if (hasFeature(HTMLINPUT_SET_CHECKED_TO_DEFAULT_WHEN_ADDED)) { + reset(); + } + if (hasFeature(HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_ADDED)) { + if (wasCreatedByJavascript()) { + removeAttribute("checked"); + } + else if (forceChecked_) { + setAttribute("checked", "checked"); + } + } + } + + /** + * {@inheritDoc} + */ + @Override public DomNode cloneNode(final boolean deep) { final HtmlCheckBoxInput clone = (HtmlCheckBoxInput) super.cloneNode(deep); if (hasFeature(HTMLINPUT_SET_CHECKED_TO_FALSE_WHEN_ADDED)) { Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java 2013-04-26 16:57:34 UTC (rev 8243) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlCheckBoxInput2Test.java 2013-04-26 18:48:58 UTC (rev 8244) @@ -41,292 +41,233 @@ public class HtmlCheckBoxInput2Test extends WebDriverTestCase { /** - * Verifies the behavior of 'checked' property on being attached to a page. * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }, - IE = { "true", "false", "false", "false", "false", "false" }, - IE6 = { "true", "false", "false", "false", "true", "true" }) - public void checked_appendChild() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var input = document.createElement('input');\n" - + " input.type = 'checkbox';\n" - + " input.checked = true;\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'></div></div></form>\n" - + "</body></html>"; + @Alerts(DEFAULT = { "true", "true", "true" }, + IE = { "true", "false", "false" }) + public void checked_appendChild_docFragment() throws Exception { + performTest(true, true, false, true, false); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "false", "false", "false" }) + public void notchecked_appendChild_docFragment() throws Exception { + performTest(false, true, false, true, false); } /** * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "false", "false", "false", "true", "true", "true" }, - IE = { "false", "false", "false", "false", "false", "false" }, - IE6 = { "false", "false", "false", "false", "true", "true" }) - public void notchecked_appendChild() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var input = document.createElement('input');\n" - + " input.type = 'checkbox';\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'></div></form>\n" - + "</body></html>"; + @Alerts(DEFAULT = { "true", "true", "true" }, + IE = { "true", "false", "false" }) + public void checked_insertBefore_docFragment() throws Exception { + performTest(true, false, false, true, false); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "false", "false", "false" }) + public void notchecked_insertBefore_docFragment() throws Exception { + performTest(false, false, false, true, false); } /** * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "false", "false", "false", "true", "true", "true" }, - IE = { "false", "false", "false", "false", "false", "false" }, - IE6 = { "false", "false", "false", "false", "true", "true" }) - public void notchecked_insertBefore() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var input = document.createElement('input');\n" - + " input.type = 'checkbox';\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " var after=document.getElementById('divAfter');\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'><div id='divAfter'></div></div></form>\n" - + "</body></html>"; + @Alerts(DEFAULT = { "true", "true", "true" }) + public void checked_appendChild_fromHtml_docFragment() throws Exception { + performTest(true, true, true, true, false); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "false", "false", "false" }) + public void notchecked_appendChild_fromHtml_docFragment() throws Exception { + performTest(false, true, true, true, false); } /** * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }, - IE = { "true", "false", "false", "false", "false", "false" }, - IE6 = { "true", "false", "false", "false", "true", "true" }) - public void checked_insertBefore() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var input = document.createElement('input');\n" - + " input.type = 'checkbox';\n" - + " input.checked = true;\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " var after=document.getElementById('divAfter');\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'><div id='divAfter'></div></div></form>\n" - + "</body></html>"; + @Alerts(DEFAULT = { "true", "true", "true" }) + public void checked_insertBefore_fromHtml_docFragment() throws Exception { + performTest(true, false, true, true, false); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "false", "false", "false" }) + public void notchecked_insertBefore_fromHtml_docFragment() throws Exception { + performTest(false, false, true, true, false); } /** - * Verifies the behavior of 'checked' property on being attached to a page. * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }) - public void checked_appendChild_fromHtml() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var builder = document.createElement('div');\n" - + " builder.innerHTML = '<input type=\"checkbox\" checked>';\n" - + " var input = builder.firstChild;\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'></div></div></form>\n" - + "</body></html>"; + @Alerts(DEFAULT = { "true", "true", "true" }, + IE = { "true", "false", "false" }) + public void checked_appendChild_docFragment_cloneNode() throws Exception { + performTest(true, true, false, true, true); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "false", "false", "false" }) + public void notchecked_appendChild_docFragment_cloneNode() throws Exception { + performTest(false, true, false, true, true); } /** * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "false", "false", "false", "true", "true", "true" }, - IE = { "false", "false", "false", "false", "false", "false" }, - IE6 = { "false", "false", "false", "false", "true", "true" }) - public void notchecked_appendChild_fromHtml() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var builder = document.createElement('div');\n" - + " builder.innerHTML = '<input type=\"checkbox\">';\n" - + " var input = builder.firstChild;\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'></div></form>\n" - + "</body></html>"; + @Alerts(DEFAULT = { "true", "true", "true" }, + IE = { "true", "false", "false" }) + public void checked_insertBefore_docFragment_cloneNode() throws Exception { + performTest(true, false, false, true, true); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "false", "false", "false" }) + public void notchecked_insertBefore_docFragment_cloneNode() throws Exception { + performTest(false, false, false, true, true); } /** * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "false", "false", "false", "true", "true", "true" }, - IE = { "false", "false", "false", "false", "false", "false" }, - IE6 = { "false", "false", "false", "false", "true", "true" }) - public void notchecked_insertBefore_fromHtml() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var builder = document.createElement('div');\n" - + " builder.innerHTML = '<input type=\"checkbox\">';\n" - + " var input = builder.firstChild;\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " var after=document.getElementById('divAfter');\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'><div id='divAfter'></div></div></form>\n" - + "</body></html>"; + @Alerts(DEFAULT = { "true", "true", "true" }) + public void checked_appendChild_fromHtml_docFragment_cloneNode() throws Exception { + performTest(true, true, true, true, true); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "false", "false", "false" }) + public void notchecked_appendChild_fromHtml_docFragment_cloneNode() throws Exception { + performTest(false, true, true, true, true); } /** * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }) - public void checked_insertBefore_fromHtml() throws Exception { - final String html = "<html>\n" + @Alerts(DEFAULT = { "true", "true", "true" }) + public void checked_insertBefore_fromHtml_docFragment_cloneNode() throws Exception { + performTest(true, false, true, true, true); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "false", "false", "false" }) + public void notchecked_insertBefore_fromHtml_docFragment_cloneNode() throws Exception { + performTest(false, false, true, true, true); + } + + private void performTest(final boolean checked, + final boolean appendChild, + final boolean fromHtml, + final boolean useFragment, + boolean cloneNode) throws Exception { + String html = "<html>\n" + "<head>\n" + " <script>\n" - + " function test() {\n" - + " var builder = document.createElement('div');\n" - + " builder.innerHTML = '<input type=\"checkbox\" checked>';\n" - + " var input = builder.firstChild;\n" + + " function test() {\n"; + if (fromHtml) { + html = html + + " var builder = document.createElement('div');\n" + + " builder.innerHTML = '<input type=\"checkbox\""; + if (checked) { + html = html + " checked"; + } + html = html + ">';\n" + + " var input = builder.firstChild;\n"; + } + else { + html = html + + " var input = document.createElement('input');\n" + + " input.type = 'checkbox';\n"; + if (checked) { + html = html + " input.checked = true;\n"; + } + } + + if (cloneNode && !useFragment) { + html = html + + " input=input.cloneNode(true);\n"; + cloneNode = false; + } + html = html + " alert(input.checked);\n" + + " var parent=document.getElementById('myDiv');\n" - + " var after=document.getElementById('divAfter');\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" + + " var after=document.getElementById('divAfter');\n"; + if (useFragment) { + html = html + + " var appendix=document.createDocumentFragment();\n" + + " appendix.appendChild(input);\n" + + " alert(input.checked);\n"; + } + else { + html = html + + " var appendix=input\n"; + } + if (appendChild) { + if (cloneNode) { + html = html + " parent.appendChild(appendix.cloneNode(true));\n"; + } + else { + html = html + " parent.appendChild(appendix);\n"; + } + } + else { + if (cloneNode) { + html = html + " parent.insertBefore(appendix.cloneNode(true), after);\n"; + } + else { + html = html + " parent.insertBefore(appendix, after);\n"; + } + } + html = html + + " input = parent.getElementsByTagName('input')[0];\n" + + " alert(input.checked);\n"; + if (!useFragment) { + html = html + + " parent.removeChild(input);\n" + + " alert(input.checked);\n" + + "\n" + + " input.defaultChecked = true;\n" + + " alert(input.checked);\n" + + " parent.appendChild(input);\n" + + " alert(input.checked);\n" + + " parent.removeChild(input);\n" + + " alert(input.checked);\n"; + } + html = html + " }\n" + " </script>\n" + "</head><body onload='test()'>\n" @@ -337,42 +278,14 @@ } /** - * Verifies the behavior of 'checked' property on being attached to a page. * @throws Exception if the test fails */ @Test @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }, - IE = { "false", "false", "false", "false", "false", "false" }, + IE = { "true", "false", "false", "false", "false", "false" }, IE6 = { "true", "false", "false", "false", "true", "true" }) - public void checked_cloneNode_appendChild() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var input = document.createElement('input');\n" - + " input.type = 'checkbox';\n" - + " input.checked = true;\n" - + " input = input.cloneNode(false);\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'></div></div></form>\n" - + "</body></html>"; - - loadPageWithAlerts2(html); + public void checked_appendChild() throws Exception { + performTest(true, true, false, false, false); } /** @@ -382,34 +295,19 @@ @Alerts(DEFAULT = { "false", "false", "false", "true", "true", "true" }, IE = { "false", "false", "false", "false", "false", "false" }, IE6 = { "false", "false", "false", "false", "true", "true" }) - public void notchecked_cloneNode_appendChild() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var input = document.createElement('input');\n" - + " input.type = 'checkbox';\n" - + " input = input.cloneNode(false);\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'></div></form>\n" - + "</body></html>"; + public void notchecked_appendChild() throws Exception { + performTest(false, true, false, false, false); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }, + IE = { "true", "false", "false", "false", "false", "false" }, + IE6 = { "true", "false", "false", "false", "true", "true" }) + public void checked_insertBefore() throws Exception { + performTest(true, false, false, false, false); } /** @@ -419,112 +317,59 @@ @Alerts(DEFAULT = { "false", "false", "false", "true", "true", "true" }, IE = { "false", "false", "false", "false", "false", "false" }, IE6 = { "false", "false", "false", "false", "true", "true" }) - public void notchecked_cloneNode_insertBefore() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var input = document.createElement('input');\n" - + " input.type = 'checkbox';\n" - + " input = input.cloneNode(false);\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " var after=document.getElementById('divAfter');\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'><div id='divAfter'></div></div></form>\n" - + "</body></html>"; + public void notchecked_insertBefore() throws Exception { + performTest(false, false, false, false, false); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }) + public void checked_appendChild_fromHtml() throws Exception { + performTest(true, true, true, false, false); } /** * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }, + @Alerts(DEFAULT = { "false", "false", "false", "true", "true", "true" }, IE = { "false", "false", "false", "false", "false", "false" }, IE6 = { "false", "false", "false", "false", "true", "true" }) - public void checked_cloneNode_insertBefore() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var input = document.createElement('input');\n" - + " input.type = 'checkbox';\n" - + " input.checked = true;\n" - + " input = input.cloneNode(false);\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " var after=document.getElementById('divAfter');\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'><div id='divAfter'></div></div></form>\n" - + "</body></html>"; + public void notchecked_appendChild_fromHtml() throws Exception { + performTest(false, true, true, false, false); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }) + public void checked_insertBefore_fromHtml() throws Exception { + performTest(true, false, true, false, false); } /** - * Verifies the behavior of 'checked' property on being attached to a page. * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = { "false", "false", "false", "true", "true", "true" }, + IE = { "false", "false", "false", "false", "false", "false" }, + IE6 = { "false", "false", "false", "false", "true", "true" }) + public void notchecked_insertBefore_fromHtml() throws Exception { + performTest(false, false, true, false, false); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }, - IE = { "false", "true", "true", "true", "true", "true" }) - public void checked_cloneNode_appendChild_fromHtml() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var builder = document.createElement('div');\n" - + " builder.innerHTML = '<input type=\"checkbox\" checked>';\n" - + " var input = builder.firstChild;\n" - + " input = input.cloneNode(false);\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'></div></div></form>\n" - + "</body></html>"; - - loadPageWithAlerts2(html); + IE = { "false", "false", "false", "false", "false", "false" }, + IE6 = { "true", "false", "false", "false", "true", "true" }) + public void checked_appendChild_cloneNode() throws Exception { + performTest(true, true, false, false, true); } /** @@ -534,35 +379,19 @@ @Alerts(DEFAULT = { "false", "false", "false", "true", "true", "true" }, IE = { "false", "false", "false", "false", "false", "false" }, IE6 = { "false", "false", "false", "false", "true", "true" }) - public void notchecked_cloneNode_appendChild_fromHtml() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var builder = document.createElement('div');\n" - + " builder.innerHTML = '<input type=\"checkbox\">';\n" - + " var input = builder.firstChild;\n" - + " input = input.cloneNode(false);\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.appendChild(input);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'></div></form>\n" - + "</body></html>"; + public void notchecked_appendChild_cloneNode() throws Exception { + performTest(false, true, false, false, true); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }, + IE = { "false", "false", "false", "false", "false", "false" }, + IE6 = { "false", "false", "false", "false", "true", "true" }) + public void checked_insertBefore_cloneNode() throws Exception { + performTest(true, false, false, false, true); } /** @@ -572,74 +401,50 @@ @Alerts(DEFAULT = { "false", "false", "false", "true", "true", "true" }, IE = { "false", "false", "false", "false", "false", "false" }, IE6 = { "false", "false", "false", "false", "true", "true" }) - public void notchecked_cloneNode_insertBefore_fromHtml() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var builder = document.createElement('div');\n" - + " builder.innerHTML = '<input type=\"checkbox\">';\n" - + " var input = builder.firstChild;\n" - + " input = input.cloneNode(false);\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " var after=document.getElementById('divAfter');\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'><div id='divAfter'></div></div></form>\n" - + "</body></html>"; + public void notchecked_insertBefore_cloneNode() throws Exception { + performTest(false, false, false, false, true); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }, + IE = { "false", "true", "true", "true", "true", "true" }) + public void checked_appendChild_fromHtml_cloneNode() throws Exception { + performTest(true, true, true, false, true); } /** * @throws Exception if the test fails */ @Test + @Alerts(DEFAULT = { "false", "false", "false", "true", "true", "true" }, + IE = { "false", "false", "false", "false", "false", "false" }, + IE6 = { "false", "false", "false", "false", "true", "true" }) + public void notchecked_appendChild_fromHtml_cloneNode() throws Exception { + performTest(false, true, true, false, true); + } + + /** + * @throws Exception if the test fails + */ + @Test @Alerts(DEFAULT = { "true", "true", "true", "true", "true", "true" }, IE = { "false", "true", "true", "true", "true", "true" }) public void checked_cloneNode_insertBefore_fromHtml() throws Exception { - final String html = "<html>\n" - + "<head>\n" - + " <script>\n" - + " function test() {\n" - + " var builder = document.createElement('div');\n" - + " builder.innerHTML = '<input type=\"checkbox\" checked>';\n" - + " var input = builder.firstChild;\n" - + " input = input.cloneNode(false);\n" - + " alert(input.checked);\n" - + " var parent=document.getElementById('myDiv');\n" - + " var after=document.getElementById('divAfter');\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + "\n" - + " input.defaultChecked = true;\n" - + " alert(input.checked);\n" - + " parent.insertBefore(input, after);\n" - + " alert(input.checked);\n" - + " parent.removeChild(input);\n" - + " alert(input.checked);\n" - + " }\n" - + " </script>\n" - + "</head><body onload='test()'>\n" - + " <form><div id='myDiv'><div id='divAfter'></div></div></form>\n" - + "</body></html>"; + performTest(true, false, true, false, true); + } - loadPageWithAlerts2(html); + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "false", "false", "false", "true", "true", "true" }, + IE = { "false", "false", "false", "false", "false", "false" }, + IE6 = { "false", "false", "false", "false", "true", "true" }) + public void notchecked_insertBefore_fromHtml_cloneNode() throws Exception { + performTest(false, false, true, false, true); } /** |