gecko-dev/docshell/test/browser/browser_bug655270.js
Kris Maglione 94e3b0bd8d Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn calls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato
This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

Differential Revision: https://phabricator.services.mozilla.com/D53740

--HG--
extra : moz-landing-system : lando
2019-12-13 20:36:16 +00:00

60 lines
1.8 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test for Bug 655273
*
* 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";
const newURL = origURL + "?new_page";
const faviconURL = testDir + "favicon_bug655270.ico";
waitForExplicitFinish();
let tab = BrowserTestUtils.addTab(gBrowser, origURL);
// 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 = {
onPageChanged(aURI, aWhat, aValue) {
if (aWhat != Ci.nsINavHistoryObserver.ATTRIBUTE_FAVICON) {
return;
}
if (aURI.spec == origURL) {
is(aValue, faviconURL, "FaviconURL for original URI");
// Ignore the promise returned here and wait for the next
// onPageChanged notification.
SpecialPowers.spawn(tab.linkedBrowser, [], function() {
content.history.pushState("", "", "?new_page");
});
}
if (aURI.spec == newURL) {
is(aValue, faviconURL, "FaviconURL for new URI");
gBrowser.removeTab(tab);
PlacesUtils.history.removeObserver(this);
finish();
}
},
onBeginUpdateBatch() {},
onEndUpdateBatch() {},
onTitleChanged() {},
onDeleteURI() {},
onClearHistory() {},
onDeleteVisits() {},
QueryInterface: ChromeUtils.generateQI([Ci.nsINavHistoryObserver]),
};
PlacesUtils.history.addObserver(observer);
}