2011-05-20 16:37:02 +04:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
|
2019-03-22 21:13:25 +03:00
|
|
|
/**
|
|
|
|
* Test for Bug 655273
|
2011-05-20 16:37:02 +04:00
|
|
|
*
|
|
|
|
* Call pushState and then make sure that the favicon service associates our
|
|
|
|
* old favicon with the new URI.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
const testDir = "http://mochi.test:8888/browser/docshell/test/browser/";
|
|
|
|
const origURL = testDir + "file_bug655270.html";
|
2019-03-22 21:13:25 +03:00
|
|
|
const newURL = origURL + "?new_page";
|
2011-05-20 16:37:02 +04:00
|
|
|
|
|
|
|
const faviconURL = testDir + "favicon_bug655270.ico";
|
|
|
|
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
2017-05-15 22:49:50 +03:00
|
|
|
let tab = BrowserTestUtils.addTab(gBrowser, origURL);
|
2011-05-20 16:37:02 +04:00
|
|
|
|
|
|
|
// The page at origURL has a <link rel='icon'>, so we should get a call into
|
|
|
|
// our observer below when it loads. Once we verify that we have the right
|
|
|
|
// favicon URI, we call pushState, which should trigger another onPageChange
|
|
|
|
// event, this time for the URI after pushState.
|
|
|
|
|
|
|
|
let observer = {
|
2019-03-22 21:13:25 +03:00
|
|
|
onPageChanged(aURI, aWhat, aValue) {
|
2011-05-20 16:37:02 +04:00
|
|
|
if (aWhat != Ci.nsINavHistoryObserver.ATTRIBUTE_FAVICON) {
|
|
|
|
return;
|
2019-07-05 10:59:46 +03:00
|
|
|
}
|
2011-05-20 16:37:02 +04:00
|
|
|
|
|
|
|
if (aURI.spec == origURL) {
|
2019-03-22 21:13:25 +03:00
|
|
|
is(aValue, faviconURL, "FaviconURL for original URI");
|
2016-10-18 23:59:06 +03:00
|
|
|
// Ignore the promise returned here and wait for the next
|
|
|
|
// onPageChanged notification.
|
2019-12-13 23:36:16 +03:00
|
|
|
SpecialPowers.spawn(tab.linkedBrowser, [], function() {
|
2019-03-22 21:13:25 +03:00
|
|
|
content.history.pushState("", "", "?new_page");
|
2016-10-18 23:59:06 +03:00
|
|
|
});
|
2011-05-20 16:37:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (aURI.spec == newURL) {
|
2019-03-22 21:13:25 +03:00
|
|
|
is(aValue, faviconURL, "FaviconURL for new URI");
|
2011-05-20 16:37:02 +04:00
|
|
|
gBrowser.removeTab(tab);
|
|
|
|
PlacesUtils.history.removeObserver(this);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-03-22 21:13:25 +03:00
|
|
|
onBeginUpdateBatch() {},
|
|
|
|
onEndUpdateBatch() {},
|
|
|
|
onTitleChanged() {},
|
|
|
|
onDeleteURI() {},
|
|
|
|
onClearHistory() {},
|
|
|
|
onDeleteVisits() {},
|
|
|
|
QueryInterface: ChromeUtils.generateQI([Ci.nsINavHistoryObserver]),
|
2011-05-20 16:37:02 +04:00
|
|
|
};
|
|
|
|
|
2017-04-14 22:51:38 +03:00
|
|
|
PlacesUtils.history.addObserver(observer);
|
2011-05-20 16:37:02 +04:00
|
|
|
}
|