[webkit-reviews] review granted: [Bug 22365] Add a test to verify the results of DOM constructors : [Attachment 25288] New test + result
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Thu Nov 20 09:44:25 PST 2008
Sam Weinig <sam at webkit.org> has granted Pam Greene <pam at chromium.org>'s request
for review:
Bug 22365: Add a test to verify the results of DOM constructors
https://bugs.webkit.org/show_bug.cgi?id=22365
Attachment 25288: New test + result
https://bugs.webkit.org/attachment.cgi?id=25288&action=review
------- Additional Comments from Sam Weinig <sam at webkit.org>
> +
> +// These nodes have a working constructor.
> +var nodes_constructor = [
> + 'DOMParser',
> + 'XMLHttpRequest', 'XMLSerializer',
> + 'XPathEvaluator',
> + 'XSLTProcessor'
> +];
You are missing Audio, Option, Image, Worker, and MessageChannel here.
> +
> +// These nodes have no constructor.
> +var nodes_no_constructor = [
> + 'EventTargetNode',
> + 'BarInfo', 'CanvasGradient',
> + 'CanvasPattern', 'Console',
> + 'DOMSelection', 'DOMWindow', 'History',
> + 'UndetectableHTMLCollection',
I don't think this is a real class in WebCore. We do have class called
HTMLAllCollection which is undetectable though. Perhaps that is what you were
thinking of.
> + 'HTMLOptionsCollection', 'InspectorController',
> + 'Location',
> + 'Navigator',
> + 'NodeIterator',
> + 'RGBColor', 'Screen',
> + 'TreeWalker',
> + 'XPathExpression', 'XPathNSResolver',
> + 'EventTarget', 'EventListener',
> + 'NPObject'
> +];
Some of these should probably have constructors (of the non-constructible
variety), but I guess it is good to test our current behavior.
> +
> +function TryAllocate(node) {
> + var Cons = this[node];
> + if (!Cons) return 'no constructor';
> + try { return new Cons(); }
> + catch (e) { return 'exception'; }
> +}
> +
> +function check(name, expected) {
> + actual = TryAllocate(node);
> + if (actual == expected)
> + document.write("PASS: " + name + " '" + expected + "'<br>");
> + else
> + document.write("FAIL: " + name + " wanted '" + expected + "', got '" +
actual + "'<br>");
> +}
> +
> +
> +for (var i = 0; i < nodes_exception.length; i++) {
> + var node = nodes_exception[i];
> + check(node, 'exception');
> +}
> +
> +for (var i = 0; i < nodes_no_constructor.length; i++) {
> + var node = nodes_no_constructor[i];
> + check(node, 'no constructor');
> +}
> +
> +for (var i = 0; i < nodes_constructor.length; i++) {
> + var node = nodes_constructor[i];
> + check(node, '[object ' + node + ']');
> +}
In general, we like to keep all code in the WebKit style guidelines, even
tests, which mean 4 space indentation.
r=me with those changes.
More information about the webkit-reviews
mailing list