/** * Test for Bug 670318 * * When LoadEntry() is called on a browser that has multiple duplicate history * entries, history.index can end up out of range (>= history.count).
*/
add_task(async function test() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "about:blank" },
async function (browser) { if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
await ContentTask.spawn(browser, URL, async function (URL) {
let history = docShell.QueryInterface(
Ci.nsIWebNavigation
).sessionHistory;
let count = 0;
let testDone = {};
testDone.promise = new Promise(resolve => {
testDone.resolve = resolve;
});
// Since listener implements nsISupportsWeakReference, we are // responsible for keeping it alive so that the GC doesn't clear // it before the test completes. We do this by anchoring the listener // to the message manager, and clearing it just before the test // completes. this._testListener = {
owner: this,
OnHistoryNewEntry(aNewURI) {
info("OnHistoryNewEntry " + aNewURI.spec + ", " + count); if (aNewURI.spec == URL && 5 == ++count) {
addEventListener( "load", function onLoad() { Assert.ok(
history.index < history.count, "history.index is valid"
);
testDone.resolve();
},
{ capture: true, once: true }
);
OnHistoryReload: () => true,
OnHistoryGotoIndex: () => {},
OnHistoryPurge: () => {},
OnHistoryReplaceEntry: () => { // The initial load of about:blank causes a transient entry to be // created, so our first navigation to a real page is a replace // instead of a new entry.
++count;
},
OnHistoryReload: () => true,
OnHistoryGotoIndex: () => {},
OnHistoryPurge: () => {},
OnHistoryReplaceEntry: () => { // The initial load of about:blank causes a transient entry to be // created, so our first navigation to a real page is a replace // instead of a new entry.
++count;
},
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.