зеркало из https://github.com/mozilla/pjs.git
Bug 548073 - Tabs in extensions/universalchardet/tests/CharsetDetectionTests.js. r=smontagu
This commit is contained in:
Родитель
4094557b13
Коммит
dd24338917
|
@ -1,3 +1,5 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* vim: set ts=8 et sw=4 tw=80: */
|
||||
var gExpectedCharset;
|
||||
var gOldPref;
|
||||
var gDetectorList;
|
||||
|
@ -18,41 +20,42 @@ function CharsetDetectionTests(aTestFile, aExpectedCharset, aDetectorList)
|
|||
function InitDetectorTests()
|
||||
{
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var str = Components.classes["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsString);
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var str = Components.classes["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsString);
|
||||
|
||||
try {
|
||||
gOldPref = prefService
|
||||
.getComplexValue("intl.charset.detector",
|
||||
Components.interfaces.nsIPrefLocalizedString).data;
|
||||
gOldPref = prefService
|
||||
.getComplexValue("intl.charset.detector",
|
||||
Components.interfaces.nsIPrefLocalizedString).data;
|
||||
} catch (e) {
|
||||
gOldPref = "";
|
||||
gOldPref = "";
|
||||
}
|
||||
SetDetectorPref(gDetectorList[0]);
|
||||
gTestIndex = 0;
|
||||
$("testframe").onload = DoDetectionTest;
|
||||
|
||||
if (gExpectedCharset == "default") {
|
||||
try {
|
||||
gExpectedCharset = prefService
|
||||
.getComplexValue("intl.charset.default",
|
||||
Components.interfaces.nsIPrefLocalizedString).data;
|
||||
} catch (e) {
|
||||
gExpectedCharset = "ISO-8859-8";
|
||||
}
|
||||
try {
|
||||
gExpectedCharset = prefService
|
||||
.getComplexValue("intl.charset.default",
|
||||
Components.interfaces.nsIPrefLocalizedString)
|
||||
.data;
|
||||
} catch (e) {
|
||||
gExpectedCharset = "ISO-8859-8";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function SetDetectorPref(aPrefValue)
|
||||
{
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var str = Components.classes["@mozilla.org/supports-string;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var str = Components.classes["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsString);
|
||||
str.data = aPrefValue;
|
||||
prefService.setComplexValue("intl.charset.detector",
|
||||
Components.interfaces.nsISupportsString, str);
|
||||
Components.interfaces.nsISupportsString, str);
|
||||
gCurrentDetector = aPrefValue;
|
||||
}
|
||||
|
||||
|
@ -64,10 +67,10 @@ function DoDetectionTest() {
|
|||
"decoded as " + gExpectedCharset + " by " + gDetectorList[gTestIndex]);
|
||||
|
||||
if (++gTestIndex < gDetectorList.length) {
|
||||
SetDetectorPref(gDetectorList[gTestIndex]);
|
||||
iframeDoc.location.reload();
|
||||
SetDetectorPref(gDetectorList[gTestIndex]);
|
||||
iframeDoc.location.reload();
|
||||
} else {
|
||||
CleanUpDetectionTests();
|
||||
CleanUpDetectionTests();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче