Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Errors
- This test gets skipped with pattern: os == 'linux' && os_version == '24.04' && arch == 'x86_64' && display == 'x11' && asan OR os == 'linux' && os_version == '24.04' && arch == 'x86_64' && display == 'x11' && debug OR os == 'linux' && os_version == '24.04' && arch == 'x86_64' && display == 'x11' && tsan OR os == 'win' && os_version == '11.26100' && arch == 'x86_64' && asan OR os == 'win' && os_version == '11.26200' && arch == 'x86_64' && asan
- This test failed 2 times in the preceding 30 days. quicksearch this test
- Manifest: docshell/test/browser/browser.toml
/* Any copyright is dedicated to the Public Domain.
/**
* 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).
*/
const URL =
async function test_body(browser) {
let history = browser.browsingContext.sessionHistory;
let count = 0;
let testDone = {};
testDone.promise = new Promise(resolve => {
testDone.resolve = resolve;
});
let listener = {
async OnHistoryNewEntry(aNewURI) {
if (aNewURI.spec == URL && 5 == ++count) {
history.removeSHistoryListener(listener);
let loaded = BrowserTestUtils.browserLoaded(browser);
SpecialPowers.spawn(browser, [], () => {
content.location.reload();
});
await loaded;
Assert.less(history.index, history.count, "history.index is valid");
testDone.resolve();
}
},
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;
// XXX I think this will be notified once |URL|, i.e. file_bug670318.html loads.
// this is probably not desired.
},
QueryInterface: ChromeUtils.generateQI([
"nsISHistoryListener",
"nsISupportsWeakReference",
]),
};
history.addSHistoryListener(listener);
BrowserTestUtils.startLoadingURIString(browser, URL);
await testDone.promise;
}
add_task(async function test() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "about:blank" },
test_body
);
});