2008-10-12 20:05:11 -07:00
|
|
|
/*
|
2010-09-09 19:08:26 -07:00
|
|
|
* getPopupNotifications
|
2008-10-12 20:05:11 -07:00
|
|
|
*
|
2010-09-09 19:08:26 -07:00
|
|
|
* Fetches the popup notification for the specified window.
|
2008-10-12 20:05:11 -07:00
|
|
|
*/
|
2010-09-09 19:08:26 -07:00
|
|
|
function getPopupNotifications(aWindow) {
|
2012-06-11 18:13:20 -07:00
|
|
|
var chromeWin = SpecialPowers.wrap(aWindow)
|
|
|
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIWebNavigation)
|
|
|
|
.QueryInterface(Ci.nsIDocShell)
|
|
|
|
.chromeEventHandler.ownerDocument.defaultView;
|
2010-09-09 19:08:26 -07:00
|
|
|
|
|
|
|
var popupNotifications = chromeWin.PopupNotifications;
|
|
|
|
return popupNotifications;
|
2008-10-12 20:05:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2010-09-09 19:08:26 -07:00
|
|
|
* getPopup
|
2008-10-12 20:05:11 -07:00
|
|
|
*
|
|
|
|
*/
|
2010-09-09 19:08:26 -07:00
|
|
|
function getPopup(aPopupNote, aKind) {
|
|
|
|
ok(true, "Looking for " + aKind + " popup notification");
|
|
|
|
return aPopupNote.getNotification(aKind);
|
2008-10-12 20:05:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2010-09-09 19:08:26 -07:00
|
|
|
* clickPopupButton
|
2008-10-12 20:05:11 -07:00
|
|
|
*
|
2010-09-09 19:08:26 -07:00
|
|
|
* Clicks the specified popup notification button.
|
2008-10-12 20:05:11 -07:00
|
|
|
*/
|
2010-09-09 19:08:26 -07:00
|
|
|
function clickPopupButton(aPopup, aButtonIndex) {
|
|
|
|
ok(true, "Looking for action at index " + aButtonIndex);
|
|
|
|
|
2012-06-11 18:13:20 -07:00
|
|
|
var notifications = SpecialPowers.wrap(aPopup.owner).panel.childNodes;
|
2010-09-09 19:08:26 -07:00
|
|
|
ok(notifications.length > 0, "at least one notification displayed");
|
|
|
|
ok(true, notifications.length + " notifications");
|
|
|
|
var notification = notifications[0];
|
|
|
|
|
|
|
|
if (aButtonIndex == 0) {
|
|
|
|
ok(true, "Triggering main action");
|
|
|
|
notification.button.doCommand();
|
|
|
|
} else if (aButtonIndex <= aPopup.secondaryActions.length) {
|
|
|
|
var index = aButtonIndex - 1;
|
|
|
|
ok(true, "Triggering secondary action " + index);
|
|
|
|
notification.childNodes[index].doCommand();
|
|
|
|
}
|
2008-10-12 20:05:11 -07:00
|
|
|
}
|
2009-05-06 12:55:25 -07:00
|
|
|
|
|
|
|
const kRememberButton = 0;
|
|
|
|
const kNeverButton = 1;
|
|
|
|
|
|
|
|
const kChangeButton = 0;
|
|
|
|
const kDontChangeButton = 1;
|
2011-06-03 18:12:11 -07:00
|
|
|
|
|
|
|
function dumpNotifications() {
|
|
|
|
try {
|
|
|
|
// PopupNotifications
|
|
|
|
var container = getPopupNotifications(window.top);
|
|
|
|
ok(true, "is popup panel open? " + container.isPanelOpen);
|
|
|
|
var notes = container._currentNotifications;
|
|
|
|
ok(true, "Found " + notes.length + " popup notifications.");
|
|
|
|
for (var i = 0; i < notes.length; i++) {
|
|
|
|
ok(true, "#" + i + ": " + notes[i].id);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Notification bars
|
2012-06-11 18:13:20 -07:00
|
|
|
var chromeWin = SpecialPowers.wrap(window.top)
|
|
|
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
2011-06-03 18:12:11 -07:00
|
|
|
.getInterface(Ci.nsIWebNavigation)
|
|
|
|
.QueryInterface(Ci.nsIDocShell)
|
|
|
|
.chromeEventHandler.ownerDocument.defaultView;
|
|
|
|
var nb = chromeWin.getNotificationBox(window.top);
|
|
|
|
var notes = nb.allNotifications;
|
|
|
|
ok(true, "Found " + notes.length + " notification bars.");
|
|
|
|
for (var i = 0; i < notes.length; i++) {
|
|
|
|
ok(true, "#" + i + ": " + notes[i].getAttribute("value"));
|
|
|
|
}
|
|
|
|
} catch(e) { todo(false, "WOAH! " + e); }
|
|
|
|
}
|