mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 610346 - Remove nsIFormSubmitObserver interface from FormTracker. r=rnewman
This commit is contained in:
parent
df75d1bef2
commit
4f2383e3f3
@ -209,7 +209,6 @@ FormTracker.prototype = {
|
||||
__proto__: Tracker.prototype,
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsIFormSubmitObserver,
|
||||
Ci.nsIObserver,
|
||||
Ci.nsISupportsWeakReference]),
|
||||
|
||||
@ -218,24 +217,13 @@ FormTracker.prototype = {
|
||||
switch (topic) {
|
||||
case "weave:engine:start-tracking":
|
||||
if (!this._enabled) {
|
||||
Svc.Obs.add("form-notifier", this);
|
||||
Svc.Obs.add("satchel-storage-changed", this);
|
||||
// HTMLFormElement doesn't use the normal observer/observe
|
||||
// pattern and looks up nsIFormSubmitObservers to .notify()
|
||||
// them so add manually to observers
|
||||
Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService)
|
||||
.addObserver(this, "earlyformsubmit", true);
|
||||
this._enabled = true;
|
||||
}
|
||||
break;
|
||||
case "weave:engine:stop-tracking":
|
||||
if (this._enabled) {
|
||||
Svc.Obs.remove("form-notifier", this);
|
||||
Svc.Obs.remove("satchel-storage-changed", this);
|
||||
Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService)
|
||||
.removeObserver(this, "earlyformsubmit");
|
||||
this._enabled = false;
|
||||
}
|
||||
break;
|
||||
@ -252,79 +240,4 @@ FormTracker.prototype = {
|
||||
this.addChangedID(guid);
|
||||
this.score += SCORE_INCREMENT_MEDIUM;
|
||||
},
|
||||
|
||||
notify: function (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 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;
|
||||
}
|
||||
|
||||
// Get the GUID on a delay so that it can be added to the DB first...
|
||||
Utils.nextTick(function() {
|
||||
this._log.trace("Logging form element: " + [name, el.value]);
|
||||
let guid = FormWrapper.getGUID(name, el.value);
|
||||
if (guid) {
|
||||
this.trackEntry(guid);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user