Bug 432741 - Lock icon status bar should open security info on single click. r=johnath

--HG--
rename : browser/base/content/test/browser_feed_tab.js => browser/base/content/test/browser_pageInfo.js
This commit is contained in:
Nochum Sossonko (Natch) 2009-07-02 13:52:42 -04:00
Родитель 4d88771b02
Коммит 6865943189
3 изменённых файлов: 100 добавлений и 55 удалений

Просмотреть файл

@ -585,7 +585,7 @@
command="Tools:Downloads"/>
<statusbarpanel id="security-button" class="statusbarpanel-iconic-text"
hidden="true"
ondblclick="if (event.button == 0) displaySecurityInfo();"/>
onclick="if (event.button == 0 &amp;&amp; event.detail == 1) displaySecurityInfo();"/>
<statusbarpanel id="page-report-button" type="menu"
class="statusbarpanel-menu-iconic"
hidden="true"

Просмотреть файл

@ -1,54 +0,0 @@
function test() {
waitForExplicitFinish();
var pageInfo, obs;
var gTestPage = gBrowser.addTab();
gBrowser.selectedTab = gTestPage;
gTestPage.linkedBrowser.addEventListener("load", handleLoad, true);
content.location =
"http://localhost:8888/browser/browser/base/content/test/feed_tab.html";
gTestPage.focus();
var observer = {
observe: function(win, topic, data) {
if (topic != "page-info-dialog-loaded")
return;
obs.removeObserver(observer, "page-info-dialog-loaded");
handlePageInfo();
}
};
function handleLoad() {
pageInfo = BrowserPageInfo();
obs = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
obs.addObserver(observer, "page-info-dialog-loaded", false);
}
function handlePageInfo() {
function $(aId) { return pageInfo.document.getElementById(aId) };
var feedTab = $("feedTab");
var feedListbox = $("feedListbox");
ok(feedListbox, "Feed list is null (feeds tab is broken)");
var feedRowsNum = feedListbox.getRowCount();
ok(feedRowsNum == 3, "Number of feeds listed: " +
feedRowsNum + ", should be 3");
for (var i = 0; i < feedRowsNum; i++) {
let feedItem = feedListbox.getItemAtIndex(i);
ok(feedItem.getAttribute("name") == (i+1),
"Name given: " + feedItem.getAttribute("name") + ", should be " + (i+1));
}
pageInfo.close();
gTestPage.focus();
gBrowser.removeCurrentTab();
finish();
}
}

Просмотреть файл

@ -0,0 +1,99 @@
function test() {
waitForExplicitFinish();
var pageInfo, obs, atTest = 0;
var gTestPage = gBrowser.addTab();
gBrowser.selectedTab = gTestPage;
gTestPage.linkedBrowser.addEventListener("load", handleLoad, true);
content.location =
"https://example.com/browser/browser/base/content/test/feed_tab.html";
gTestPage.focus();
var observer = {
observe: function(win, topic, data) {
if (topic != "page-info-dialog-loaded")
return;
switch(atTest) {
case 0:
atTest++;
handlePageInfo();
break;
case 1:
atTest++;
pageInfo = win;
testLockClick();
break;
case 2:
atTest++;
obs.removeObserver(observer, "page-info-dialog-loaded");
testLockDoubleClick();
break;
}
}
}
function handleLoad() {
pageInfo = BrowserPageInfo();
obs = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
obs.addObserver(observer, "page-info-dialog-loaded", false);
}
function $(aId) { return pageInfo.document.getElementById(aId) };
function handlePageInfo() {
var feedTab = $("feedTab");
var feedListbox = $("feedListbox");
ok(feedListbox, "Feed list is null (feeds tab is broken)");
var feedRowsNum = feedListbox.getRowCount();
ok(feedRowsNum == 3, "Number of feeds listed: " +
feedRowsNum + ", should be 3");
for (var i = 0; i < feedRowsNum; i++) {
let feedItem = feedListbox.getItemAtIndex(i);
ok(feedItem.getAttribute("name") == (i+1),
"Name given: " + feedItem.getAttribute("name") + ", should be " + (i+1));
}
pageInfo.addEventListener("unload", function() {
pageInfo.removeEventListener("unload", arguments.callee, false);
var lockIcon = document.getElementById("security-button");
EventUtils.synthesizeMouse(lockIcon, 0, 0, {clickCount: 1});
}, false);
pageInfo.close();
}
function testLockClick() {
var deck = $("mainDeck");
is(deck.selectedPanel.id, "securityPanel", "The security tab should open when the lock icon is clicked");
pageInfo.addEventListener("unload", function() {
pageInfo.removeEventListener("unload", arguments.callee, false);
var lockIcon = document.getElementById("security-button");
EventUtils.synthesizeMouse(lockIcon, 0, 0, {clickCount: 1});
EventUtils.synthesizeMouse(lockIcon, 0, 0, {clickCount: 2});
}, false);
pageInfo.close();
}
function testLockDoubleClick() {
var pageInfoDialogs = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator)
.getEnumerator("Browser:page-info");
var i = 0;
while(pageInfoDialogs.hasMoreElements()) {
i++;
pageInfo = pageInfoDialogs.getNext();
pageInfo.close();
}
is(i, 1, "When the lock is clicked twice there should be only one page info dialog");
gTestPage.focus();
gBrowser.removeCurrentTab();
finish();
}
}