2011-02-27 17:36:36 -08:00
|
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
|
|
http://creativecommons.org/publicdomain/zero/1.0/ */
|
2010-11-23 11:30:16 -08:00
|
|
|
|
2012-04-12 03:27:27 -07:00
|
|
|
/**
|
|
|
|
* This file tests that, when there is an app tab that references an invalid
|
|
|
|
* favicon, the default favicon appears the group app tab tray, instead of an
|
|
|
|
* empty image that would not be visible.
|
|
|
|
*/
|
|
|
|
|
2011-05-31 13:00:01 -07:00
|
|
|
const fi = Cc["@mozilla.org/browser/favicon-service;1"].
|
|
|
|
getService(Ci.nsIFaviconService);
|
|
|
|
|
2010-11-23 11:30:16 -08:00
|
|
|
let newTab;
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
|
|
|
newTab = gBrowser.addTab();
|
|
|
|
|
2012-03-14 09:24:03 -07:00
|
|
|
showTabView(function() {
|
2012-05-04 07:32:35 -07:00
|
|
|
let cw = TabView.getContentWindow();
|
|
|
|
whenAppTabIconAdded(cw.GroupItems.groupItems[0], onTabPinned);
|
2012-03-14 09:24:03 -07:00
|
|
|
gBrowser.pinTab(newTab);
|
|
|
|
})
|
2010-11-23 11:30:16 -08:00
|
|
|
}
|
|
|
|
|
2012-03-14 09:24:03 -07:00
|
|
|
function onTabPinned() {
|
2012-05-04 07:32:35 -07:00
|
|
|
let contentWindow = TabView.getContentWindow();
|
2010-11-23 11:30:16 -08:00
|
|
|
is(contentWindow.GroupItems.groupItems.length, 1,
|
|
|
|
"There is one group item on startup");
|
|
|
|
|
|
|
|
let groupItem = contentWindow.GroupItems.groupItems[0];
|
|
|
|
let icon = contentWindow.iQ(".appTabIcon", groupItem.$appTabTray)[0];
|
|
|
|
let $icon = contentWindow.iQ(icon);
|
|
|
|
|
|
|
|
is($icon.data("xulTab"), newTab,
|
|
|
|
"The app tab icon has the right tab reference")
|
|
|
|
// check to see whether it's showing the default one or not.
|
2011-05-31 13:00:01 -07:00
|
|
|
is($icon.attr("src"), fi.defaultFavicon.spec,
|
2010-11-23 11:30:16 -08:00
|
|
|
"The icon is showing the default fav icon for blank tab");
|
|
|
|
|
|
|
|
let errorHandler = function(event) {
|
|
|
|
newTab.removeEventListener("error", errorHandler, false);
|
|
|
|
|
|
|
|
// since the browser code and test code are invoked when an error event is
|
|
|
|
// fired, a delay is used here to avoid the test code run before the browser
|
|
|
|
// code.
|
|
|
|
executeSoon(function() {
|
2011-08-23 07:48:53 -07:00
|
|
|
let iconSrc = $icon.attr("src");
|
2012-04-12 03:27:27 -07:00
|
|
|
|
2011-08-23 07:48:53 -07:00
|
|
|
// with moz-anno:favicon automatically redirects to the default favIcon
|
|
|
|
// if the given url is invalid
|
2012-09-23 12:09:29 -07:00
|
|
|
ok(iconSrc.startsWith("moz-anno:favicon:"),
|
2011-08-23 07:48:53 -07:00
|
|
|
"The icon url starts with moz-anno:favicon so the default fav icon would be displayed");
|
2010-11-23 11:30:16 -08:00
|
|
|
|
2012-04-12 03:27:27 -07:00
|
|
|
// At this point, as an additional integrity check we could also verify
|
|
|
|
// that the iconSrc URI does not have any associated favicon data. This
|
|
|
|
// kind of check, however, is not easily supported by the asynchronous
|
|
|
|
// favicon API. Fortunately, the fact that we received the error event
|
|
|
|
// already indicates that the original favicon was not available.
|
|
|
|
// Morevover, since we are using a "moz-anno:favicon:" URI, we know that
|
|
|
|
// we'll not display an empty icon, but the default favicon.
|
|
|
|
|
2010-11-23 11:30:16 -08:00
|
|
|
// clean up
|
|
|
|
gBrowser.removeTab(newTab);
|
|
|
|
let endGame = function() {
|
|
|
|
window.removeEventListener("tabviewhidden", endGame, false);
|
|
|
|
|
|
|
|
ok(!TabView.isVisible(), "Tab View is hidden");
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
window.addEventListener("tabviewhidden", endGame, false);
|
|
|
|
TabView.toggle();
|
|
|
|
});
|
|
|
|
};
|
|
|
|
newTab.addEventListener("error", errorHandler, false);
|
|
|
|
|
|
|
|
newTab.linkedBrowser.loadURI(
|
2011-10-05 08:46:47 -07:00
|
|
|
"http://mochi.test:8888/browser/browser/components/tabview/test/test_bug600645.html");
|
2010-11-23 11:30:16 -08:00
|
|
|
}
|