1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/workers/test/test_loadEncoding.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,50 @@ 1.4 +<!-- 1.5 + Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ 1.7 +--> 1.8 +<!DOCTYPE HTML> 1.9 +<html> 1.10 +<head> 1.11 + <title>Bug 484305 - Load workers as UTF-8</title> 1.12 + <meta http-equiv="content-type" content="text/html; charset=KOI8-R"> 1.13 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.14 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.15 +</head> 1.16 +<body> 1.17 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=484305">Bug 484305 - Load workers as UTF-8</a> 1.18 +<p id="display"></p> 1.19 +<div id="content" style="display: none"> 1.20 + 1.21 +</div> 1.22 +<pre id="test"> 1.23 +<script class="testbody" type="text/javascript"> 1.24 + 1.25 +SimpleTest.waitForExplicitFinish(); 1.26 + 1.27 +var canonical = String.fromCharCode(0x41F, 0x440, 0x438, 0x432, 0x435, 0x442); 1.28 +ok(document.inputEncoding === "KOI8-R", "Document encoding is KOI8-R"); 1.29 + 1.30 +// Worker sends two strings, one with `canonical` encoded in KOI8-R and one as UTF-8. 1.31 +// Since Worker scripts should always be decoded using UTF-8, even if the owning document's charset is different, the UTF-8 decode should match, while KOI8-R should fail. 1.32 +var counter = 0; 1.33 +var worker = new Worker("loadEncoding_worker.js"); 1.34 +worker.onmessage = function(e) { 1.35 + if (e.data.encoding === "KOI8-R") { 1.36 + ok(e.data.text !== canonical, "KOI8-R decoded text should not match"); 1.37 + } else if (e.data.encoding === "UTF-8") { 1.38 + ok(e.data.text === canonical, "UTF-8 decoded text should match"); 1.39 + } 1.40 + counter++; 1.41 + if (counter === 2) 1.42 + SimpleTest.finish(); 1.43 +} 1.44 + 1.45 +worker.onerror = function(e) { 1.46 + ok(false, "Worker error"); 1.47 + SimpleTest.finish(); 1.48 +} 1.49 +</script> 1.50 + 1.51 +</pre> 1.52 +</body> 1.53 +</html>