RESOLVED DUPLICATE of bug 4714 Bug 16743
Acid3 expects NodeIterator.nextNode to forward exceptions from the filter
https://bugs.webkit.org/show_bug.cgi?id=16743
Summary Acid3 expects NodeIterator.nextNode to forward exceptions from the filter
Eric Seidel (no email)
Reported 2008-01-05 13:58:32 PST
Test 5: FAIL (method [object NodeIterator].nextNode() didn't forward exception) // DOM Traversal function () { // test 5: NodeFilters and Exceptions var doc = getTestDocument(); var iteration = 0; var exception = "Roses"; var test = function(node) { iteration += 1; switch (iteration) { case 1, 3, 4, 6, 7, 8, 9, 12: throw exception; case 2, 5, 10, 11: return true; default: throw 0; }; }; var check = function(o, method) { var ok = false; try { o[method](); } catch (e) { if (e === exception) ok = true; } assert(ok, "method " + o + "." + method + "() didn't forward exception"); }; var i = doc.createNodeIterator(doc.documentElement, 0xFFFFFFFF, test, true); check(i, "nextNode"); // 1 assert(i.nextNode() == doc.documentElement, "i.nextNode() didn't return the right node"); // 2 check(i, "previousNode"); // 3 var w = document.createTreeWalker(doc.documentElement, 0xFFFFFFFF, test, true); check(w, "nextNode"); // 4 assert(w.nextNode() == doc.documentElement.firstChild, "w.nextNode() didn't return the right node"); // 5 check(w, "previousNode"); // 6 check(w, "firstChild"); // 7 check(w, "lastChild"); // 8 check(w, "nextSibling"); // 9 assert(w.previousSibling() == null, "w.previousSibling() didn't return the right node"); // 10 assert(w.nextSibling() == null, "w.nextSibling() didn't return the right node"); // 11 check(w, "previousSibling"); // 12 return 1; },
Attachments
Darin Adler
Comment 1 2008-01-06 13:25:44 PST
Our traversal functions are so broken, this is only the tip of the iceberg. But it's straightforward to fix.
Eric Seidel (no email)
Comment 2 2008-01-06 14:17:35 PST
If you'd like to check in a test case which demonstrates the total brokeness (with lots of FAILs), that's fine by me. :)
Darin Adler
Comment 3 2008-01-07 10:20:26 PST
(In reply to comment #2) > If you'd like to check in a test case which demonstrates the total brokeness > (with lots of FAILs), that's fine by me. :) Sure, I'll try to find the time to do that. In the past, I had decided it was pointless to worry about these rarely-used classes, which is why I didn't bother. The design is fairly tricky -- there are all sorts of edge cases because of the involvement of the filter function and the fact that it can manipulate the very tree its filtering, so writing a test is a bit challenging.
Darin Adler
Comment 4 2008-01-08 09:36:01 PST
This is an unusual requirement. There's nowhere else in the DOM where we expect exceptions to propagate through the DOM. This causes problems for the language-independent DOM -- it's not necessarily simple to propagate exceptions from any binding language through the DOM. Are we sure this is a requirement? It's not hard for me to implement, but I'm worried it's not the right thing to do.
Darin Adler
Comment 5 2008-01-08 10:30:08 PST
This code is incorrect JavaScript: switch (iteration) { case 1, 3, 4, 6, 7, 8, 9, 12: throw exception; case 2, 5, 10, 11: return true; default: throw 0; }; Those cases are only for the values 12 and 11. It needs to be changed to this: switch (iteration) { case 1: case 3: case 4: case 6: case 7: case 8: case 9: case 12: throw "Roses"; case 2: case 5: case 10: case 11: return true; default: throw 0; } CC'ing Hixie so he sees this.
Darin Adler
Comment 6 2008-01-08 10:43:24 PST
I found another error in the test: assert(w.previousSibling() == null, "w.previousSibling() didn't return the right node"); // 10 The above line will not call the filter, because there's no node to filter (it's null). So this does not increment the iteration count. I don't know what the contents of the test document are, so I'm not sure about the validity of the next two test steps. I had to change them for my test case.
Darin Adler
Comment 7 2008-01-08 13:04:08 PST
*** This bug has been marked as a duplicate of 4714 ***
Ian 'Hixie' Hickson
Comment 8 2008-01-08 19:49:26 PST
I tried to fix the test, let me know if i missed something. Thanks for the help.
Lucas Forschler
Comment 9 2019-02-06 09:02:54 PST
Mass moving XML DOM bugs to the "DOM" Component.
Note You need to log in before you can comment on or make changes to this bug.