From 2f3f541b17c35231a10b833f0415bb302a4ecca9 Mon Sep 17 00:00:00 2001 From: Michael Layzell Date: Wed, 21 Oct 2015 13:31:58 +0100 Subject: [PATCH] Update Web Platform tests to check for correct behavior, Upstreamed from https://bugzilla.mozilla.org/show_bug.cgi?id=918771 --- XMLHttpRequest/resources/empty-div-utf8-html.py | 5 +++++ XMLHttpRequest/resources/img-utf8-html.py | 5 +++++ XMLHttpRequest/send-content-type-string.htm | 4 ++-- XMLHttpRequest/send-entity-body-document.htm | 14 ++++++++++---- 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 XMLHttpRequest/resources/empty-div-utf8-html.py create mode 100644 XMLHttpRequest/resources/img-utf8-html.py diff --git a/XMLHttpRequest/resources/empty-div-utf8-html.py b/XMLHttpRequest/resources/empty-div-utf8-html.py new file mode 100644 index 00000000000000..26d54b9d1496af --- /dev/null +++ b/XMLHttpRequest/resources/empty-div-utf8-html.py @@ -0,0 +1,5 @@ +def main(request, response): + headers = [("Content-type", "text/html;charset=utf-8")] + content = "
" + + return headers, content diff --git a/XMLHttpRequest/resources/img-utf8-html.py b/XMLHttpRequest/resources/img-utf8-html.py new file mode 100644 index 00000000000000..085867f9510e48 --- /dev/null +++ b/XMLHttpRequest/resources/img-utf8-html.py @@ -0,0 +1,5 @@ +def main(request, response): + headers = [("Content-type", "text/html;charset=utf-8")] + content = "foo" + + return headers, content diff --git a/XMLHttpRequest/send-content-type-string.htm b/XMLHttpRequest/send-content-type-string.htm index 61cb4c0ff936eb..0391ed8b3d19eb 100644 --- a/XMLHttpRequest/send-content-type-string.htm +++ b/XMLHttpRequest/send-content-type-string.htm @@ -20,7 +20,7 @@ request("TEST", "text/plain;charset=UTF-8") function init(fr) { request(fr.contentDocument, fr.getAttribute("data-t")) } - - + + diff --git a/XMLHttpRequest/send-entity-body-document.htm b/XMLHttpRequest/send-entity-body-document.htm index 67a0ff6db49183..5f1cb68dce819d 100644 --- a/XMLHttpRequest/send-entity-body-document.htm +++ b/XMLHttpRequest/send-entity-body-document.htm @@ -16,11 +16,13 @@ { contentType: 'text/html;charset=UTF-8', responseText : '\uFFFD<\/body>' }, /*invalid character code in document turns into FFFD*/ { contentType: 'text/html;charset=UTF-8', responseText : '\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: 'foo' }, + { contentType: 'text/html;charset=UTF-8', responseText: '
' } ] - 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) @@ -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) }