Closed Bug 642153 Opened 15 years ago Closed 15 years ago

Validator: Flag DOM mutation events as warnings for their extreme inefficiency

Categories

(addons.mozilla.org Graveyard :: Admin/Editor Tools, defect, P3)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: kmag, Assigned: basta)

Details

(Whiteboard: [ReviewTeam])

Attachments

(1 file)

User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:2.0b13pre) Gecko/20110310 Firefox/4.0b13pre Build Identifier: I think it would be a good idea to warn unwary developers that using DOM Mutation events are extremely inefficient. They have some uses, but some developers see no issue with inserting them into every page for trivial purposes, which is an extremely bad idea. Reproducible: Always
Agreed. Kris, can you list the events that should be flagged?
Assignee: nobody → mbasta
Severity: normal → minor
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P3
Whiteboard: [required amo-editors]
Target Milestone: --- → 6.0.3
Sure, I just didn't want to go to the trouble if we weren't going to do this. Any of the events marked deprecated here would be a candidate: http://www.w3.org/TR/DOM-Level-3-Events/ But in particular: DOMAttrModified, DOMAttributeNameChanged, DOMCharacterDataModified, DOMElementNameChanged, DOMNodeInserted, DOMNodeInsertedIntoDocument, DOMNodeRemoved, DOMNodeRemovedFromDocument, DOMSubtreeModified I'm not sure whether we should flag calls to addEventListener or just the presence of those strings.
I can mark these as flagged identifiers. If these are pretty uncommon anyway (or shouldn't be used), then there likely won't be too much noise.
Check it out: https://github.com/mattbasta/amo-validator/commit/4e2839d861bcbf8d5b7f8aadfb2dbcdce0cbcbf6 Will create a pull request as soon as the innerHTML stuff goes through.
Sorry, I missed comment 3. I don't think adding these to the banned identifier list because they're strings passed to addEventListener rather than strings. They also apparently work as on* attributes (but not on* properties, as far as I can tell).
> strings passed to addEventListener rather than strings. Come again?
Heh... elem.addEventListener("DOMSubtreeModified", onDOMSubtreeModified, false); elem.setAttribute("onDOMSubtreeModified", "doStuff(event)") <elem onDOMSubtreeModified="doStuff(event)"/> Sorry for the typo. I meant "rather than identifiers".
Ah, then this is going to end up as a lovely regex test. Will do soon.
Target Milestone: 6.0.3 → 6.0.4
Target Milestone: 6.0.4 → 6.0.6
Pushed to mozilla/amo-validator
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
Kris/ Jorgev, can you verify? Thanks!
It doesn't work on preview. https://addons.allizom.org/en-US/developers/addon/the-official-diego-torres-add-/file/114505/validation In overlay.js: cl.addEventListener('DOMSubtreeModified', function (e) {
Attached file Failing XPI
Agreed, this doesn't seem to work on allizom or from git. overlay.js and overlay.xul should trigger warnings in the attached XPI.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Target Milestone: 6.0.6 → 6.0.7
I'm seeing the errors being reported: Warning: DOM Mutation Events Prohibited DOM mutation events are flagged because of their deprecated status, as well as their extreme inefficiency. Consider using a different event. Tier: 3 File: content/overlay.js Line: 10 Context: > document.addEventListener('DOMNodeRemovedFromDocument', function () {}, false); > document.addEventListener('DOMSubtreeModified', function () {}, false); > Can you confirm that you have the latest version from git? Also, make sure you're using the --determined flag.
The JS errors are showing up for me with the latest pull now (they weren't at the time of my last comment), but still not the on* attributes.
Target Milestone: 6.0.7 → 6.0.8
Ah, didn't realize that those existed. They're added now, if someone could look over the code: https://github.com/mozilla/amo-validator/pull/23
Status: REOPENED → RESOLVED
Closed: 15 years ago15 years ago
Resolution: --- → FIXED
Reclassifying editor bugs and changing to a new whiteboard flag. Spam, spam, spam, spam...
Whiteboard: [required amo-editors] → [ReviewTeam]
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: