Skip to content

Commit

Permalink
Issue mozilla#86 - debug, openNotification improvements
Browse files Browse the repository at this point in the history
Addressed some comments
  • Loading branch information
xabolcs committed Sep 7, 2016
1 parent 32a43a9 commit a991c30
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 28 deletions.
29 changes: 19 additions & 10 deletions extension/chrome/content/browser.js
Expand Up @@ -42,26 +42,35 @@ openURL: function(url)
gBrowser.selectedTab = gBrowser.addTab(url);
},

openNotification: function(id, message, label, accessKey, callback) {
var action = {
label: label,
callback: callback,
accessKey: accessKey
openNotification: function(id, message, label, accessKey, callback, boxPlease) {
const TIMEOUT = 10000;
var action;
if (label && accessKey && callback) {
action = {
label: label,
callback: callback,
accessKey: accessKey
}
};
if (typeof PopupNotifications != "undefined") {

if (typeof PopupNotifications != "undefined" && !!!boxPlease) {
var options = {
timeout: Date.now() + 10000
timeout: Date.now() + TIMEOUT,
removeOnDismissal: true
};

PopupNotifications.show(gBrowser.selectedBrowser, id,
var notification = PopupNotifications.show(gBrowser.selectedBrowser, id,
message, "urlbar", action, null, options);

setTimeout(function(){ notification.remove(); }, TIMEOUT);
} else {
let nb = gBrowser.getNotificationBox();

nb.appendNotification(
var notification = nb.appendNotification(
message, id,
"chrome://nightly/content/brand/icon.png",
nb.PRIORITY_INFO_HIGH, [ action ]);
nb.PRIORITY_INFO_HIGH, action ? [ action ] : []);
setTimeout(function(){ nb.removeNotification(notification) }, TIMEOUT);
}
},

Expand Down
17 changes: 11 additions & 6 deletions extension/chrome/content/nightly.js
Expand Up @@ -221,13 +221,14 @@ copyTemplate: function(template) {
},

pastebin: function (content, onLoadCallback, onErrorCallback) {
const PASTEBIN_URL = "https://pastebin.mozilla.orfg/";

if (content === null || content === "" || content === undefined) {
onError("Not posting empty content!");
onError("No contents to post to " + PASTEBIN_URL);
return;
}
var postdata;
var request = new XMLHttpRequest();
request.open("POST", "https://pastebin.mozilla.org/", true);
request.open("POST", PASTEBIN_URL, true);

request.onreadystatechange = function() {
if (request.readyState == 4 ) {
Expand All @@ -237,6 +238,7 @@ pastebin: function (content, onLoadCallback, onErrorCallback) {
if (typeof onLoadCallback === "function") {
onLoadCallback();
}
console.log("pastebin done!");
}
};

Expand All @@ -248,15 +250,18 @@ pastebin: function (content, onLoadCallback, onErrorCallback) {
return;
}
if (typeof message !== "string") {
message = "An error occured while sending the request!";
console.log("onerror! this is a ProgressEvent! Now what?", message);
message = "Failed to submit data to " + PASTEBIN_URL + " !";
}
if (nightlyApp.openNotification) {
nightlyApp.openNotification("nightly-pastebin-error", message, null, null, null, /* boxPlease */ true);
}
Services.prompt.alert(null, "Nightly Tester Tools", message);
}

request.onabort = onError;
request.onerror = onError;

postdata = new FormData();
var postdata = new FormData();
postdata.append("code2", content);
postdata.append("expiry", "m");
postdata.append("format", "text");
Expand Down
29 changes: 19 additions & 10 deletions extension/chrome/content/suite.js
Expand Up @@ -155,26 +155,35 @@ getWindowTitleForNavigator: function () {
return newTitle;
},

openNotification: function(id, message, label, accessKey, callback) {
var action = {
label: label,
callback: callback,
accessKey: accessKey
openNotification: function(id, message, label, accessKey, callback, boxPlease) {
const TIMEOUT = 10000;
var action;
if (label && accessKey && callback) {
action = {
label: label,
callback: callback,
accessKey: accessKey
}
};
if (typeof PopupNotifications != "undefined") {

if (typeof PopupNotifications != "undefined" && !!!boxPlease) {
var options = {
timeout: Date.now() + 10000
timeout: Date.now() + TIMEOUT,
removeOnDismissal: true
};

PopupNotifications.show(gBrowser.selectedBrowser, id,
var notification = PopupNotifications.show(gBrowser.selectedBrowser, id,
message, "urlbar", action, null, options);

setTimeout(function(){ notification.remove(); }, TIMEOUT);
} else {
let nb = gBrowser.getNotificationBox();

nb.appendNotification(
var notification = nb.appendNotification(
message, id,
"chrome://nightly/content/brand/icon.png",
nb.PRIORITY_INFO_HIGH, [ action ]);
nb.PRIORITY_INFO_HIGH, action ? [ action ] : []);
setTimeout(function(){ nb.removeNotification(notification) }, TIMEOUT);
}
},

Expand Down
5 changes: 3 additions & 2 deletions extension/chrome/skin/browser.css
Expand Up @@ -10,10 +10,11 @@ toolbar[iconsize="small"] #nightly-tester-enter {
list-style-image: url("chrome://nightly/skin/idsmall.png");
}

.popup-notification-icon[popupid="nightly-compatibility-restart"] {
.popup-notification-icon[popupid="nightly-compatibility-restart"],
.popup-notification-icon[popupid="nightly-pastebin-error"] {
list-style-image: url("chrome://nightly/content/brand/logo.png");
}

#nightly-aboutsupport[loading="true"] {
list-style-image: url("chrome://global/skin/icons/loading_16.png") !important;
list-style-image: url("chrome://global/skin/icons/loading.png") !important;
}

0 comments on commit a991c30

Please sign in to comment.