Bug 1241436 - Update the "email me" checkbox in accordance with the email input field in the tab crash reporter. r=felipe
MozReview-Commit-ID: EnIe7NRwMes
--- a/browser/base/content/aboutTabCrashed.js
+++ b/browser/base/content/aboutTabCrashed.js
@@ -81,25 +81,32 @@ var AboutTabCrashed = {
case "DOMContentLoaded": {
this.onDOMContentLoaded();
break;
}
case "click": {
this.onClick(event);
break;
}
+ case "input": {
+ this.onInput(event);
+ break;
+ }
}
},
onDOMContentLoaded() {
this.CLICK_TARGETS.forEach((targetID) => {
let el = document.getElementById(targetID);
el.addEventListener("click", this);
});
+ // For setting "emailMe" checkbox automatically on email value change.
+ document.getElementById("email").addEventListener("input", this);
+
// Error pages are loaded as LOAD_BACKGROUND, so they don't get load events.
let event = new CustomEvent("AboutTabCrashedLoad", {bubbles:true});
document.dispatchEvent(event);
sendAsyncMessage("Load");
},
onClick(event) {
@@ -121,16 +128,24 @@ var AboutTabCrashed = {
case "sendReport": {
this.showCrashReportUI(event.target.checked);
break;
}
}
},
+ onInput(event) {
+ switch(event.target.id) {
+ case "email": {
+ document.getElementById("emailMe").checked = !!event.target.value;
+ break;
+ }
+ }
+ },
/**
* After this page tells the parent that it has loaded, the parent
* will respond with whether or not a crash report is available. This
* method handles that message.
*
* @param message
* The message from the parent, which should contain a data
* Object property with the following properties: