diff options
Diffstat (limited to 'LayoutTests/fast/encoding/resources')
19 files changed, 219 insertions, 0 deletions
diff --git a/LayoutTests/fast/encoding/resources/%25%u0435 0 %xx%%%ulike.html b/LayoutTests/fast/encoding/resources/%25%u0435 0 %xx%%%ulike.html new file mode 100644 index 0000000..ae0d86f --- /dev/null +++ b/LayoutTests/fast/encoding/resources/%25%u0435 0 %xx%%%ulike.html @@ -0,0 +1,14 @@ +<html> +<body onload="javascript: + // WinIE and Firefox use the same URL, but in WinIE, document.URL returns unescaped text + if (document.URL.match('%25.*html') == '%2525%u0435%200%20%xx%25%%ulike.html' || + document.URL.match('%25.*html') == '%25%u0435 0 %xx%%%ulike.html') + document.getElementById('result').firstChild.nodeValue = 'SUCCESS'; + + layoutTestController.notifyDone(); +"> +<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=6452">bug 6452</a> - +KURL::appendEscapingBadChars() should never escape percent characters.</p> +<p id=result>FAILURE</p> +</body> +</html> diff --git a/LayoutTests/fast/encoding/resources/char-decoding-utils.js b/LayoutTests/fast/encoding/resources/char-decoding-utils.js new file mode 100644 index 0000000..a091ad8 --- /dev/null +++ b/LayoutTests/fast/encoding/resources/char-decoding-utils.js @@ -0,0 +1,34 @@ +function hex(number) +{ + var hexDigit = "0123456789ABCDEF"; + var hex = hexDigit.substr(number & 0xf, 1); + while (number > 15) { + number >>= 4; + hex = hexDigit.substr(number & 15, 1) + hex; + } + return hex; +} + +function decode(charsetName, characterSequence) +{ + var req = new XMLHttpRequest; + req.open('GET', 'data:text/plain,' + characterSequence, false); + req.overrideMimeType('text/plain; charset="' + charsetName + '"'); + req.send(''); + var code = hex(req.responseText.charCodeAt(0)); + return "U+" + ("0000" + code).substr(code.length, 4); +} + +function testDecode(charsetName, characterSequence, unicode) +{ + shouldBe("decode('" + charsetName + "', '" + characterSequence + "')", "'" + unicode + "'"); +} + +function batchTestDecode(inputData) +{ + for (var i in inputData.encodings) { + for (var j in inputData.encoded) + testDecode(inputData.encodings[i], inputData.encoded[j], inputData.unicode[j]); + } +} + diff --git a/LayoutTests/fast/encoding/resources/char-encoding-utils.js b/LayoutTests/fast/encoding/resources/char-encoding-utils.js new file mode 100644 index 0000000..2007c7f --- /dev/null +++ b/LayoutTests/fast/encoding/resources/char-encoding-utils.js @@ -0,0 +1,69 @@ +function encode(charset, unicode) +{ + // Returns a value already encoded, since we can't do it synchronously. + return results[charset][unicode]; +} + +function testsDone() +{ + var form = document.getElementById('form'); + var subframe = document.getElementById('subframe'); + + form.parentNode.removeChild(form); + subframe.parentNode.removeChild(subframe); + + description("This tests encoding characters in various character sets."); + + for (i = 0; i < charsets.length; ++i) { + shouldBe("encode('" + charsets[i] + "', '" + unicodes[i] + "')", "'" + expectedResults[i] + "'"); + } + + isSuccessfullyParsed(); + + if (window.layoutTestController) + layoutTestController.notifyDone(); +} + +function processResult(result) +{ + var charsetResults = results[charsets[i]]; + if (!charsetResults) { + charsetResults = new Object; + results[charsets[i]] = charsetResults; + } + charsetResults[unicodes[i]] = result; +} + +function subframeLoaded() +{ + var URL = "" + document.getElementById('subframe').contentWindow.location; + processResult(URL.substr(URL.indexOf('=') + 1)); + ++i; + runTest(); +} + +function runTest() +{ + if (i >= charsets.length) { + testsDone(); + return; + } + + var form = document.getElementById('form'); + var text = document.getElementById('text'); + var subframe = document.getElementById('subframe'); + + form.acceptCharset = charsets[i]; + form.action = "resources/dummy.html"; + subframe.onload = subframeLoaded; + text.value = String.fromCharCode(unicodes[i].replace('U+', '0x')); + + form.submit(); +} + +function testEncode(charsetName, unicode, characterSequence) +{ + charsets.push(charsetName); + unicodes.push(unicode); + expectedResults.push(characterSequence); +} diff --git a/LayoutTests/fast/encoding/resources/css-cached-bom-frame.html b/LayoutTests/fast/encoding/resources/css-cached-bom-frame.html new file mode 100644 index 0000000..0412e3f --- /dev/null +++ b/LayoutTests/fast/encoding/resources/css-cached-bom-frame.html @@ -0,0 +1,5 @@ +<link rel=stylesheet href=utf-16-little-endian.css> +<script> +window.parent.frameLoaded(); +</script> + diff --git a/LayoutTests/fast/encoding/resources/dummy.html b/LayoutTests/fast/encoding/resources/dummy.html new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/LayoutTests/fast/encoding/resources/dummy.html diff --git a/LayoutTests/fast/encoding/resources/dynamic-load-target.js b/LayoutTests/fast/encoding/resources/dynamic-load-target.js new file mode 100644 index 0000000..6a0e175 --- /dev/null +++ b/LayoutTests/fast/encoding/resources/dynamic-load-target.js @@ -0,0 +1,9 @@ + + +if ('とうきょう' == tokyo) + document.getElementById("target").innerHTML = "PASS: UTF-8 was correctly used for this script."; +else + document.getElementById("target").innerHTML = "FAIL: Incorrect encoding used. Expected '" + tokyo + "' but got '" + 'とうきょう' + "'."; + +if (window.layoutTestController) + window.layoutTestController.notifyDone(); diff --git a/LayoutTests/fast/encoding/resources/frame-default-enc-frame.html b/LayoutTests/fast/encoding/resources/frame-default-enc-frame.html new file mode 100644 index 0000000..8e928e3 --- /dev/null +++ b/LayoutTests/fast/encoding/resources/frame-default-enc-frame.html @@ -0,0 +1,17 @@ +<html> +<head> +<title>Frame</title> +</head> +<body> +<script> + chs = document.inputEncoding; + if (!chs) + chs = document.charset; + if (!chs) + chs = document.characterSet; + + parent.done(chs); +</script> + +</body> +</html> diff --git a/LayoutTests/fast/encoding/resources/invalid-xml-shift-jis.xml b/LayoutTests/fast/encoding/resources/invalid-xml-shift-jis.xml new file mode 100644 index 0000000..c33a08c --- /dev/null +++ b/LayoutTests/fast/encoding/resources/invalid-xml-shift-jis.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="shift-jis" ?> +<root> + <fail> This is an invalid byte pair in shift-jis: </fail> + <test/> <!-- shouldn't ever be parsed, as the parser should abort at the first sign of non-well-formedness --> +</root> diff --git a/LayoutTests/fast/encoding/resources/invalid-xml-utf16.xml b/LayoutTests/fast/encoding/resources/invalid-xml-utf16.xml Binary files differnew file mode 100644 index 0000000..cb7da3a --- /dev/null +++ b/LayoutTests/fast/encoding/resources/invalid-xml-utf16.xml diff --git a/LayoutTests/fast/encoding/resources/invalid-xml-utf8.xml b/LayoutTests/fast/encoding/resources/invalid-xml-utf8.xml new file mode 100644 index 0000000..b47850e --- /dev/null +++ b/LayoutTests/fast/encoding/resources/invalid-xml-utf8.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<root> + <fail> This is an invalid byte in UTF-8: </fail> + <test/> <!-- shouldn't ever be parsed, as the parser should abort at the first sign of non-well-formedness --> +</root> diff --git a/LayoutTests/fast/encoding/resources/invalid-xml-x-mac-thai.xml b/LayoutTests/fast/encoding/resources/invalid-xml-x-mac-thai.xml new file mode 100644 index 0000000..198d0ee --- /dev/null +++ b/LayoutTests/fast/encoding/resources/invalid-xml-x-mac-thai.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="x-mac-thai" ?> +<root> + <fail> This is an invalid byte in x-mac-thai: </fail> + <test/> <!-- shouldn't ever be parsed, as the parser should abort at the first sign of non-well-formedness --> +</root> diff --git a/LayoutTests/fast/encoding/resources/invalid-xml.js b/LayoutTests/fast/encoding/resources/invalid-xml.js new file mode 100644 index 0000000..e241a0c --- /dev/null +++ b/LayoutTests/fast/encoding/resources/invalid-xml.js @@ -0,0 +1,43 @@ +// test 70: XML encoding test +// q.v. XML 1.0, section 4.3.3 Character Encoding in Entities +// this only tests one of a large number of conditions that should cause fatal errors + +function runEncodingTest(event) +{ + debug("Testing: " + encodingTests[currentTest-1]); + shouldBeEqualToString("iframe.contentDocument.documentElement.tagName", "root"); + shouldBeTrue("iframe.contentDocument.documentElement.getElementsByTagName('test').length < 1"); + setTimeout(runNextTest, 0); +} + +var currentTest = 0; +var encodingTests = [ + "invalid-xml-utf8.xml", + "invalid-xml-utf16.xml", + "invalid-xml-shift-jis.xml", + "invalid-xml-x-mac-thai.xml", +]; + +function runNextTest() +{ + if (currentTest >= encodingTests.length) { + var script = document.createElement("script"); + script.src = "../js/resources/js-test-post.js"; + if (window.layoutTestController) + script.setAttribute("onload", "layoutTestController.notifyDone()"); + document.body.appendChild(script); + iframe.parentNode.removeChild(iframe); + return; + } + iframe.src = "resources/" + encodingTests[currentTest++]; +} + +if (window.layoutTestController) + layoutTestController.waitUntilDone(); + +var iframe = document.createElement("iframe"); +document.body.appendChild(iframe); +iframe.onload = runEncodingTest; +runNextTest(); + +var successfullyParsed = true; diff --git a/LayoutTests/fast/encoding/resources/preloaded-gb2312.css b/LayoutTests/fast/encoding/resources/preloaded-gb2312.css new file mode 100644 index 0000000..9d83e62 --- /dev/null +++ b/LayoutTests/fast/encoding/resources/preloaded-gb2312.css @@ -0,0 +1 @@ +#foobar:before { content: "SUSS"; } diff --git a/LayoutTests/fast/encoding/resources/preloaded-gb2312.js b/LayoutTests/fast/encoding/resources/preloaded-gb2312.js new file mode 100644 index 0000000..c324df0 --- /dev/null +++ b/LayoutTests/fast/encoding/resources/preloaded-gb2312.js @@ -0,0 +1 @@ +document.getElementById('testdiv3').innerText = 'SUSS'; diff --git a/LayoutTests/fast/encoding/resources/preloaded-utf-8.css b/LayoutTests/fast/encoding/resources/preloaded-utf-8.css new file mode 100644 index 0000000..d4d992b --- /dev/null +++ b/LayoutTests/fast/encoding/resources/preloaded-utf-8.css @@ -0,0 +1 @@ +#foobar:before { content: "SUССЕSS"; } diff --git a/LayoutTests/fast/encoding/resources/preloaded-utf-8.js b/LayoutTests/fast/encoding/resources/preloaded-utf-8.js new file mode 100644 index 0000000..6160a18 --- /dev/null +++ b/LayoutTests/fast/encoding/resources/preloaded-utf-8.js @@ -0,0 +1 @@ +document.getElementById('testdiv1').innerText = 'SUССЕSS'; diff --git a/LayoutTests/fast/encoding/resources/utf-16-little-endian.css b/LayoutTests/fast/encoding/resources/utf-16-little-endian.css Binary files differnew file mode 100644 index 0000000..2ca0c95 --- /dev/null +++ b/LayoutTests/fast/encoding/resources/utf-16-little-endian.css diff --git a/LayoutTests/fast/encoding/resources/yentestexternal.js b/LayoutTests/fast/encoding/resources/yentestexternal.js new file mode 100644 index 0000000..01262ea --- /dev/null +++ b/LayoutTests/fast/encoding/resources/yentestexternal.js @@ -0,0 +1,4 @@ +function writeYenExternal() +{ + document.write("two backslashes external: " + "\\" + "<br>"); +} diff --git a/LayoutTests/fast/encoding/resources/yentestexternal2.js b/LayoutTests/fast/encoding/resources/yentestexternal2.js new file mode 100644 index 0000000..a6db72b --- /dev/null +++ b/LayoutTests/fast/encoding/resources/yentestexternal2.js @@ -0,0 +1,5 @@ +function writeYenExternal() +{ + document.write("two backslashes external: \\ <br>"); + document.write("one backslash external: \ <br>"); +} |