Bug 1162787 - Make the service worker periodic tests robust to the idle daily service firing its notification when the tests are being run; r=nsm

--HG--
extra : rebase_source : b78061a0cda67e426cdbbef7f89ca006c03a9158
This commit is contained in:
Ehsan Akhgari 2015-05-07 16:23:50 -07:00
Родитель a26860eed6
Коммит 71f3e8945e
3 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -54,8 +54,13 @@ ServiceWorkerPeriodicUpdater::Observe(nsISupports* aSubject,
const char* aTopic,
const char16_t* aData)
{
// In tests, the pref is set to false so that the idle-daily service does not
// trigger updates leading to intermittent failures.
// We're called from SpecialPowers inside tests, in which case we need to
// update during the test run, for which we use a non-empty aData.
NS_NAMED_LITERAL_STRING(CallerSpecialPowers, "Caller:SpecialPowers");
if (strcmp(aTopic, OBSERVER_TOPIC_IDLE_DAILY) == 0 &&
sPeriodicUpdatesEnabled) {
(sPeriodicUpdatesEnabled || CallerSpecialPowers.Equals(aData))) {
// First, update all registrations in the parent process.
nsCOMPtr<nsIServiceWorkerManager> swm =
mozilla::services::GetServiceWorkerManager();

Просмотреть файл

@ -67,7 +67,6 @@ function runTheTest() {
["dom.serviceWorkers.exemptFromPerDomainMax", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
["dom.serviceWorkers.periodic-updates.enabled", true],
]}, function() {
start();
});

Просмотреть файл

@ -515,7 +515,7 @@ SpecialPowersObserverAPI.prototype = {
// at the cost of hard-coding the usage of PeriodicServiceWorkerUpdater.
Cc["@mozilla.org/service-worker-periodic-updater;1"].
getService(Ci.nsIObserver).
observe(null, "idle-daily", "");
observe(null, "idle-daily", "Caller:SpecialPowers");
return undefined; // See comment at the beginning of this function.
}