[HtmlUnit] SVN: [14137] trunk/htmlunit/src

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[HtmlUnit] SVN: [14137] trunk/htmlunit/src

rbri
Revision: 14137
          http://sourceforge.net/p/htmlunit/code/14137
Author:   rbri
Date:     2017-04-17 15:45:08 +0000 (Mon, 17 Apr 2017)
Log Message:
-----------
next test is ready for real browsers (incl. IE11)

Modified Paths:
--------------
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
    trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLSerializer.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEventTest.java
    trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLSerializerTest.java

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-04-17 14:53:55 UTC (rev 14136)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/BrowserVersionFeatures.java 2017-04-17 15:45:08 UTC (rev 14137)
@@ -1379,10 +1379,6 @@
     @BrowserFeature(@WebBrowser(IE))
     JS_XML_SERIALIZER_HTML_DOCUMENT_FRAGMENT_ALWAYS_EMPTY,
 
-    /** Indicates that new XMLSerializer().serializeToString(..) respects the XHTML definition for non empty tags. */
-    @BrowserFeature({@WebBrowser(FF), @WebBrowser(CHROME)})
-    JS_XML_SERIALIZER_NON_EMPTY_TAGS,
-
     /** Indicates that <code>XMLSerializer.serializeToString(..)</code> serializes a single CDataSection as escaped
      * text instead of <code>&lt;![CDATA[xxx]]&gt;</code>. */
     @BrowserFeature(@WebBrowser(IE))

Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLSerializer.java
===================================================================
--- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLSerializer.java 2017-04-17 14:53:55 UTC (rev 14136)
+++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLSerializer.java 2017-04-17 15:45:08 UTC (rev 14137)
@@ -16,7 +16,6 @@
 
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_XML_SERIALIZER_BLANK_BEFORE_SELF_CLOSING;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_XML_SERIALIZER_HTML_DOCUMENT_FRAGMENT_ALWAYS_EMPTY;
-import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_XML_SERIALIZER_NON_EMPTY_TAGS;
 import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_XML_SERIALIZER_ROOT_CDATA_AS_ESCAPED_TEXT;
 
 import java.util.Arrays;
@@ -207,8 +206,7 @@
         }
         if (!startTagClosed) {
             final String tagName = nodeName.toLowerCase(Locale.ROOT);
-            final boolean nonEmptyTagsSupported = getBrowserVersion().hasFeature(JS_XML_SERIALIZER_NON_EMPTY_TAGS);
-            if (nonEmptyTagsSupported && NON_EMPTY_TAGS.contains(tagName)) {
+            if (NON_EMPTY_TAGS.contains(tagName)) {
                 builder.append('>');
                 builder.append("</").append(nodeName).append('>');
             }

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEventTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEventTest.java 2017-04-17 14:53:55 UTC (rev 14136)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/event/BeforeUnloadEventTest.java 2017-04-17 15:45:08 UTC (rev 14137)
@@ -16,6 +16,7 @@
 
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.openqa.selenium.WebDriver;
 
 import com.gargoylesoftware.htmlunit.BrowserRunner;
 import com.gargoylesoftware.htmlunit.BrowserRunner.Alerts;
@@ -32,13 +33,13 @@
 
     private static final String DUMP_EVENT_FUNCTION = "  function dump(event) {\n"
         + "    if (event) {\n"
-        + "      alert(event);\n"
-        + "      alert(event.type);\n"
-        + "      alert(event.bubbles);\n"
-        + "      alert(event.cancelable);\n"
-        + "      alert(event.returnValue);\n"
+        + "      document.title += ' -' + event;\n"
+        + "      document.title += ' -' + event.type;\n"
+        + "      document.title += ' -' + event.bubbles;\n"
+        + "      document.title += ' -' + event.cancelable;\n"
+        + "      document.title += ' -' + event.returnValue;\n"
         + "    } else {\n"
-        + "      alert('no event');\n"
+        + "      document.title += ' ' + 'no event';\n"
         + "    }\n"
         + "  }\n";
 
@@ -65,24 +66,25 @@
      * @throws Exception if the test fails
      */
     @Test
-    @Alerts(DEFAULT = {"[object BeforeUnloadEvent]", "", "true", "true", ""},
-            FF = {"[object BeforeUnloadEvent]", "", "false", "false", ""},
-            CHROME = {"[object BeforeUnloadEvent]", "beforeunload", "false", "true", ""},
+    @Alerts(DEFAULT = {"-[object BeforeUnloadEvent]", "-", "-true", "-true", "-"},
+            FF = {"-[object BeforeUnloadEvent]", "-", "-false", "-false", "-"},
+            CHROME = {"-[object BeforeUnloadEvent]", "-beforeunload", "-false", "-true", "-"},
             IE = "exception")
     public void create_createEvent() throws Exception {
         final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
-            + "<html><head><title>foo</title><script>\n"
+            + "<html><head><script>\n"
             + "  function test() {\n"
             + "    try {\n"
             + "      var event = document.createEvent('BeforeUnloadEvent');\n"
             + "      dump(event);\n"
-            + "    } catch (e) { alert('exception') }\n"
+            + "    } catch (e) { document.title += 'exception' }\n"
             + "  }\n"
             + DUMP_EVENT_FUNCTION
             + "</script></head><body onload='test()'>\n"
             + "</body></html>";
 
-        loadPageWithAlerts2(html);
+        final WebDriver driver = loadPage2(html);
+        assertEquals(String.join(" ", getExpectedAlerts()),  driver.getTitle());
     }
 
     /**
@@ -89,23 +91,24 @@
      * @throws Exception if the test fails
      */
     @Test
-    @Alerts(DEFAULT = {"[object BeforeUnloadEvent]", "beforeunload", "true", "false", ""},
+    @Alerts(DEFAULT = {"-[object BeforeUnloadEvent]", "-beforeunload", "-true", "-false", "-"},
             IE = "exception")
     public void initEvent() throws Exception {
         final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
-            + "<html><head><title>foo</title><script>\n"
+            + "<html><head><script>\n"
             + "  function test() {\n"
             + "    try {\n"
             + "      var event = document.createEvent('BeforeUnloadEvent');\n"
             + "      event.initEvent('beforeunload', true, false);\n"
             + "      dump(event);\n"
-            + "    } catch (e) { alert('exception') }\n"
+            + "    } catch (e) { document.title += 'exception' }\n"
             + "  }\n"
             + DUMP_EVENT_FUNCTION
             + "</script></head><body onload='test()'>\n"
             + "</body></html>";
 
-        loadPageWithAlerts2(html);
+        final WebDriver driver = loadPage2(html);
+        assertEquals(String.join(" ", getExpectedAlerts()),  driver.getTitle());
     }
 
     /**
@@ -112,17 +115,17 @@
      * @throws Exception if the test fails
      */
     @Test
-    @Alerts(DEFAULT = {"[object BeforeUnloadEvent]", "beforeunload", "true", "false", ""},
+    @Alerts(DEFAULT = {"-[object BeforeUnloadEvent]", "-beforeunload", "-true", "-false", "-"},
             IE = "exception")
     public void dispatchEvent() throws Exception {
         final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
-            + "<html><head><title>foo</title><script>\n"
+            + "<html><head><script>\n"
             + "  function test() {\n"
             + "    try {\n"
             + "      var event = document.createEvent('BeforeUnloadEvent');\n"
             + "      event.initEvent('beforeunload', true, false);\n"
             + "      dispatchEvent(event);\n"
-            + "    } catch (e) { alert('exception') }\n"
+            + "    } catch (e) { document.title += 'exception' }\n"
             + "  }\n"
             + DUMP_EVENT_FUNCTION
             + "  window.onbeforeunload  = dump;\n"
@@ -129,7 +132,8 @@
             + "</script></head><body onload='test()'>\n"
             + "</body></html>";
 
-        loadPageWithAlerts2(html);
+        final WebDriver driver = loadPage2(html);
+        assertEquals(String.join(" ", getExpectedAlerts()),  driver.getTitle());
     }
 
     /**
@@ -136,11 +140,11 @@
      * @throws Exception if the test fails
      */
     @Test
-    @Alerts(DEFAULT = {"[object Event]", "beforeunload", "true", "false", "undefined"},
-            CHROME = {"[object Event]", "beforeunload", "true", "false", "true"})
+    @Alerts(DEFAULT = {"-[object Event]", "-beforeunload", "-true", "-false", "-undefined"},
+            CHROME = {"-[object Event]", "-beforeunload", "-true", "-false", "-true"})
     public void dispatchEvent_event() throws Exception {
         final String html = HtmlPageTest.STANDARDS_MODE_PREFIX_
-            + "<html><head><title>foo</title><script>\n"
+            + "<html><head><script>\n"
             + "  function test() {\n"
             + "    try {\n"
             + "      var event = document.createEvent('Event');\n"
@@ -153,7 +157,8 @@
             + "</script></head><body onload='test()'>\n"
             + "</body></html>";
 
-        loadPageWithAlerts2(html);
+        final WebDriver driver = loadPage2(html);
+        assertEquals(String.join(" ", getExpectedAlerts()),  driver.getTitle());
     }
 
     /**

Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLSerializerTest.java
===================================================================
--- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLSerializerTest.java 2017-04-17 14:53:55 UTC (rev 14136)
+++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/xml/XMLSerializerTest.java 2017-04-17 15:45:08 UTC (rev 14137)
@@ -14,6 +14,8 @@
  */
 package com.gargoylesoftware.htmlunit.javascript.host.xml;
 
+import static com.gargoylesoftware.htmlunit.BrowserRunner.Browser.IE;
+
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.openqa.selenium.By;
@@ -281,8 +283,7 @@
      * @throws Exception if the test fails
      */
     @Test
-    @Alerts(DEFAULT = "<textarea xmlns=\"http://www.w3.org/1999/xhtml\"></textarea>",
-            IE = "<textarea xmlns=\"http://www.w3.org/1999/xhtml\" />")
+    @Alerts("<textarea xmlns=\"http://www.w3.org/1999/xhtml\"></textarea>")
     public void mixedCase() throws Exception {
         final String html = "<html><head><title>foo</title><script>\n"
             + "  function test() {\n"
@@ -298,7 +299,7 @@
      * @throws Exception if the test fails
      */
     @Test
-    @Alerts({"<area xmlns=\"http://www.w3.org/1999/xhtml\" />",
+    @Alerts(DEFAULT = {"<area xmlns=\"http://www.w3.org/1999/xhtml\" />",
                     "<base xmlns=\"http://www.w3.org/1999/xhtml\" />",
                     "<basefont xmlns=\"http://www.w3.org/1999/xhtml\" />",
                     "<br xmlns=\"http://www.w3.org/1999/xhtml\" />",
@@ -305,7 +306,16 @@
                     "<hr xmlns=\"http://www.w3.org/1999/xhtml\" />",
                     "<input xmlns=\"http://www.w3.org/1999/xhtml\" />",
                     "<link xmlns=\"http://www.w3.org/1999/xhtml\" />",
+                    "<meta xmlns=\"http://www.w3.org/1999/xhtml\" />"},
+            IE = {"<area xmlns=\"http://www.w3.org/1999/xhtml\" />",
+                    "<base xmlns=\"http://www.w3.org/1999/xhtml\" />",
+                    "<basefont xmlns=\"http://www.w3.org/1999/xhtml\"></basefont>",
+                    "<br xmlns=\"http://www.w3.org/1999/xhtml\" />",
+                    "<hr xmlns=\"http://www.w3.org/1999/xhtml\" />",
+                    "<input xmlns=\"http://www.w3.org/1999/xhtml\" />",
+                    "<link xmlns=\"http://www.w3.org/1999/xhtml\" />",
                     "<meta xmlns=\"http://www.w3.org/1999/xhtml\" />"})
+    @NotYetImplemented(IE)
     public void noClosingTag() throws Exception {
         final String html = "<html><head><title>foo</title><script>\n"
             + "  function test() {\n"
@@ -359,16 +369,11 @@
      * @throws Exception if the test fails
      */
     @Test
-    @Alerts(DEFAULT = {"<div xmlns=\"http://www.w3.org/1999/xhtml\"></div>",
+    @Alerts({"<div xmlns=\"http://www.w3.org/1999/xhtml\"></div>",
                     "<h1 xmlns=\"http://www.w3.org/1999/xhtml\"></h1>",
                     "<p xmlns=\"http://www.w3.org/1999/xhtml\"></p>",
                     "<li xmlns=\"http://www.w3.org/1999/xhtml\"></li>",
-                    "<textarea xmlns=\"http://www.w3.org/1999/xhtml\"></textarea>"},
-            IE = {"<div xmlns=\"http://www.w3.org/1999/xhtml\" />",
-                    "<h1 xmlns=\"http://www.w3.org/1999/xhtml\" />",
-                    "<p xmlns=\"http://www.w3.org/1999/xhtml\" />",
-                    "<li xmlns=\"http://www.w3.org/1999/xhtml\" />",
-                    "<textarea xmlns=\"http://www.w3.org/1999/xhtml\" />"})
+                    "<textarea xmlns=\"http://www.w3.org/1999/xhtml\"></textarea>"})
     public void otherTags() throws Exception {
         final String html = "<html><head><title>foo</title><script>\n"
             + "  function test() {\n"


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
HtmlUnit-develop mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/htmlunit-develop
Loading...