From: <rb...@us...> - 2013-05-27 21:33:57
|
Revision: 8314 http://sourceforge.net/p/htmlunit/code/8314 Author: rbri Date: 2013-05-27 21:33:52 +0000 (Mon, 27 May 2013) Log Message: ----------- fix test for IE8 Modified Paths: -------------- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-27 13:31:49 UTC (rev 8313) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2013-05-27 21:33:52 UTC (rev 8314) @@ -753,7 +753,7 @@ JS_BUTTON_SET_TYPE_THROWS_EXCEPTION, /** IE uses the content of a button tag as value instead of the attribute. */ - @BrowserFeature(@WebBrowser(IE)) + @BrowserFeature(@WebBrowser(value = IE, maxVersion = 7)) JS_BUTTON_USE_CONTENT_AS_VALUE, /** Indicates that the browser emulates the char attribute. */ Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java 2013-05-27 13:31:49 UTC (rev 8313) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/html/HtmlButton2Test.java 2013-05-27 21:33:52 UTC (rev 8314) @@ -21,6 +21,8 @@ import com.gargoylesoftware.htmlunit.BrowserRunner; import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts; +import com.gargoylesoftware.htmlunit.BrowserRunner.Browser; +import com.gargoylesoftware.htmlunit.BrowserRunner.NotYetImplemented; import com.gargoylesoftware.htmlunit.WebDriverTestCase; /** @@ -64,17 +66,15 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "-undefined", "-", "-" }, - IE = { "OK-undefined", "-", "-" }) + @Alerts(DEFAULT = { "-undefined", "-undefined", "-" }) public void defaultValues() throws Exception { - final String html = "<html><head><title>foo</title>\n" + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var input = document.getElementById('button1');\n" + " alert(input.value + '-' + input.defaultValue);\n" - + " input = document.createElement('input');\n" - + " input.type = 'button';\n" + + " input = document.createElement('button');\n" + " alert(input.value + '-' + input.defaultValue);\n" + " var builder = document.createElement('div');\n" @@ -98,7 +98,7 @@ @Test @Alerts({ "-undefined", "-", "-" }) public void defaultValuesAfterClone() throws Exception { - final String html = "<html><head><title>foo</title>\n" + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var input = document.getElementById('button1');\n" @@ -131,11 +131,9 @@ */ @Test @Alerts(DEFAULT = { "initial-undefined", "initial-undefined", "newValue-undefined", "newValue-undefined", - "newValue-newDefault", "newValue-newDefault" }, - IE = { "OK-undefined", "OK-undefined", "newValue-undefined", "newValue-undefined", "newValue-newDefault", "newValue-newDefault" }) public void resetByClick() throws Exception { - final String html = "<html><head><title>foo</title>\n" + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var button = document.getElementById('testId');\n" @@ -172,11 +170,9 @@ */ @Test @Alerts(DEFAULT = { "initial-undefined", "initial-undefined", "newValue-undefined", "newValue-undefined", - "newValue-newDefault", "newValue-newDefault" }, - IE = { "OK-undefined", "OK-undefined", "newValue-undefined", "newValue-undefined", "newValue-newDefault", "newValue-newDefault" }) public void resetByJS() throws Exception { - final String html = "<html><head><title>foo</title>\n" + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var button = document.getElementById('testId');\n" @@ -211,10 +207,9 @@ * @throws Exception if the test fails */ @Test - @Alerts(DEFAULT = { "initial-undefined", "initial-default", "newValue-default", "newValue-newDefault" }, - IE8 = { "OK-undefined", "OK-default", "newValue-default", "newValue-newDefault" }) + @Alerts(DEFAULT = { "initial-undefined", "initial-default", "newValue-default", "newValue-newDefault" }) public void defaultValue() throws Exception { - final String html = "<html><head><title>foo</title>\n" + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + "<script>\n" + " function test() {\n" + " var button = document.getElementById('testId');\n" @@ -237,4 +232,92 @@ loadPageWithAlerts2(html); } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "initial-OK", "newValue-OK", "newValue-OK" }) + public void innerHtml() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var button = document.getElementById('testId');\n" + + " alert(button.value + '-' + button.innerHTML);\n" + + + " button.value = 'newValue';\n" + + " alert(button.value + '-' + button.innerHTML);\n" + + + " button.innerHtml = 'Cancel';\n" + + " alert(button.value + '-' + button.innerHTML);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <button id='testId' value='initial'>OK</button>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @Alerts(DEFAULT = { "initial-undefined", "newValue-undefined", "newValue-Cancel" }, + IE8 = { "initial-OK", "newValue-OK", "newValue-Cancel" }) + public void innerText() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var button = document.getElementById('testId');\n" + + " alert(button.value + '-' + button.innerText);\n" + + + " button.value = 'newValue';\n" + + " alert(button.value + '-' + button.innerText);\n" + + + " button.innerText = 'Cancel';\n" + + " alert(button.value + '-' + button.innerText);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <button id='testId' value='initial'>OK</button>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } + + /** + * @throws Exception if the test fails + */ + @Test + @NotYetImplemented(Browser.IE8) + @Alerts(DEFAULT = { "initial-initial-OK", "newValue-newValue-OK", "newValue-newValue-OK" }, + IE8 = { "initial-initial-OK", "newValue--OK", "newValue--OK" }) + public void valueAttributeNode() throws Exception { + final String html = "<!DOCTYPE HTML>\n<html><head><title>foo</title>\n" + + "<script>\n" + + " function test() {\n" + + " var button = document.getElementById('testId');\n" + + " var attr = button.getAttributeNode('value');\n" + + " alert(attr.value + '-' + button.value + '-' + button.innerHTML);\n" + + + " attr.value = 'newValue';\n" + + " alert(attr.value + '-' + button.value + '-' + button.innerHTML);\n" + + + " button.innerHtml = 'Cancel';\n" + + " alert(attr.value + '-' + button.value + '-' + button.innerHTML);\n" + + " }\n" + + "</script>\n" + + "</head><body onload='test()'>\n" + + "<form>\n" + + " <button id='testId' value='initial'>OK</button>\n" + + "</form>\n" + + "</body></html>"; + + loadPageWithAlerts2(html); + } } |