2008-10-12 20:05:11 -07:00
|
|
|
/*
|
|
|
|
* getNotificationBox
|
|
|
|
*
|
|
|
|
* Fetches the notification box for the specified window.
|
|
|
|
*/
|
|
|
|
function getNotificationBox(aWindow) {
|
|
|
|
var chromeWin = aWindow
|
|
|
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIWebNavigation)
|
|
|
|
.QueryInterface(Ci.nsIDocShellTreeItem)
|
|
|
|
.rootTreeItem
|
|
|
|
.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Ci.nsIDOMWindow)
|
|
|
|
.QueryInterface(Ci.nsIDOMChromeWindow);
|
|
|
|
|
|
|
|
// Don't need .wrappedJSObject here, unlike when chrome does this.
|
|
|
|
var notifyBox = chromeWin.getNotificationBox(aWindow);
|
|
|
|
return notifyBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* getNotificationBar
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function getNotificationBar(aBox, aKind) {
|
|
|
|
ok(true, "Looking for " + aKind + " notification bar");
|
|
|
|
// Sometimes callers wants a bar, sometimes not. Allow 0 or 1, but not 2+.
|
|
|
|
ok(aBox.allNotifications.length <= 1, "Checking for multiple notifications");
|
|
|
|
return aBox.getNotificationWithValue(aKind);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* clickNotificationButton
|
|
|
|
*
|
|
|
|
* Clicks the specified notification button.
|
|
|
|
*/
|
2009-05-06 12:55:25 -07:00
|
|
|
function clickNotificationButton(aBar, aButtonIndex) {
|
2008-10-12 20:05:11 -07:00
|
|
|
// This is a bit of a hack. The notification doesn't have an API to
|
|
|
|
// trigger buttons, so we dive down into the implementation and twiddle
|
|
|
|
// the buttons directly.
|
2009-05-06 12:55:25 -07:00
|
|
|
var button = aBar.getElementsByTagName("button").item(aButtonIndex);
|
|
|
|
ok(button, "Got button " + aButtonIndex);
|
|
|
|
button.doCommand();
|
2008-10-12 20:05:11 -07:00
|
|
|
}
|
2009-05-06 12:55:25 -07:00
|
|
|
|
|
|
|
const kRememberButton = 0;
|
|
|
|
const kNeverButton = 1;
|
|
|
|
const kNotNowButton = 2;
|
|
|
|
|
|
|
|
const kChangeButton = 0;
|
|
|
|
const kDontChangeButton = 1;
|