Commit 15407560 authored by Vivien Nicolas's avatar Vivien Nicolas
Browse files

Bug 637779 - Typing in the search field in about:config will give an Error:...

Bug 637779 - Typing in the search field in about:config will give an Error: element is undefined in forms.js line 533 [r=mfinkle]
parent 1d4376c7
...@@ -329,6 +329,11 @@ FormAssistant.prototype = { ...@@ -329,6 +329,11 @@ FormAssistant.prototype = {
// key processing inside a select element are done during the keypress // key processing inside a select element are done during the keypress
// handler, preventing this one to be fired cancel the selection change // handler, preventing this one to be fired cancel the selection change
case "keypress": case "keypress":
// There is no need to handle keys if there is not element currently
// used by the form assistant
if (!currentElement)
return;
let formExceptions = { button: true, checkbox: true, file: true, image: true, radio: true, reset: true, submit: true }; let formExceptions = { button: true, checkbox: true, file: true, image: true, radio: true, reset: true, submit: true };
if (this._isSelectElement(currentElement) || formExceptions[currentElement.type] || if (this._isSelectElement(currentElement) || formExceptions[currentElement.type] ||
currentElement instanceof HTMLButtonElement || (currentElement.getAttribute("role") == "button" && currentElement.hasAttribute("tabindex"))) { currentElement instanceof HTMLButtonElement || (currentElement.getAttribute("role") == "button" && currentElement.hasAttribute("tabindex"))) {
...@@ -353,6 +358,11 @@ FormAssistant.prototype = { ...@@ -353,6 +358,11 @@ FormAssistant.prototype = {
break; break;
case "keyup": case "keyup":
// There is no need to handle keys if there is not element currently
// used by the form assistant
if (!currentElement)
return;
switch (aEvent.keyCode) { switch (aEvent.keyCode) {
case aEvent.DOM_VK_DOWN: case aEvent.DOM_VK_DOWN:
if (currentElement instanceof HTMLInputElement && !this._isAutocomplete(currentElement)) { if (currentElement instanceof HTMLInputElement && !this._isAutocomplete(currentElement)) {
...@@ -396,7 +406,7 @@ FormAssistant.prototype = { ...@@ -396,7 +406,7 @@ FormAssistant.prototype = {
default: default:
if (this._isAutocomplete(aEvent.target)) if (this._isAutocomplete(aEvent.target))
sendAsyncMessage("FormAssist:AutoComplete", this._getJSON()); sendAsyncMessage("FormAssist:AutoComplete", this._getJSON());
else if (this._isSelectElement(currentElement)) else if (currentElement && this._isSelectElement(currentElement))
this.currentIndex = this.currentIndex; this.currentIndex = this.currentIndex;
break; break;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment