Bug 1222495 - Get dom/workers/test/test_suspend.html working with e10s and B2G. r=khuey

This commit is contained in:
Andrew McCreight 2015-11-12 08:08:47 -08:00
Родитель 7f79cf9b7a
Коммит 0d0da460ed
2 изменённых файлов: 18 добавлений и 29 удалений

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

@ -187,7 +187,6 @@ skip-if = buildapp == 'b2g' # b2g(Failed to load script: relativeLoad_import.js)
skip-if = (toolkit == 'gonk' && debug) # Bug 1176223
[test_simpleThread.html]
[test_suspend.html]
skip-if = buildapp == 'b2g' || e10s # b2g(test timed out, might need more time) b2g-debug(test timed out, might need more time) b2g-desktop(test timed out, might need more time) e10s(Bug 1222495 - Sets preferences directly)
[test_terminate.html]
[test_terminateSyncXHR.html]
[test_threadErrors.html]

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

@ -31,27 +31,15 @@
var oldMessageCount;
var waitCount = 0;
function setCachePref(enabled) {
var prefBranch = SpecialPowers.Cc["@mozilla.org/preferences-service;1"]
.getService(SpecialPowers.Ci.nsIPrefBranch);
if (enabled) {
prefBranch.setBoolPref("browser.sessionhistory.cache_subframes", true);
}
else {
try {
prefBranch.clearUserPref("browser.sessionhistory.cache_subframes");
} catch (e) { /* Pref didn't exist, meh */ }
}
}
function finishTest() {
if (finished) {
return;
}
finished = true;
setCachePref(false);
iframe.terminateWorker();
SimpleTest.finish();
SpecialPowers.flushPrefEnv(function () {
iframe.terminateWorker();
SimpleTest.finish();
});
}
function waitInterval() {
@ -84,12 +72,13 @@
is(String(iframe.location), "about:blank", "Wrong url!");
is(suspended, false, "Already suspended?");
is(resumed, false, "Already resumed?");
setCachePref(false);
suspended = true;
var iframeElement = document.getElementById("workerFrame");
iframeElement.onload = badOnloadCallback;
oldMessageCount = lastCount;
interval = setInterval(waitInterval, 1000);
SpecialPowers.popPrefEnv(function () {
suspended = true;
var iframeElement = document.getElementById("workerFrame");
iframeElement.onload = badOnloadCallback;
oldMessageCount = lastCount;
interval = setInterval(waitInterval, 1000);
});
}
function messageCallback(data) {
@ -102,12 +91,13 @@
"Got good data, lastCount = " + lastCount + ", data = " + data);
lastCount = data;
if (lastCount == 25) {
setCachePref(true);
iframe.location = "about:blank";
// We want suspend_iframe.html to go into bfcache, so we need to flush
// out all pending notifications. Otherwise, if they're flushed too
// late, they could kick us out of the bfcache again.
iframe.document.body.offsetTop;
SpecialPowers.pushPrefEnv({"set": [["browser.sessionhistory.cache_subframes", true]]}, function () {
iframe.location = "about:blank";
// We want suspend_iframe.html to go into bfcache, so we need to flush
// out all pending notifications. Otherwise, if they're flushed too
// late, they could kick us out of the bfcache again.
iframe.document.body.offsetTop;
});
}
return;
}