michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Test for Bug 655273 michael@0: * michael@0: * Call pushState and then make sure that the favicon service associates our michael@0: * old favicon with the new URI. michael@0: */ michael@0: michael@0: function test() { michael@0: const testDir = "http://mochi.test:8888/browser/docshell/test/browser/"; michael@0: const origURL = testDir + "file_bug655270.html"; michael@0: const newURL = origURL + '?new_page'; michael@0: michael@0: const faviconURL = testDir + "favicon_bug655270.ico"; michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: let tab = gBrowser.addTab(origURL); michael@0: michael@0: // The page at origURL has a , so we should get a call into michael@0: // our observer below when it loads. Once we verify that we have the right michael@0: // favicon URI, we call pushState, which should trigger another onPageChange michael@0: // event, this time for the URI after pushState. michael@0: michael@0: let observer = { michael@0: onPageChanged: function(aURI, aWhat, aValue) { michael@0: if (aWhat != Ci.nsINavHistoryObserver.ATTRIBUTE_FAVICON) michael@0: return; michael@0: michael@0: if (aURI.spec == origURL) { michael@0: is(aValue, faviconURL, 'FaviconURL for original URI'); michael@0: tab.linkedBrowser.contentWindow.history.pushState('', '', '?new_page'); michael@0: } michael@0: michael@0: if (aURI.spec == newURL) { michael@0: is(aValue, faviconURL, 'FaviconURL for new URI'); michael@0: gBrowser.removeTab(tab); michael@0: PlacesUtils.history.removeObserver(this); michael@0: finish(); michael@0: } michael@0: }, michael@0: michael@0: onBeginUpdateBatch: function() { }, michael@0: onEndUpdateBatch: function() { }, michael@0: onVisit: function() { }, michael@0: onTitleChanged: function() { }, michael@0: onDeleteURI: function() { }, michael@0: onClearHistory: function() { }, michael@0: onDeleteVisits: function() { }, michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver]) michael@0: }; michael@0: michael@0: PlacesUtils.history.addObserver(observer, false); michael@0: }