Bug 1132556 - Replace runInContent() with ContentTask.spawn(). r=smacleod

This commit is contained in:
AJ Kerrigan 2016-01-07 03:26:31 -05:00
parent 6fd5733c1f
commit ff3269f2d2
4 changed files with 8 additions and 24 deletions

View File

@ -32,9 +32,9 @@ function test() {
is(tabState.entries[0].url, baseURL + 0, "... but not more");
// visit yet another anchor (appending it to session history)
runInContent(tab.linkedBrowser, function(win) {
win.document.querySelector("a").click();
}, null).then(flushAndCheck);
ContentTask.spawn(tab.linkedBrowser, null, function() {
content.window.document.querySelector("a").click();
}).then(flushAndCheck);
function flushAndCheck() {
TabStateFlusher.flush(tab.linkedBrowser).then(check);

View File

@ -42,9 +42,9 @@ function checkState(tab) {
// deserialized in the content scope. And in this case, since RegExps are
// not currently Xrayable (see bug 1014991), trying to pull |obj3| (a RegExp)
// off of an Xrayed Object won't work. So we need to waive.
runInContent(tab.linkedBrowser, function(win, state) {
ContentTask.spawn(tab.linkedBrowser, aEvent.state, function(state) {
return Cu.waiveXrays(state).obj3.toString();
}, aEvent.state).then(function(stateStr) {
}).then(function(stateStr) {
is(stateStr, '/^a$/', "second popstate object.");
// Make sure that the new-elem node is present in the document. If it's
@ -92,13 +92,13 @@ function test() {
// testURL (state object: null) <-- oldest
// testURL (state object: {obj1:1})
// testURL?page2 (state object: {obj3:/^a$/}) <-- newest
function contentTest(win) {
let history = win.history;
function contentTest() {
let history = content.window.history;
history.pushState({obj1:1}, "title-obj1");
history.pushState({obj2:2}, "title-obj2", "?page2");
history.replaceState({obj3:/^a$/}, "title-obj3");
}
runInContent(browser, contentTest, null).then(function() {
ContentTask.spawn(browser, null, contentTest).then(function() {
return TabStateFlusher.flush(tab.linkedBrowser);
}).then(() => {
let state = ss.getTabState(tab);

View File

@ -216,12 +216,6 @@ addMessageListener("ss-test:click", function ({data}) {
sendAsyncMessage("ss-test:click");
});
addMessageListener("ss-test:run", function({data, objects}) {
let f = eval('(' + data.code + ')');
let result = f(content, objects.arg);
sendAsyncMessage("ss-test:runFinished", result);
});
addEventListener("load", function(event) {
let subframe = event.target != content.document;
sendAsyncMessage("ss-test:loadEvent", {subframe: subframe, url: event.target.documentURI});

View File

@ -449,16 +449,6 @@ function promiseNewWindowLoaded(aOptions) {
return new Promise(resolve => whenNewWindowLoaded(aOptions, resolve));
}
function runInContent(browser, func, arg, callback = null) {
let deferred = Promise.defer();
let mm = browser.messageManager;
mm.sendAsyncMessage("ss-test:run", {code: func.toSource()}, {arg: arg});
mm.addMessageListener("ss-test:runFinished", ({data}) => deferred.resolve(data));
return deferred.promise;
}
/**
* This waits for the browser-delayed-startup-finished notification of a given
* window. It indicates that the windows has loaded completely and is ready to