mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 982816 - Remove extra calls to nextTest in test_hawkrequest.js r=ckarlof
This commit is contained in:
parent
2a1f3ed8fe
commit
1f442e1878
@ -43,7 +43,7 @@ add_test(function test_intl_accept_language() {
|
||||
"fa-CG;ik", // Congolese dialect of Farsei, defaulting to Inupiaq
|
||||
];
|
||||
|
||||
function setLanguage(lang) {
|
||||
function setLanguagePref(lang) {
|
||||
let acceptLanguage = Cc["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Ci.nsISupportsString);
|
||||
acceptLanguage.data = lang;
|
||||
@ -53,20 +53,27 @@ add_test(function test_intl_accept_language() {
|
||||
|
||||
let hawk = new HAWKAuthenticatedRESTRequest("https://example.com");
|
||||
|
||||
Services.prefs.addObserver("intl.accept_languages", nextTest, false);
|
||||
setLanguage(languages[testCount]);
|
||||
Services.prefs.addObserver("intl.accept_languages", checkLanguagePref, false);
|
||||
setLanguagePref(languages[testCount]);
|
||||
|
||||
function nextTest() {
|
||||
function checkLanguagePref() {
|
||||
var _done = false;
|
||||
CommonUtils.nextTick(function() {
|
||||
if (testCount < 2) {
|
||||
// Ensure we're only called for the number of entries in languages[].
|
||||
do_check_true(testCount < languages.length);
|
||||
|
||||
do_check_eq(hawk._intl.accept_languages, languages[testCount]);
|
||||
|
||||
testCount += 1;
|
||||
setLanguage(languages[testCount]);
|
||||
nextTest();
|
||||
testCount++;
|
||||
if (testCount < languages.length) {
|
||||
// Set next language in prefs; Pref service will call checkNextLanguage.
|
||||
setLanguagePref(languages[testCount]);
|
||||
return;
|
||||
}
|
||||
Services.prefs.removeObserver("intl.accept_languages", nextTest);
|
||||
|
||||
// We've checked all the entries in languages[]. Cleanup and move on.
|
||||
do_print("Checked " + testCount + " languages. Removing checkLanguagePref as pref observer.");
|
||||
Services.prefs.removeObserver("intl.accept_languages", checkLanguagePref);
|
||||
run_next_test();
|
||||
return;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user