mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1252444 - Rewrite some dom mochitests to use pushPrefEnv instead of setCharPref. r=jmaher
This commit is contained in:
parent
b47306aef0
commit
153c131077
@ -19,25 +19,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=466409
|
||||
/** Test for Bug 466409 **/
|
||||
|
||||
|
||||
function setUniversalDetector(detector)
|
||||
{
|
||||
var olddetector = SpecialPowers.getCharPref("intl.charset.detector");
|
||||
SpecialPowers.setCharPref("intl.charset.detector", detector);
|
||||
return olddetector;
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
var testframe = document.getElementById('testframe');
|
||||
|
||||
testframe.onload = function ()
|
||||
{
|
||||
setUniversalDetector(olddetector);
|
||||
ok(true, "page loaded successfully");
|
||||
SimpleTest.finish();
|
||||
};
|
||||
|
||||
var olddetector = setUniversalDetector("universal_charset_detector");
|
||||
testframe.src = "bug466409-page.html";
|
||||
|
||||
SpecialPowers.pushPrefEnv({"set": [['intl.charset.detector', 'universal_charset_detector']]}, function() {
|
||||
testframe.onload = function () {
|
||||
ok(true, "page loaded successfully");
|
||||
SimpleTest.finish();
|
||||
};
|
||||
testframe.src = "bug466409-page.html";
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
@ -22,22 +22,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=889335
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
/** Test for NavigatorLanguage **/
|
||||
var prefValue = null;
|
||||
var actualLanguageChangesFromHandler = 0;
|
||||
var actualLanguageChangesFromAVL = 0;
|
||||
var expectedLanguageChanges = 0;
|
||||
|
||||
function setUp() {
|
||||
try {
|
||||
prefValue = SpecialPowers.getCharPref('intl.accept_languages');
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
SpecialPowers.setCharPref('intl.accept_languages', prefValue);
|
||||
}
|
||||
|
||||
var testValues = [
|
||||
{ accept_languages: 'foo', language: 'foo', languages: ['foo'] },
|
||||
{ accept_languages: '', language: '', languages: [] },
|
||||
@ -58,7 +46,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=889335
|
||||
function nextTest() {
|
||||
currentTestIdx++;
|
||||
if (currentTestIdx >= tests.length) {
|
||||
tearDown();
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
@ -90,7 +77,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=889335
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
SpecialPowers.setCharPref('intl.accept_languages', 'testArrayCached');
|
||||
SpecialPowers.pushPrefEnv({"set": [['intl.accept_languages', 'testArrayCached']]});
|
||||
}, 0);
|
||||
});
|
||||
|
||||
@ -103,7 +90,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=889335
|
||||
"nextTest();");
|
||||
|
||||
setTimeout(function() {
|
||||
SpecialPowers.setCharPref('intl.accept_languages', 'testEventProperties');
|
||||
SpecialPowers.pushPrefEnv({"set": [['intl.accept_languages', 'testEventProperties']]}, function() {});
|
||||
}, 0);
|
||||
});
|
||||
|
||||
@ -133,7 +120,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=889335
|
||||
for (var i = 0; i < testValues.length; ++i) {
|
||||
var data = testValues[i];
|
||||
setTimeout(function(data) {
|
||||
SpecialPowers.setCharPref('intl.accept_languages', data.accept_languages);
|
||||
SpecialPowers.pushPrefEnv({"set": [['intl.accept_languages', data.accept_languages]]});
|
||||
}, 0, data);
|
||||
expectedLanguageChanges++;
|
||||
yield undefined;
|
||||
@ -156,22 +143,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=889335
|
||||
genEvents.next();
|
||||
});
|
||||
|
||||
// Check that the orientationchange event isn't sent twice if the preference
|
||||
// Check that the languagechange event isn't sent twice if the preference
|
||||
// is set to the same value.
|
||||
tests.push(function testOnlyFireIfRealChange() {
|
||||
function* changeLanguage() {
|
||||
setTimeout(function() {
|
||||
SpecialPowers.setCharPref('intl.accept_languages', 'fr-CA');
|
||||
SpecialPowers.pushPrefEnv({"set": [['intl.accept_languages', 'fr-CA']]});
|
||||
});
|
||||
yield undefined;
|
||||
|
||||
setTimeout(function() {
|
||||
// Twice the same change, should fire only one event.
|
||||
SpecialPowers.setCharPref('intl.accept_languages', 'fr-CA');
|
||||
SpecialPowers.pushPrefEnv({"set": [['intl.accept_languages', 'fr-CA']]});
|
||||
setTimeout(function() {
|
||||
// A real change to tell the test it should now count how many changes were
|
||||
// received until now.
|
||||
SpecialPowers.setCharPref('intl.accept_languages', 'fr-FR');
|
||||
SpecialPowers.pushPrefEnv({"set": [['intl.accept_languages', 'fr-FR']]});
|
||||
});
|
||||
});
|
||||
yield undefined;
|
||||
@ -210,16 +197,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=889335
|
||||
|
||||
SpecialPowers.exactGC(window, function() {
|
||||
// This should not crash.
|
||||
SpecialPowers.setCharPref('intl.accept_languages', 'en-GB');
|
||||
|
||||
nextTest();
|
||||
SpecialPowers.pushPrefEnv({"set": [['intl.accept_languages', 'en-GB']]}, nextTest);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// There is one test using document.body.
|
||||
addLoadEvent(function() {
|
||||
setUp();
|
||||
tests[0]();
|
||||
});
|
||||
|
||||
|
@ -54,22 +54,6 @@ function deleteDB() {
|
||||
backend.sendAsyncMessage("deleteDB");
|
||||
}
|
||||
|
||||
function setSubstringMatching(value) {
|
||||
info("Setting substring matching to " + value);
|
||||
|
||||
if (value) {
|
||||
SpecialPowers.setIntPref("dom.phonenumber.substringmatching.BR", value);
|
||||
|
||||
// this is the Mcc for Brazil, so that we trigger the previous pref
|
||||
SpecialPowers.setCharPref("ril.lastKnownSimMcc", "724");
|
||||
} else {
|
||||
SpecialPowers.clearUserPref("dom.phonenumber.substringmatching.BR");
|
||||
SpecialPowers.clearUserPref("ril.lastKnownSimMcc");
|
||||
}
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
var steps = [
|
||||
function setupChromeScript() {
|
||||
loadChromeScript();
|
||||
@ -79,7 +63,6 @@ var steps = [
|
||||
|
||||
deleteDB, // let's be sure the DB does not exist yet
|
||||
createDB.bind(null, 12),
|
||||
setSubstringMatching.bind(null, 7),
|
||||
|
||||
function testAccessMozContacts() {
|
||||
info("Checking we have the right number of contacts: " + contactsCount);
|
||||
@ -194,7 +177,6 @@ var steps = [
|
||||
},
|
||||
|
||||
deleteDB,
|
||||
setSubstringMatching.bind(null, null),
|
||||
|
||||
function finish() {
|
||||
backend.destroy();
|
||||
@ -203,7 +185,9 @@ var steps = [
|
||||
}
|
||||
];
|
||||
|
||||
start_tests();
|
||||
// this is the Mcc for Brazil, so that we trigger the previous pref
|
||||
SpecialPowers.pushPrefEnv({"set": [["dom.phonenumber.substringmatching.BR", 7],
|
||||
["ril.lastKnownSimMcc", "724"]]}, start_tests);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
@ -97,9 +97,10 @@ function checkFirst()
|
||||
is(first, ref, "The default Accept header used by image loader is correct");
|
||||
|
||||
SpecialPowers.setCharPref("image.http.accept", "image/png");
|
||||
|
||||
var remoteCanvas = new RemoteCanvas("bug496292-iframe-2.html");
|
||||
remoteCanvas.load(checkSecond);
|
||||
SpecialPowers.pushPrefEnv({"set": [["image.http.accept", "image/png"]]}, function() {
|
||||
var remoteCanvas = new RemoteCanvas("bug496292-iframe-2.html");
|
||||
remoteCanvas.load(checkSecond);
|
||||
});
|
||||
}
|
||||
|
||||
function checkSecond()
|
||||
@ -107,12 +108,10 @@ function checkSecond()
|
||||
second = canvas.toDataURL();
|
||||
is(second, ref, "The modified Accept header used by image loader is correct");
|
||||
|
||||
try {
|
||||
SpecialPowers.clearUserPref("image.http.accept");
|
||||
} catch (ex) { }
|
||||
|
||||
var remoteCanvas = new RemoteCanvas("bug496292-iframe-1.html");
|
||||
remoteCanvas.load(checkThird);
|
||||
SpecialPowers.pushPrefEnv({"clear": [["image.http.accept"]]}, function() {
|
||||
var remoteCanvas = new RemoteCanvas("bug496292-iframe-1.html");
|
||||
remoteCanvas.load(checkThird);
|
||||
});
|
||||
}
|
||||
|
||||
function checkThird() {
|
||||
|
@ -129,12 +129,15 @@ function test() {
|
||||
aWindow.close();
|
||||
|
||||
// Load the test from a URL on the whitelist but without the whitelist
|
||||
SpecialPowers.setCharPref("urlclassifier.trackingWhitelistTable", "");
|
||||
testOnWindow(contentPage1, function(aWindow) {
|
||||
checkLoads(aWindow, false);
|
||||
aWindow.close();
|
||||
SimpleTest.finish();
|
||||
});
|
||||
SpecialPowers.pushPrefEnv({"set" : [["urlclassifier.trackingWhitelistTable", ""]]},
|
||||
function() {
|
||||
testOnWindow(contentPage1, function(aWindow) {
|
||||
checkLoads(aWindow, false);
|
||||
aWindow.close();
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user