summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/XMLHttpRequest/send-entity-body-document.htm
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/XMLHttpRequest/send-entity-body-document.htm
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/XMLHttpRequest/send-entity-body-document.htm')
-rw-r--r--testing/web-platform/tests/XMLHttpRequest/send-entity-body-document.htm61
1 files changed, 61 insertions, 0 deletions
diff --git a/testing/web-platform/tests/XMLHttpRequest/send-entity-body-document.htm b/testing/web-platform/tests/XMLHttpRequest/send-entity-body-document.htm
new file mode 100644
index 000000000..5f1cb68dc
--- /dev/null
+++ b/testing/web-platform/tests/XMLHttpRequest/send-entity-body-document.htm
@@ -0,0 +1,61 @@
+<!doctype html>
+<html>
+ <head>
+ <title>XMLHttpRequest: send() - Document</title>
+ <meta charset="utf-8">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <link rel="help" href="https://xhr.spec.whatwg.org/#the-send()-method" data-tested-assertations="/following::ol/li[4]" />
+ <link rel="help" href="https://xhr.spec.whatwg.org/#dom-XMLHttpRequest-send-document" data-tested-assertations="/following::dd" />
+ </head>
+ <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', responseText: '<img>foo' },
+ { contentType: 'text/html;charset=UTF-8', responseText: '<!DOCTYPE html><html><head></head><body><div></div></body></html>' }
+ ]
+
+
+ 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,
+ 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, 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>