Bug 918771 - Part 3: Update Web Platform tests to check for correct behavior, r=bz
authorMichael Layzell <michael@thelayzells.com>
Wed, 23 Sep 2015 13:36:55 -0400
changeset 303819 a2c2e50e4785aeb549110b941e7c66c60ffc50ad
parent 303818 481163317b0a44232062f2cd23b703e90dd9a6a6
child 303820 76b54ac73786eb8f095531680db0651078b6ce98
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs918771
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 918771 - Part 3: Update Web Platform tests to check for correct behavior, r=bz
testing/web-platform/meta/XMLHttpRequest/send-content-type-string.htm.ini
testing/web-platform/meta/XMLHttpRequest/send-entity-body-document.htm.ini
testing/web-platform/tests/XMLHttpRequest/resources/empty-div-utf8-html.py
testing/web-platform/tests/XMLHttpRequest/resources/img-utf8-html.py
testing/web-platform/tests/XMLHttpRequest/send-content-type-string.htm
testing/web-platform/tests/XMLHttpRequest/send-entity-body-document.htm
deleted file mode 100644
--- a/testing/web-platform/meta/XMLHttpRequest/send-content-type-string.htm.ini
+++ /dev/null
@@ -1,8 +0,0 @@
-[send-content-type-string.htm]
-  type: testharness
-  [XMLHttpRequest: send() - Content-Type 1]
-    expected: FAIL
-
-  [XMLHttpRequest: send() - Content-Type 2]
-    expected: FAIL
-
deleted file mode 100644
--- a/testing/web-platform/meta/XMLHttpRequest/send-entity-body-document.htm.ini
+++ /dev/null
@@ -1,17 +0,0 @@
-[send-entity-body-document.htm]
-  type: testharness
-  [XMLHttpRequest: send() - Document]
-    expected: FAIL
-
-  [XMLHttpRequest: send() - Document 1]
-    expected: FAIL
-
-  [XMLHttpRequest: send() - Document 2]
-    expected: FAIL
-
-  [XMLHttpRequest: send() - Document 3]
-    expected: FAIL
-
-  [XMLHttpRequest: send() - Document 4]
-    expected: FAIL
-
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/XMLHttpRequest/resources/empty-div-utf8-html.py
@@ -0,0 +1,5 @@
+def main(request, response):
+    headers = [("Content-type", "text/html;charset=utf-8")]
+    content = "<!DOCTYPE html><div></div>"
+
+    return headers, content
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/XMLHttpRequest/resources/img-utf8-html.py
@@ -0,0 +1,5 @@
+def main(request, response):
+    headers = [("Content-type", "text/html;charset=utf-8")]
+    content = "<img>foo"
+
+    return headers, content
--- a/testing/web-platform/tests/XMLHttpRequest/send-content-type-string.htm
+++ b/testing/web-platform/tests/XMLHttpRequest/send-content-type-string.htm
@@ -15,12 +15,12 @@
           client.open("POST", "resources/content.py", false)
           client.send(data)
           assert_equals(client.getResponseHeader("x-request-content-type"), expected_type)
         })
       }
       request("TEST", "text/plain;charset=UTF-8")
       function init(fr) { request(fr.contentDocument, fr.getAttribute("data-t")) }
     </script>
-    <iframe src='data:text/xml;charset=windows-1252,<%FF/>' onload="init(this)" data-t="application/xml;charset=windows-1252"></iframe>
-    <iframe src='data:text/html;charset=windows-1252,%FF' onload="init(this)" data-t="text/html;charset=windows-1252"></iframe>
+    <iframe src='data:text/xml;charset=windows-1252,<%FF/>' onload="init(this)" data-t="application/xml;charset=UTF-8"></iframe>
+    <iframe src='data:text/html;charset=windows-1252,%FF' onload="init(this)" data-t="text/html;charset=UTF-8"></iframe>
   </body>
 </html>
--- a/testing/web-platform/tests/XMLHttpRequest/send-entity-body-document.htm
+++ b/testing/web-platform/tests/XMLHttpRequest/send-entity-body-document.htm
@@ -11,45 +11,51 @@
   <body>
     <div id="log"></div>
     <script>
      var expectations = [
       { contentType: 'application/xml;charset=UTF-8', responseText : '<\u00FF\/>' },
       { contentType: 'text/html;charset=UTF-8', responseText : '<body>\uFFFD<\/body>' }, /*invalid character code in document turns into FFFD*/
       { contentType: 'text/html;charset=UTF-8', responseText : '<body>\u30C6\u30b9\u30c8<\/body>' } /* correctly serialized Shift-JIS */,
       { contentType: 'text/html;charset=UTF-8', responseText: 'top' }, /* There's some markup included, but it's not really relevant for this test suite, so we do an indexOf() test */
-      { contentType: 'text/html;charset=UTF-8' }
+      { contentType: 'text/html;charset=UTF-8' },
+      { contentType: 'text/html;charset=UTF-8', responseText: '<img>foo' },
+      { contentType: 'text/html;charset=UTF-8', responseText: '<!DOCTYPE html><html><head></head><body><div></div></body></html>' }
      ]
 
 
-      function request(input, isHTML, title) {
+      function request(input, number, title) {
         test(function() {
           var client = new XMLHttpRequest()
           client.open("POST", "resources/content.py?response_charset_label=UTF-8", false)
           client.send(input)
           var exp = expectations[number]
           assert_equals(client.getResponseHeader('X-Request-Content-Type'), exp.contentType, 'document should be serialized and sent as '+exp.contentType+' (TEST#'+number+')')
           // The indexOf() assertation will overlook some stuff, i.e. XML prologues that shouldn't be there (looking at you, Presto).
           // However, arguably these things have little to do with the XHR functionality we're testing.
           if(exp.responseText){ // This test does not want to assert anything about what markup a standalone IMG should be wrapped in. Hence the GIF test lacks a responseText expectation.
-            assert_true(client.responseText.indexOf(exp.responseText) != -1);
+            assert_true(client.responseText.indexOf(exp.responseText) != -1,
+                        JSON.stringify(exp.responseText) + " not in " +
+                        JSON.stringify(client.responseText));
           }
           assert_equals(client.responseXML, null)
         }, title)
       }
-      function init(fr, number, title) { request(fr.contentDocument, number) }
+      function init(fr, number, title) { request(fr.contentDocument, number, title) }
     </script>
     <!--
         This test also tests how documents in various encodings are serialized.
         The below IFRAMEs contain:
           * one XML document parsed from a windows-1252 source - content is <ΓΏ/>
           * one HTML-document parsed from an invalid UTF-8 source, will contain a basic HTML DOM
              with a U+FFFD replacement character for the invalid char
           * one HTML document parsed from a valid Shift-JIS source
      -->
     <iframe src='resources/win-1252-xml.py' onload="init(this, 0, 'XML document, windows-1252')"></iframe>
     <iframe src='resources/invalid-utf8-html.py' onload="init(this, 1, 'HTML document, invalid UTF-8')"></iframe>
     <iframe src='resources/shift-jis-html.py' onload="init(this, 2, 'HTML document, shift-jis')"></iframe>
     <iframe src='folder.txt' onload="init(this, 3, 'plain text file')"></iframe>
     <iframe src='resources/image.gif' onload="init(this, 4, 'image file')"></iframe>
+    <iframe src='resources/img-utf8-html.py' onload="init(this, 5, 'img tag')"></iframe>
+    <iframe src='resources/empty-div-utf8-html.py' onload="init(this, 6, 'empty div')"></iframe>
 
   </body>
 </html>