test_utf16_files.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset=utf-8>
  5. <title>Test loading various utf-16 files (little or big endian, with or without BOM)</title>
  6. <script type="text/javascript" src="/resources/testharness.js"></script>
  7. <script type="text/javascript" src="/resources/testharnessreport.js"></script>
  8. <link rel="stylesheet" href="file_utf16_be_bom.css">
  9. <link rel="stylesheet" href="file_utf16_le_bom.css">
  10. <script type="text/javascript" src="file_utf16_be_bom.js"></script>
  11. <script type="text/javascript" src="file_utf16_le_bom.js"></script>
  12. </head>
  13. <body>
  14. <div id="log"></div>
  15. <iframe name="ifr1" src="file_utf16_be_bom.xhtml"></iframe>
  16. <iframe name="ifr2" src="file_utf16_le_bom.xhtml"></iframe>
  17. <iframe name="ifr3" src="file_utf16_le_nobom.xhtml"></iframe>
  18. <script>
  19. runTest();
  20. function runTest() {
  21. test(function() {
  22. assert_equals(document.styleSheets[0].cssRules[0].selectorText, ".css1", ".css1 should exist.");
  23. assert_equals(document.styleSheets[1].cssRules[0].selectorText, ".css2", ".css2 should exist.");
  24. }, "Test loading utf-16 css files");
  25. test(function() {
  26. assert_equals(js1, "Unicåde", "js1 should be defined.");
  27. assert_equals(js2, "Unicåde", "js2 should be defined.");
  28. }, "Test loading utf-16 javascript files");
  29. var tests = [
  30. {ifr: ifr1, fails: false, name: "Test loading utf-16, big endian, with BOM"},
  31. {ifr: ifr2, fails: false, name: "Test loading utf-16, little endian, with BOM"},
  32. {ifr: ifr3, fails: true, name: "Test loading utf-16le xml fails"},
  33. ];
  34. tests.forEach(function(test) {
  35. var t = async_test(test.name);
  36. var fails = test.fails;
  37. var ifr = test.ifr;
  38. ifr.onload = ifr.onerror = function() {
  39. t.step(fails ? function() {
  40. assert_equals(ifr.document.body, null, ifr.name + " should NOT load.");
  41. } : function() {
  42. assert_true(ifr.document.body instanceof ifr.HTMLBodyElement, ifr.name + " should load.");
  43. });
  44. t.done();
  45. };
  46. });
  47. }
  48. </script>
  49. </body>
  50. </html>