Bug 1222495 - Get dom/workers/test/test_suspend.html working with e10s and B2G. r=khuey
--- a/dom/workers/test/mochitest.ini
+++ b/dom/workers/test/mochitest.ini
@@ -182,17 +182,16 @@ skip-if = buildapp == 'b2g' # b2g(Failed
[test_resolveWorker.html]
[test_resolveWorker-assignment.html]
[test_rvals.html]
[test_sharedWorker.html]
[test_sharedWorker_performance_user_timing.html]
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]
[test_threadTimeouts.html]
[test_throwingOnerror.html]
[test_timeoutTracing.html]
[test_transferable.html]
[test_url.html]
--- a/dom/workers/test/test_suspend.html
+++ b/dom/workers/test/test_suspend.html
@@ -26,37 +26,25 @@
var suspended = false;
var resumed = false;
var finished = false;
var interval;
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() {
if (finished) {
return;
}
is(String(iframe.location), "about:blank", "Wrong url!");
is(suspended, true, "Not suspended?");
@@ -79,40 +67,42 @@
function suspendCallback() {
if (finished) {
return;
}
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) {
if (finished) {
return;
}
if (!suspended) {
ok(lastCount === undefined || lastCount == data - 1,
"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;
}
var newLocation =
window.location.toString().replace("test_suspend.html",
"suspend_iframe.html");
is(newLocation.indexOf(iframe.location.toString()), 0, "Wrong url!");