Closed Bug 715994 Opened 14 years ago Closed 14 years ago

TreeWalker and NodeIterator not working in a page-mod content script

Categories

(Add-on SDK Graveyard :: General, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: cameronmartin123, Assigned: ejpbruel)

Details

From a page-mod content script, I cannot use TreeWalker or NodeIterator to traverse the DOM. Here is an example content script: http://pastebin.com/xHyrPaWN worker.nextNode() should move the pointer forward and return the current node, but it does neither. Using unsafeWindow to bypass XPCNativeWrapper doesn't change the result. I get the same result using NodeIterator, too.
OS: Mac OS X → All
Hardware: x86_64 → All
Hmm, I'm having trouble reproducing this problem. I created a simple addon that instantiates a page mod with your example content script and applies to .org domains, then I opened http://melez.org/ in a tab, and the content script logged the following messages to the console: info: [object HTMLBodyElement] ---------- info: [object Text] ---------- info: [object Text] Here's the addon I used to test: https://builder.addons.mozilla.org/addon/1003383/latest/ Do you see the same behavior when you test that addon?
Just for the record, what version of the SDK are you using to test this, Cameron?
When running Myk's Addon, I still get the same result: info: [object HTMLBodyElement] -------- info: null -------- info: [object HTMLBodyElement] I'm using SDK version 1.3 with firefox 9.0.1 on OSX. TreeWalkers do work in normal web pages for me, so this is definitely a problem specific to the Addon SDK.
I also tried this on Firefox 9.0.1 on Ubuntu and I got the same result.
Interesting! I tested on 9.0.1 and got the same results as Cameron. I tested also on Aurora and got the same results as Myk. It seems like nothing is being returned by: worker.nextNode() ...on Firefox 9. The MDN docs are regrettably sparse on Treewalker, with no docs on nextNode() and only this suggested form on the createTreeWalker page: while(treeWalker.nextNode()) nodeList.push(treeWalker.currentNode);
@Jeff: in Firefox 9.0.1, does worker.nextNode() move the pointer forward? Do you see correct behaviour when using TreeWalker outside of the addon SDK? Here's the W3C spec http://www.w3.org/TR/DOM-Level-2-Traversal-Range/traversal.html
@Cameron: very odd, I'm starting to think this is a Firefox bug in 9.0.1. I tweaked the example a little bit: https://builder.addons.mozilla.org/addon/1032874/latest/ If I compare the behaviour of this code on 9 vs Aurora ( 11 ), they totally different: Firefox 9: info: [] Aurora: info: [ "first", "second", "third" ] Also, if I paste the code from my version of mod.js into the scratchpad editor on Firefox 9.0.1 and run it, I get the expected output: [ "first", "second", "third" ] I'll talk to the team about this tomorrow if I get some time, or failing that the Jetpack weekly meeting on Tuesday.
Also, Eddy and Mossop
I get the same results as you Jeff. Have you got any updates from the meeting on Tuesday?
Cameron: no, but that's my fault because my connection was so bad I wasn't able to participate.
Assignee: nobody → ejpbruel
Has anyone seen what this does on Firefox beta?
Whiteboard: [triage:followup]
I get the correct behaviour in Firefox Beta. Has anyone had any luck discovering why this bug occurs? And has anyone tried this on Firefox 8?
Since Firefox 10 is coming out a week from Tuesday, there's not a lot we can do before then.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → WORKSFORME
Whiteboard: [triage:followup]
You need to log in before you can comment on or make changes to this bug.