";
return goneBack;
});
}).then(({ location, persisted }) => {
is(location, firstLocation, "should go back to the right page");
ok(persisted, "test relies on BFCache");
return ContentTask.spawn(frame, {}, () => {
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
let t20 = content.document.getElementById("t20");
return fm.focusedElement === t20;
});
}).then((focusCorrect) => {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
todo(focusCorrect, "focus restored after history back");
} else {
ok(focusCorrect, "focus restored after history back");
}
done();
});
}
function addFrameSwitchingListeners(frame)
{
frame.contentWindow.addEventListener("focus", frameSwitchingEventOccured);
frame.contentWindow.addEventListener("blur", frameSwitchingEventOccured);
frame.contentDocument.addEventListener("focus", frameSwitchingEventOccured);
frame.contentDocument.addEventListener("blur", frameSwitchingEventOccured);
var node = frame.contentDocument.body.firstChild;
node.addEventListener("focus", frameSwitchingEventOccured);
node.addEventListener("blur", frameSwitchingEventOccured);
}
function frameSwitchingEventOccured(event)
{
if (!gExpectedEvents.length) {
gEventMatched = false;
return;
}
try {
var events = gExpectedEvents.shift();
is(event.target, events[0], "event target");
is(event.type, events[1], "event type");
is(fm.focusedElement, events[2], "focused element");
is(fm.focusedWindow, events[3], "focused frame");
if (events[4])
is(fm.getFocusedElementForWindow(events[4], false, {}), events[5], "focused element in frame");
if (gEventMatched && event.target == events[0] && event.type == events[1] &&
fm.focusedElement == events[2] && fm.focusedWindow == events[3]) {
if (!events[4] || fm.getFocusedElementForWindow(events[4], false, {}) == events[5])
return;
}
} catch (ex) { ok(ex, "exception"); }
gEventMatched = false;
}
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(startTest);
]]>