Bug 1888590 - Mark some subtests on trusted-types-event-handlers.html as failing...
[gecko.git] / extensions / universalchardet / tests / CharsetDetectionTests.js
blob8d6ebad964463c83d40705944564a6f4897acbc2
1 /* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
2 /* vim: set ts=8 et sw=4 tw=80: */
4 var gExpectedCharset;
5 var gLocalDir;
7 function CharsetDetectionTests(aTestFile, aExpectedCharset) {
8   gExpectedCharset = aExpectedCharset;
10   InitDetectorTests();
12   var fileURI = gLocalDir + aTestFile;
13   $("testframe").src = fileURI;
15   SimpleTest.waitForExplicitFinish();
18 function InitDetectorTests() {
19   var loader = Services.scriptloader;
20   var ioService = Services.io;
21   loader.loadSubScript("chrome://mochikit/content/chrome-harness.js");
23   $("testframe").onload = DoDetectionTest;
25   if (gExpectedCharset == "default") {
26     // No point trying to be generic here, because we have plenty of other
27     // unit tests that fail if run using a non-windows-1252 locale.
28     gExpectedCharset = "windows-1252";
29   }
31   // Get the local directory. This needs to be a file: URI because chrome:
32   // URIs are always UTF-8 (bug 617339) and we are testing decoding from other
33   // charsets.
34   var jar = getJar(getRootDirectory(window.location.href));
35   var dir = jar
36     ? extractJarToTmp(jar)
37     : getChromeDir(getResolvedURI(window.location.href));
38   gLocalDir = ioService.newFileURI(dir).spec;
41 function DoDetectionTest() {
42   var iframeDoc = $("testframe").contentDocument;
43   var charset = iframeDoc.characterSet;
45   is(charset, gExpectedCharset, "decoded as " + gExpectedCharset);
47   SimpleTest.finish();