test_bug672453.html (7532B)
1 <!doctype html> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=672453 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 672453</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" href="/tests/SimpleTest/test.css"> 11 </head> 12 <body> 13 <a target="_blank" 14 href="https://bugzilla.mozilla.org/show_bug.cgi?id=672453" 15 >Mozilla Bug 672453</a> 16 <iframe></iframe> 17 <script> 18 /** Test for Bug 672453 */ 19 20 var tests = [ 21 "file_bug672453_not_declared.html", 22 "file_bug672453_xml_decl.html", 23 "file_bug672453_late_meta.html", 24 "file_bug672453_meta_restart.html", 25 "file_bug672453_meta_after_head.html", 26 "file_bug672453_meta_unsupported.html", 27 "file_bug672453_http_unsupported.html", 28 "file_bug672453_meta_utf16.html", 29 "file_bug672453_meta_non_superset.html", 30 "file_bug672453_meta_userdefined.html", 31 "file_bug672453_meta_replacement.html", 32 "file_bug672453_http_replacement.html", 33 "file_bug672453_enc_error.html", 34 "file_bug672453_enc_error_inherited.html", 35 "file_bug672453_meta_speculation_fail.html", 36 "file_bug672453_xml_speculation_fail.html", 37 ]; 38 39 // The general idea here is that encoding substitutions or failures to declare the encoding 40 // (except when inherited or, not tested here, all-ASCII) are errors and ineffeciencies 41 // or risks about things failing under further editing (i.e. meta after head but within 42 // the extended scan zone) are warnings. 43 44 var expectedErrors = [ 45 { errorMessage: "The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it.", 46 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_not_declared.html", 47 lineNumber: 0, 48 isWarning: true }, 49 { errorMessage: "The character encoding of an HTML document was declared using the XML declaration syntax. This is non-conforming, and declaring the encoding using a meta tag at the start of the head part is more efficient.", 50 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_xml_decl.html", 51 lineNumber: 1, 52 isWarning: true }, 53 { errorMessage: "A meta tag attempting to declare the character encoding declaration was found too late, and the encoding of the parent document was used instead. The meta tag needs to be moved to the start of the head part of the document.", 54 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_late_meta.html", 55 lineNumber: 1028, 56 isWarning: false }, 57 { errorMessage: "A meta tag attempting to declare the character encoding declaration was found too late, and the encoding of the parent document was used instead. The meta tag needs to be moved to the start of the head part of the document.", 58 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_restart.html", 59 lineNumber: 1028, 60 isWarning: false }, 61 { errorMessage: "The meta tag declaring the character encoding of the document should be moved to start of the head part of the document.", 62 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_after_head.html", 63 lineNumber: 7, 64 isWarning: true }, 65 { errorMessage: "An unsupported character encoding was declared for the HTML document using a meta tag. The declaration was ignored.", 66 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_unsupported.html", 67 lineNumber: 1, 68 isWarning: false }, 69 { errorMessage: "An unsupported character encoding was declared on the transfer protocol level. The declaration was ignored.", 70 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_http_unsupported.html", 71 lineNumber: 0, 72 isWarning: false }, 73 { errorMessage: "A meta tag was used to declare the character encoding as UTF-16. This was interpreted as an UTF-8 declaration instead.", 74 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_utf16.html", 75 lineNumber: 1, 76 isWarning: false }, 77 { errorMessage: "An unsupported character encoding was declared for the HTML document using a meta tag. The declaration was ignored.", 78 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_non_superset.html", 79 lineNumber: 1, 80 isWarning: false }, 81 { errorMessage: "A meta tag was used to declare the character encoding as x-user-defined. This was interpreted as a windows-1252 declaration instead for compatibility with intentionally mis-encoded legacy fonts. This site should migrate to Unicode.", 82 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_userdefined.html", 83 lineNumber: 1, 84 isWarning: false }, 85 { errorMessage: "A meta tag was used to declare an encoding that is a cross-site scripting hazard. The replacement encoding was used instead.", 86 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_replacement.html", 87 lineNumber: 0, 88 isWarning: false }, 89 { errorMessage: "An encoding that is a cross-site scripting hazard was declared on the transfer protocol level. The replacement encoding was used instead.", 90 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_http_replacement.html", 91 lineNumber: 0, 92 isWarning: false }, 93 { errorMessage: "The byte stream was erroneous according to the character encoding that was declared. The character encoding declaration may be incorrect.", 94 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_enc_error.html", 95 lineNumber: 0, 96 isWarning: false }, 97 { errorMessage: "The byte stream was erroneous according to the character encoding that was inherited from the parent document. The character encoding needs to be declared in the Content-Type HTTP header, using a meta tag, or using a byte order mark.", 98 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_enc_error_inherited.html", 99 lineNumber: 0, 100 isWarning: false }, 101 { errorMessage: "The start of the document was reparsed, because there were non-ASCII characters before the meta tag that declared the encoding. The meta should be the first child of head without non-ASCII comments before.", 102 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_speculation_fail.html", 103 lineNumber: 5, 104 isWarning: true }, 105 { errorMessage: "The start of the document was reparsed, because there were non-ASCII characters in the part of the document that was unsuccessfully searched for a meta tag before falling back to the XML declaration syntax. A meta tag at the start of the head part should be used instead of the XML declaration syntax.", 106 sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_xml_speculation_fail.html", 107 lineNumber: 10, 108 isWarning: true }, 109 ]; 110 111 SimpleTest.waitForExplicitFinish(); 112 113 window.onload = function() { 114 var iframe = document.getElementsByTagName("iframe")[0]; 115 116 function runNextTest() { 117 var url = tests.shift(); 118 if (!url) { 119 SimpleTest.endMonitorConsole(); 120 return; 121 } 122 iframe.src = url; 123 } 124 iframe.onload = runNextTest; 125 126 SimpleTest.monitorConsole(SimpleTest.finish, expectedErrors); 127 runNextTest(); 128 }; 129 </script> 130 </body> 131 </html>