Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/bom.html

Issue 1470893002: [Fetch] Always use utf-8 for decoding in text() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reflect comments. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/bom.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/bom.html b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/bom.html
new file mode 100644
index 0000000000000000000000000000000000000000..53eecb01007c10d8cd9ab370f744b1cc715f487e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/bom.html
@@ -0,0 +1,36 @@
+<!doctype html>
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+window.jsTestIsAsync = true;
+description('BOM can override the encoding when decoding the response in ' +
+ 'responseText.');
+
+xhr = new XMLHttpRequest;
+xhr.open('GET', 'resources/bom-utf-8.php');
+xhr.onreadystatechange = function() {
+ if (xhr.readyState != xhr.DONE) { return; }
+ // A string with utf-8 BOM is decoded as utf-8.
+ shouldBeEqualToString('xhr.responseText',
+ '\u4e09\u6751\u304b\u306a\u5b50');
+ xhr2 = new XMLHttpRequest;
+ xhr2.open('GET', 'resources/bom-utf-16be.php');
+ xhr2.onreadystatechange = function() {
+ if (xhr2.readyState != xhr2.DONE) { return; }
+ // A string with utf-16be BOM is decoded as utf-16be.
+ shouldBeEqualToString('xhr2.responseText',
+ '\u4e09\u6751\u304b\u306a\u5b50');
+ xhr3 = new XMLHttpRequest;
+ xhr3.open('GET', 'resources/bom-utf-16le.php');
+ xhr3.onreadystatechange = function() {
+ if (xhr3.readyState != xhr3.DONE) { return; }
+ // A string with utf-16le BOM is decoded as utf-16le.
+ shouldBeEqualToString('xhr3.responseText',
+ '\u4e09\u6751\u304b\u306a\u5b50');
+ finishJSTest();
+ };
+ xhr3.send();
+ };
+ xhr2.send();
+};
+xhr.send();
+</script>

Powered by Google App Engine
This is Rietveld 408576698