Bug 1227300, Part 7 - Update test interfaces. a=testonly

This commit is contained in:
Kit Cambridge 2015-11-23 15:03:20 -08:00
parent 37c04c712c
commit 64ff2873e3
5 changed files with 47 additions and 22 deletions

View File

@ -29,26 +29,34 @@ var MockServices = (function () {
});
var mockAlertsService = {
showAlertNotification: function(imageUrl, title, text, textClickable,
cookie, alertListener, name) {
showAlert: function(alert, alertListener) {
var listener = SpecialPowers.wrap(alertListener);
activeAlertNotifications[name] = {
activeAlertNotifications[alert.name] = {
listener: listener,
cookie: cookie,
title: title
cookie: alert.cookie,
title: alert.title
};
// fake async alert show event
if (listener) {
setTimeout(function () {
listener.observe(null, "alertshow", cookie);
listener.observe(null, "alertshow", alert.cookie);
}, 100);
setTimeout(function () {
listener.observe(null, "alertclickcallback", cookie);
listener.observe(null, "alertclickcallback", alert.cookie);
}, 100);
}
},
showAlertNotification: function(imageUrl, title, text, textClickable,
cookie, alertListener, name) {
this.showAlert({
name: name,
cookie: cookie,
title: title
}, alertListener);
},
showAppNotification: function(aImageUrl, aTitle, aText, aAlertListener, aDetails) {
var listener = aAlertListener || (activeAlertNotifications[aDetails.id] ? activeAlertNotifications[aDetails.id].listener : undefined);
activeAppNotifications[aDetails.id] = {

View File

@ -8,17 +8,23 @@ var registrar = SpecialPowers.wrap(SpecialPowers.Components).manager.
QueryInterface(SpecialPowers.Ci.nsIComponentRegistrar);
var mockAlertsService = {
showAlert: function(alert, alertListener) {
// probably should do this async....
SpecialPowers.wrap(alertListener).observe(null, "alertshow", alert.cookie);
if (SpecialPowers.getBoolPref("notification.prompt.testing.click_on_notification") == true) {
SpecialPowers.wrap(alertListener).observe(null, "alertclickcallback", alert.cookie);
}
SpecialPowers.wrap(alertListener).observe(null, "alertfinished", alert.cookie);
},
showAlertNotification: function(imageUrl, title, text, textClickable,
cookie, alertListener, name, bidi,
lang, data) {
// probably should do this async....
SpecialPowers.wrap(alertListener).observe(null, "alertshow", cookie);
if (SpecialPowers.getBoolPref("notification.prompt.testing.click_on_notification") == true) {
SpecialPowers.wrap(alertListener).observe(null, "alertclickcallback", cookie);
}
SpecialPowers.wrap(alertListener).observe(null, "alertfinished", cookie);
return this.showAlert({
cookie: cookie
}, alertListener);
},
showAppNotification: function(imageUrl, title, text, alertListener, details) {

View File

@ -23,15 +23,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=782211
const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1";
var mockAlertsService = {
showAlertNotification: function(imageUrl, title, text, textClickable,
cookie, alertListener, name, dir,
lang, data) {
notificationsCreated.push(name);
showAlert: function(alert, alertListener) {
notificationsCreated.push(alert.name);
if (notificationsCreated.length == 3) {
checkNotifications();
}
},
showAlertNotification: function(imageUrl, title, text, textClickable,
cookie, alertListener, name, dir,
lang, data) {
this.showAlert({ name: name });
},
QueryInterface: function(aIID) {
if (SpecialPowers.wrap(aIID).equals(SpecialPowers.Ci.nsISupports) ||
SpecialPowers.wrap(aIID).equals(SpecialPowers.Ci.nsIAlertsService)) {

View File

@ -23,13 +23,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=874090
const ALERTS_SERVICE_CONTRACT_ID = "@mozilla.org/alerts-service;1";
var mockAlertsService = {
showAlertNotification: function(imageUrl, title, text, textClickable,
cookie, alertListener, name, dir, lang, data) {
ok(true, "System principal was granted permission and is able to call showAlertNotification.");
showAlert: function(alert, alertListener) {
ok(true, "System principal was granted permission and is able to call showAlert.");
unregisterMock();
SimpleTest.finish();
},
showAlertNotification: function(imageUrl, title, text, textClickable,
cookie, alertListener, name, dir, lang, data) {
this.showAlert();
},
QueryInterface: function(aIID) {
if (aIID.equals(Components.interfaces.nsISupports) ||
aIID.equals(Components.interfaces.nsIAlertsService)) {

View File

@ -117,6 +117,9 @@ var AlertsService = {
"", ALERTS_SERVICE_CONTRACT_ID, null);
},
showAlert: function() {
},
showAlertNotification: function() {
},
};