Skip to content

Commit

Permalink
Update Web Platform tests to check for correct behavior,
Browse files Browse the repository at this point in the history
  • Loading branch information
mystor authored and jgraham committed Oct 21, 2015
1 parent 010e723 commit 2f3f541
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
5 changes: 5 additions & 0 deletions 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
5 changes: 5 additions & 0 deletions 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
4 changes: 2 additions & 2 deletions XMLHttpRequest/send-content-type-string.htm
Expand Up @@ -20,7 +20,7 @@
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>
14 changes: 10 additions & 4 deletions XMLHttpRequest/send-entity-body-document.htm
Expand Up @@ -16,11 +16,13 @@
{ 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)
Expand All @@ -30,12 +32,14 @@
// 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.
Expand All @@ -50,6 +54,8 @@
<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>

0 comments on commit 2f3f541

Please sign in to comment.