Bug 16743
Summary: | Acid3 expects NodeIterator.nextNode to forward exceptions from the filter | ||
---|---|---|---|
Product: | WebKit | Reporter: | Eric Seidel (no email) <eric> |
Component: | DOM | Assignee: | Darin Adler <darin> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Normal | CC: | cdumez, darin, ggaren, ian, mjs, sam |
Priority: | P2 | ||
Version: | 528+ (Nightly build) | ||
Hardware: | Mac | ||
OS: | OS X 10.4 | ||
Bug Depends on: | |||
Bug Blocks: | 16744 |
Eric Seidel (no email)
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Darin Adler
Our traversal functions are so broken, this is only the tip of the iceberg. But it's straightforward to fix.
Eric Seidel (no email)
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
(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
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
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
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
*** This bug has been marked as a duplicate of 4714 ***
Ian 'Hixie' Hickson
I tried to fix the test, let me know if i missed something.
Thanks for the help.
Lucas Forschler
Mass moving XML DOM bugs to the "DOM" Component.