The current version of TinyMCE (http://tinymce.moxiecode.com/) uses createTextRange in IE and createTreeWalker (http://www.w3.org/TR/DOM-Level-2-Traversal-Range/traversal.html) in Gecko browsers. Neither of these functions work in HtmlUnit. It seems that none of the optional DOM Level 2 Traversal feature is supported in HtmlUnit right now, and I'm not sure what the status of IE support is (besides the fact that createTextRange doesn't work). It would be nice if these features could be implemented so that HtmlUnit could be used to test sites with TinyMCE.
I might be able to look at implementing one or both of these in the future, but was wondering what the current status is or if anybody else is working on supporting TinyMCE.
Logged In: YES
user_id=1109422
Originator: NO
I don't think anyone is working on this, though I believe it has come up once or twice in the user lists (I'm sure I'll be corrected if I'm wrong). Feel free to contribute a patch (be sure to read http://htmlunit.sourceforge.net/submittingPatches.html and http://htmlunit.sourceforge.net/codingConventions.html).
Patch adding createTreeWalker support to htmlunit.
Logged In: YES
user_id=2182041
Originator: YES
File Added: treewalkersupport.patch
Logged In: YES
user_id=2182041
Originator: YES
i have added a patch which implements TreeWalker support for htmlunit. there are some unit tests written (of course more tests is always better). please critique this implementation - the one detail which I am a bit concerned about is the addition of the private staticGetPrototype method in HTMLDocument, which is used by jsxFunction_createTreeWalker. was not sure how else to handle this. the tests i've written all pass, and tinymce no longer complains (at least when htmlunit is simulating firefox).
Impressive patch with many tests what's really good... but the results you expect from HtmlUnit are not the ones I get in my Firefox (no matter if 2 or 3) for 7 of the 17 tests. Can you check that?
Btw: do you belong to TinyMCE team?
thanks for the feedback! is there an easy way to run the tests against FF instead of htmlunit? i tried to check them as i wrote them by manually typing them into the firebug console but apparently i missed something with that method.
no i don't belong to the TinyMCE team - i work for 10gen, an open-source cloud computing company. we are trying to test some sites running on our platform that use TinyMCE.
Currently the best way is to use following VM argument:
-Dcom.gargoylesoftware.htmlunit.WebTestCase.GenerateTestpages=true
then createTestPageForRealBrowserIfNeeded will create html files that can be opened directly in FF and that will tell you if the expectation are correct. If you activate the info log level this will look like:
INFO 14:18:23,525 WebTestCase: Test file written: /tmp/TEST_57790.html
so it looks like those tests are failing because of the additional html that is injected into the generated FF tests. TreeWalker is walking around the DOM, but the DOM is different for the generated testpages than for the test pages that are being run in the htmlunit tests. this accounts for 5 of the 7 mismatches. i think the other 2 are for the two test cases that expect exceptions. for both of these tests FF does throw an exception (at least FF 3 where i'm testing this). not sure why this isn't being reported as matching the expectation.
hmm, you're right, the instrumentation is problematic for these tests.
Nevertheless I could see there are at least problems with the constant values. For instance in testGetter2, my FF doesn't give -1 as third alert but 4294967295. Additionally testEmpty throws a JS error in my FF.
Fix one of the tests so the expected results work in FF.
you're right - i have attached another revision of the patch fixing the -1 vs 4294967295 problem in FF. testEmptyFilter is one of the tests i was talking about - it is supposed to throw an exception. that's why i gave it a @Test(expected = ScriptException.class). is there something else i need to do to get it to expect the exception for the FF tests?
File Added: treewalkersupport2.patch
Patch applied. Thanks.
Impressive patch, is createNodeIterator() in the queue? ;)
thanks! heh - sure I can add it to the queue. the queue is rather long right now though, so it could be a while before this gets anywhere.