зеркало из https://github.com/mozilla/pjs.git
Bug 487541 - form submission caused exception 0x80004002 (NS_NOINTERFACE) [nsISupports.QueryInterface]
Get rid of the QueryInterface and just use instanceof while copying the logic of nsFormHistory::Notify to avoid divergent logic until satchel provides a notification.
This commit is contained in:
Родитель
9372000a56
Коммит
cd2b9e8150
|
@ -227,22 +227,68 @@ FormTracker.prototype = {
|
|||
notify: function FormTracker_notify(formElement, aWindow, actionURI) {
|
||||
if (this.ignoreAll)
|
||||
return;
|
||||
|
||||
|
||||
this._log.trace("Form submission notification for " + actionURI.spec);
|
||||
|
||||
|
||||
// XXX Bug 487541 Copy the logic from nsFormHistory::Notify to avoid
|
||||
// divergent logic, which can lead to security issues, until there's a
|
||||
// better way to get satchel's results like with a notification.
|
||||
|
||||
// Determine if a dom node has the autocomplete attribute set to "off"
|
||||
let completeOff = function(domNode) {
|
||||
let autocomplete = domNode.getAttribute("autocomplete");
|
||||
return autocomplete && autocomplete.search(/^off$/i) == 0;
|
||||
}
|
||||
|
||||
if (completeOff(formElement)) {
|
||||
this._log.trace("Form autocomplete set to off");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get number of elements in form, add points and changedIDs */
|
||||
let len = formElement.length;
|
||||
let elements = formElement.elements;
|
||||
for (let i = 0; i < len; i++) {
|
||||
let element = elements.item(i);
|
||||
let inputElement = element.QueryInterface(Ci.nsIDOMHTMLInputElement);
|
||||
|
||||
if (inputElement && inputElement.type == "text") {
|
||||
this._log.trace("Logging form element: " + inputElement.name + "::" +
|
||||
inputElement.value);
|
||||
this.addChangedID(Utils.sha1(inputElement.name + inputElement.value));
|
||||
this._score += 10;
|
||||
let el = elements.item(i);
|
||||
|
||||
// Grab the name for debugging, but check if empty when satchel would
|
||||
let name = el.name;
|
||||
if (name === "")
|
||||
name = el.id;
|
||||
|
||||
if (!(el instanceof Ci.nsIDOMHTMLInputElement)) {
|
||||
this._log.trace(name + " is not a DOMHTMLInputElement: " + el);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (el.type.search(/^text$/i) != 0) {
|
||||
this._log.trace(name + "'s type is not 'text': " + el.type);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (completeOff(el)) {
|
||||
this._log.trace(name + "'s autocomplete set to off");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (el.value === "") {
|
||||
this._log.trace(name + "'s value is empty");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (el.value == el.defaultValue) {
|
||||
this._log.trace(name + "'s value is the default");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (name === "") {
|
||||
this._log.trace("Text input element has no name or id");
|
||||
continue;
|
||||
}
|
||||
|
||||
this._log.trace("Logging form element: " + name + " :: " + el.value);
|
||||
this.addChangedID(Utils.sha1(name + el.value));
|
||||
this._score += 10;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -32,6 +32,7 @@ pref("extensions.weave.log.logger.service.main", "Trace");
|
|||
pref("extensions.weave.log.logger.async", "Debug");
|
||||
pref("extensions.weave.log.logger.network.resources", "Debug");
|
||||
pref("extensions.weave.log.logger.engine.bookmarks", "Debug");
|
||||
pref("extensions.weave.log.logger.engine.forms", "Debug");
|
||||
pref("extensions.weave.log.logger.engine.history", "Debug");
|
||||
pref("extensions.weave.log.logger.engine.tabs", "Debug");
|
||||
pref("extensions.weave.log.logger.engine.clients", "Debug");
|
||||
|
|
Загрузка…
Ссылка в новой задаче