Bug 742191 - Part b: Update testharness.js and friends; r=Aryeh

This commit is contained in:
Ms2ger 2012-10-14 09:46:57 +02:00
Родитель fecd660b2f
Коммит 53e642872f
5 изменённых файлов: 171 добавлений и 47 удалений

Просмотреть файл

@ -2,6 +2,12 @@
"Selection interface: existence and properties of interface object":true,
"Selection interface: existence and properties of interface prototype object":true,
"Selection interface: existence and properties of interface prototype object's \"constructor\" property":true,
"Selection interface: attribute anchorNode":true,
"Selection interface: attribute anchorOffset":true,
"Selection interface: attribute focusNode":true,
"Selection interface: attribute focusOffset":true,
"Selection interface: attribute isCollapsed":true,
"Selection interface: attribute rangeCount":true,
"Selection interface: calling collapse(Node,unsigned long) on getSelection() with too few arguments must throw TypeError":true,
"Selection interface: calling extend(Node,unsigned long) on getSelection() with too few arguments must throw TypeError":true,
"Selection interface: calling selectAllChildren(Node) on getSelection() with too few arguments must throw TypeError":true,

Просмотреть файл

@ -44,6 +44,7 @@
"Event interface: attribute bubbles": true,
"Event interface: attribute cancelable": true,
"Event interface: attribute defaultPrevented": true,
"Event interface: attribute isTrusted": true,
"Event interface: attribute timeStamp": true,
"Stringification of document.createEvent(\"Event\")": "debug",
"Event interface: document.createEvent(\"Event\") must inherit property \"timeStamp\" with the proper type (14)": true,
@ -55,10 +56,12 @@
"CustomEvent interface constructor": true,
"CustomEvent interface: existence and properties of interface prototype object": true,
"CustomEvent interface: existence and properties of interface prototype object's \"constructor\" property": true,
"CustomEvent interface: attribute detail": true,
"Stringification of new CustomEvent(\"foo\")": "debug",
"Event interface: new CustomEvent(\"foo\") must inherit property \"timeStamp\" with the proper type (14)": true,
"Event interface: calling initEvent(DOMString,boolean,boolean) on new CustomEvent(\"foo\") with too few arguments must throw TypeError": true,
"EventTarget interface: operation addEventListener(DOMString,EventListener,boolean)": true,
"EventTarget interface: operation removeEventListener(DOMString,EventListener,boolean)": true,
"EventListener interface: existence and properties of interface object": true,
"EventListener interface: existence and properties of interface prototype object": true,
"EventListener interface: existence and properties of interface prototype object's \"constructor\" property": true,
@ -218,6 +221,9 @@
"DocumentType interface: existence and properties of interface object": true,
"DocumentType interface: existence and properties of interface prototype object": true,
"DocumentType interface: existence and properties of interface prototype object's \"constructor\" property": true,
"DocumentType interface: attribute name": true,
"DocumentType interface: attribute publicId": true,
"DocumentType interface: attribute systemId": true,
"DocumentType interface: operation remove()": true,
"Stringification of document.doctype": "debug",
"DocumentType interface: document.doctype must inherit property \"remove\" with the proper type (3)": true,
@ -283,6 +289,7 @@
"Attr interface: existence and properties of interface object": true,
"Attr interface: existence and properties of interface prototype object": true,
"Attr interface: existence and properties of interface prototype object's \"constructor\" property": true,
"Attr interface: attribute name": true,
"Attr interface: attribute value": true,
"Attr interface: attribute namespaceURI": true,
"Attr interface: attribute prefix": true,
@ -302,6 +309,7 @@
"Text interface: existence and properties of interface object": true,
"Text interface: existence and properties of interface prototype object": true,
"Text interface: existence and properties of interface prototype object's \"constructor\" property": true,
"Text interface: attribute wholeText": true,
"Stringification of document.createTextNode(\"abc\")": "debug",
"Text interface: calling splitText(unsigned long) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: calling substringData(unsigned long,unsigned long) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
@ -326,6 +334,7 @@
"ProcessingInstruction interface: existence and properties of interface object": true,
"ProcessingInstruction interface: existence and properties of interface prototype object": true,
"ProcessingInstruction interface: existence and properties of interface prototype object's \"constructor\" property": true,
"ProcessingInstruction interface: attribute target": true,
"Stringification of xmlDoc.createProcessingInstruction(\"abc\", \"def\")": "debug",
"CharacterData interface: calling substringData(unsigned long,unsigned long) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
"CharacterData interface: calling appendData(DOMString) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
@ -411,10 +420,18 @@
"NodeIterator interface: existence and properties of interface object": true,
"NodeIterator interface: existence and properties of interface prototype object": true,
"NodeIterator interface: existence and properties of interface prototype object's \"constructor\" property": true,
"NodeIterator interface: attribute root": true,
"NodeIterator interface: attribute referenceNode": true,
"NodeIterator interface: attribute pointerBeforeReferenceNode": true,
"NodeIterator interface: attribute whatToShow": true,
"NodeIterator interface: attribute filter": true,
"Stringification of document.createNodeIterator(document.body, NodeFilter.SHOW_ALL, null, false)": "debug",
"TreeWalker interface: existence and properties of interface object": true,
"TreeWalker interface: existence and properties of interface prototype object": true,
"TreeWalker interface: existence and properties of interface prototype object's \"constructor\" property": true,
"TreeWalker interface: attribute root": true,
"TreeWalker interface: attribute whatToShow": true,
"TreeWalker interface: attribute filter": true,
"TreeWalker interface: attribute currentNode": true,
"Stringification of document.createTreeWalker(document.body, NodeFilter.SHOW_ALL, null, false)": "debug",
"NodeFilter interface: existence and properties of interface object": true,
@ -437,9 +454,13 @@
"NodeFilter interface: constant SHOW_DOCUMENT_FRAGMENT on interface prototype object": true,
"NodeFilter interface: constant SHOW_NOTATION on interface prototype object": true,
"NodeFilter interface: operation acceptNode(Node)": true,
"NodeList interface: attribute length": true,
"HTMLCollection interface: attribute length": true,
"DOMStringList interface: existence and properties of interface object": true,
"DOMStringList interface: existence and properties of interface prototype object": true,
"DOMStringList interface: existence and properties of interface prototype object's \"constructor\" property": true,
"DOMStringList interface: attribute length": true,
"Stringification of document.body.classList": true
"DOMTokenList interface: attribute length": true,
"Stringification of document.body.classList": true,
"DOMSettableTokenList interface: attribute value": true
}

Просмотреть файл

@ -1,10 +1,23 @@
{
"XMLHttpRequestUpload interface: existence and properties of interface prototype object": true,
"XMLHttpRequest interface constructor": true,
"XMLHttpRequest interface: existence and properties of interface prototype object": true,
"XMLHttpRequest interface: attribute onreadystatechange": true,
"XMLHttpRequest interface: attribute readyState": true,
"XMLHttpRequest interface: operation open(DOMString,DOMString,boolean,DOMString,DOMString)": true,
"XMLHttpRequest interface: attribute timeout": true,
"XMLHttpRequest interface: attribute withCredentials": true,
"XMLHttpRequest interface: attribute upload": true,
"XMLHttpRequest interface: operation send(union)": true,
"XMLHttpRequest interface: attribute status": true,
"XMLHttpRequest interface: attribute statusText": true,
"XMLHttpRequest interface: attribute response": true,
"XMLHttpRequest interface: attribute responseText": true,
"XMLHttpRequest interface: attribute responseXML": true,
"FormData interface: existence and properties of interface object": true,
"FormData interface constructor": true,
"FormData interface: existence and properties of interface prototype object": true,
"FormData interface: existence and properties of interface prototype object's \"constructor\" property": true,
"FormData interface: operation append(DOMString,Blob,DOMString)": true,
"Stringification of new FormData()": "debug",
"FormData interface: calling append(DOMString,Blob,DOMString) on new FormData() with too few arguments must throw TypeError": true,
"FormData interface: calling append(DOMString,DOMString) on new FormData() with too few arguments must throw TypeError": true,

Просмотреть файл

@ -361,17 +361,17 @@ IdlArray.prototype.assert_type_is = function(value, type)
if (type.sequence)
{
assert_true(Array.isArray(value), "is not array");
if (!type.idlType.length)
if (!value.length)
{
// Nothing we can do.
return;
}
type = type.idlType[0];
}
else
{
type = type.idlType;
this.assert_type_is(value[0], type.idlType.idlType);
return;
}
type = type.idlType;
switch(type)
{
case "void":
@ -563,8 +563,8 @@ IdlException.prototype.test_self = function()
//object."
//Note: This doesn't match browsers as of December 2011, see
//http://www.w3.org/Bugs/Public/show_bug.cgi?id=14813
assert_true(Function.prototype.isPrototypeOf(window[this.name]),
"prototype of window's property " + format_value(this.name) + " is not Function.prototype");
assert_equals(Object.getPrototypeOf(window[this.name]), Function.prototype,
"prototype of window's property " + format_value(this.name) + " is not Function.prototype");
//"Its [[Get]] internal property is set as described in ECMA-262
//section 15.3.5.4."
//Not much to test for this.
@ -577,8 +577,8 @@ IdlException.prototype.test_self = function()
//"Its [[Class]] internal property is “Function”."
//String() returns something implementation-dependent, because it calls
//Function#toString.
assert_equals({}.toString.call(window[this.name]), "[object Function]",
"{}.toString.call(" + this.name + ")");
assert_class_string(window[this.name], "Function",
"class string of " + this.name);
//TODO: Test 4.9.1.1. Exception interface object [[Call]] method (which
//does not match browsers: //http://www.w3.org/Bugs/Public/show_bug.cgi?id=14885)
@ -619,18 +619,19 @@ IdlException.prototype.test_self = function()
'should inherit from ' + inherit_exception + ', but window has no such property');
assert_own_property(window[inherit_exception], "prototype",
'should inherit from ' + inherit_exception + ', but that object has no "prototype" property');
assert_true(window[inherit_exception].prototype.isPrototypeOf(window[this.name].prototype),
'prototype of ' + this.name + '.prototype is not ' + inherit_exception + '.prototype');
assert_equals(Object.getPrototypeOf(window[this.name].prototype),
window[inherit_exception].prototype,
'prototype of ' + this.name + '.prototype is not ' + inherit_exception + '.prototype');
//"The class string of an exception interface prototype object is the
//concatenation of the exceptions identifier and the string
//“Prototype”."
//String() and {}.toString.call() should be equivalent, since nothing
//String() should end up calling {}.toString, since nothing
//defines a stringifier.
assert_equals({}.toString.call(window[this.name].prototype), "[object " + this.name + "Prototype]",
"{}.toString.call(" + this.name + ")");
assert_class_string(window[this.name].prototype, this.name + "Prototype",
"class string of " + this.name + ".prototype");
assert_equals(String(window[this.name].prototype), "[object " + this.name + "Prototype]",
"String(" + this.name + ")");
"String(" + this.name + ".prototype)");
}.bind(this), this.name + " exception: existence and properties of exception interface prototype object");
test(function()
@ -824,13 +825,14 @@ IdlException.prototype.test_object = function(desc)
//exception object must be the exception interface prototype object
//from the global environment the exception object is associated
//with."
assert_true(window[this.name].prototype.isPrototypeOf(obj),
desc + "'s prototype is not " + this.name + ".prototype");
assert_equals(Object.getPrototypeOf(obj),
window[this.name].prototype,
desc + "'s prototype is not " + this.name + ".prototype");
}
//"The class string of the exception object must be the identifier of
//the exception."
assert_equals({}.toString.call(obj), "[object " + this.name + "]", "{}.toString.call(" + desc + ")");
assert_class_string(obj, this.name, "class string of " + desc);
//Stringifier is not defined for DOMExceptions, because message isn't
//defined.
}.bind(this), this.name + " must be represented by " + desc);
@ -918,8 +920,8 @@ IdlInterface.prototype.test_self = function()
//object."
//Note: This doesn't match browsers as of December 2011, see
//http://www.w3.org/Bugs/Public/show_bug.cgi?id=14813
assert_true(Function.prototype.isPrototypeOf(window[this.name]),
"prototype of window's property " + format_value(this.name) + " is not Function.prototype");
assert_equals(Object.getPrototypeOf(window[this.name]), Function.prototype,
"prototype of window's property " + format_value(this.name) + " is not Function.prototype");
//"Its [[Get]] internal property is set as described in ECMA-262
//section 15.3.5.4."
//Not much to test for this.
@ -933,8 +935,7 @@ IdlInterface.prototype.test_self = function()
//"Its [[Class]] internal property is “Function”."
//String() returns something implementation-dependent, because it calls
//Function#toString.
assert_equals({}.toString.call(window[this.name]), "[object Function]",
"{}.toString.call(" + this.name + ")");
assert_class_string(window[this.name], "Function", "class string of " + this.name);
if (!this.has_extended_attribute("Constructor"))
{
@ -966,15 +967,20 @@ IdlInterface.prototype.test_self = function()
//attributes { [[Writable]]: false, [[Enumerable]]: false,
//[[Configurable]]: false } whose value is a Number determined as
//follows: . . .
//"Return the maximum argument list length of the constructors in
//the entries of S."
//"Return the length of the shortest argument list of the entries
//in S."
//TODO: Variadic constructors. Should generalize this so that it
//works for testing operation length too (currently we just don't
//support multiple operations with the same identifier).
var expected_length = this.extAttrs
.filter(function(attr) { return attr.name == "Constructor" })
.map(function(attr) { return attr.arguments ? attr.arguments.length : 0 })
.reduce(function(m, n) { return Math.max(m, n) });
.map(function(attr) {
return attr.arguments ? attr.arguments.filter(
function(arg) {
return !arg.optional;
}).length : 0
})
.reduce(function(m, n) { return Math.min(m, n) });
assert_own_property(window[this.name], "length");
assert_equals(window[this.name].length, expected_length, "wrong value for " + this.name + ".length");
var desc = Object.getOwnPropertyDescriptor(window[this.name], "length");
@ -1037,16 +1043,17 @@ IdlInterface.prototype.test_self = function()
'should inherit from ' + inherit_interface + ', but window has no such property');
assert_own_property(window[inherit_interface], "prototype",
'should inherit from ' + inherit_interface + ', but that object has no "prototype" property');
assert_true(window[inherit_interface].prototype.isPrototypeOf(window[this.name].prototype),
'prototype of ' + this.name + '.prototype is not ' + inherit_interface + '.prototype');
assert_equals(Object.getPrototypeOf(window[this.name].prototype),
window[inherit_interface].prototype,
'prototype of ' + this.name + '.prototype is not ' + inherit_interface + '.prototype');
//"The class string of an interface prototype object is the
//concatenation of the interfaces identifier and the string
//“Prototype”."
//String() and {}.toString.call() should be equivalent, since nothing
//String() should end up calling {}.toString, since nothing
//defines a stringifier.
assert_equals({}.toString.call(window[this.name].prototype), "[object " + this.name + "Prototype]",
"{}.toString.call(" + this.name + ".prototype)");
assert_class_string(window[this.name].prototype, this.name + "Prototype",
"class string of " + this.name + ".prototype");
assert_equals(String(window[this.name].prototype), "[object " + this.name + "Prototype]",
"String(" + this.name + ".prototype)");
}.bind(this), this.name + " interface: existence and properties of interface prototype object");
@ -1146,6 +1153,11 @@ IdlInterface.prototype.test_members = function()
assert_own_property(window[this.name], "prototype",
'interface "' + this.name + '" does not have own property "prototype"');
//TODO: Needs to test for LenientThis.
assert_throws(new TypeError(), function() {
window[this.name].prototype[member.name];
}.bind(this), "getting property on prototype object must throw TypeError");
do_interface_attribute_asserts(window[this.name].prototype, member);
}.bind(this), this.name + " interface: attribute " + member.name);
}
@ -1192,11 +1204,38 @@ IdlInterface.prototype.test_members = function()
//"The value of the Function objects “length” property is
//a Number determined as follows:
//". . .
//"Return the maximum argument list length of the functions
//in the entries of S."
//TODO: Does this work for overloads?
assert_equals(window[this.name].prototype[member.name].length, member.arguments.length,
//"Return the length of the shortest argument list of the
//entries in S."
//TODO: Doesn't handle overloading or variadic arguments.
assert_equals(window[this.name].prototype[member.name].length,
member.arguments.filter(function(arg) {
return !arg.optional;
}).length,
"property has wrong .length");
//Make some suitable arguments
var args = member.arguments.map(function(arg) {
return create_suitable_object(arg.type);
});
//"Let O be a value determined as follows:
//". . .
//"Otherwise, throw a TypeError."
//This should be hit if the operation is not static, there is
//no [ImplicitThis] attribute, and the this value is null.
//TODO: We currently ignore the static and [ImplicitThis]
//cases.
assert_throws(new TypeError(), function() {
window[this.name].prototype[member.name].apply(null, args);
}, "calling operation with this = null didn't throw TypeError");
//". . . If O is not null and is also not a platform object
//that implements interface I, throw a TypeError."
//TODO: Test a platform object that implements some other
//interface. (Have to be sure to get inheritance right.)
assert_throws(new TypeError(), function() {
window[this.name].prototype[member.name].apply({}, args);
}, "calling operation with this = {} didn't throw TypeError");
}.bind(this), this.name + " interface: operation " + member.name +
"(" + member.arguments.map(function(m) { return m.type.idlType; }) +
")");
@ -1269,8 +1308,9 @@ IdlInterface.prototype.test_primary_interface_of = function(desc, obj, exception
//"The value of the internal [[Prototype]] property of the platform
//object is the interface prototype object of the primary interface
//from the platform objects associated global environment."
assert_true(window[this.name].prototype.isPrototypeOf(obj),
desc + "'s prototype is not " + this.name + ".prototype");
assert_equals(Object.getPrototypeOf(obj),
window[this.name].prototype,
desc + "'s prototype is not " + this.name + ".prototype");
}.bind(this), this.name + " must be primary interface of " + desc);
}
@ -1281,7 +1321,7 @@ IdlInterface.prototype.test_primary_interface_of = function(desc, obj, exception
{
assert_equals(exception, null, "Unexpected exception when evaluating object");
assert_equals(typeof obj, expected_typeof, "wrong typeof object");
assert_equals({}.toString.call(obj), "[object " + this.name + "]", "{}.toString.call(" + desc + ")");
assert_class_string(obj, this.name, "class string of " + desc);
if (!this.members.some(function(member) { return member.stringifier || member.type == "stringifier"}))
{
assert_equals(String(obj), "[object " + this.name + "]", "String(" + desc + ")");
@ -1418,6 +1458,11 @@ function do_interface_attribute_asserts(obj, member)
//the Number value 0."
assert_equals(typeof desc.get, "function", "getter must be Function");
assert_equals(desc.get.length, 0, "getter length must be 0");
//TODO: Account for LenientThis
assert_throws(new TypeError(), function()
{
desc.get.call({});
}.bind(this), "calling getter on wrong object type must throw TypeError");
//TODO: Test calling setter on the interface prototype (should throw
//TypeError in most cases).

Просмотреть файл

@ -261,6 +261,10 @@ policies and contribution forms [3].
* assert_regexp_match(actual, expected, description)
* asserts that /actual/ matches the regexp /expected/
*
* assert_class_string(object, class_name, description)
* asserts that the class string of /object/ as returned in
* Object.prototype.toString is equal to /class_name/.
*
* assert_own_property(object, property_name, description)
* assert that object has own property property_name
*
@ -629,7 +633,7 @@ policies and contribution forms [3].
function assert_object_equals(actual, expected, description)
{
//This needs to be improved a great deal
function check_equal(expected, actual, stack)
function check_equal(actual, expected, stack)
{
stack.push(actual);
@ -715,6 +719,12 @@ policies and contribution forms [3].
}
expose(assert_regexp_match, "assert_regexp_match");
function assert_class_string(object, class_string, description) {
assert_equals({}.toString.call(object), "[object " + class_string + "]",
description);
}
expose(assert_class_string, "assert_class_string");
function _assert_own_property(name) {
return function(object, property_name, description)
@ -1291,6 +1301,16 @@ policies and contribution forms [3].
return;
}
this.phase = this.phases.COMPLETE;
var this_obj = this;
this.tests.forEach(
function(x)
{
if(x.status === x.NOTRUN)
{
this_obj.notify_result(x);
}
}
);
this.notify_complete();
};
@ -1400,11 +1420,22 @@ policies and contribution forms [3].
Output.prototype.resolve_log = function()
{
if (!this.output_document) {
var output_document;
if (typeof this.output_document === "function")
{
output_document = this.output_document.apply(undefined);
} else
{
output_document = this.output_document;
}
if (!output_document)
{
return;
}
var node = this.output_document.getElementById("log");
if (node) {
var node = output_document.getElementById("log");
if (node)
{
this.output_document = output_document;
this.output_node = node;
}
};
@ -1533,7 +1564,7 @@ policies and contribution forms [3].
if (!style_element && !input_element.checked) {
style_element = output_document.createElementNS(xhtml_ns, "style");
style_element.id = "hide-" + result_class;
style_element.innerHTML = "table#results > tbody > tr."+result_class+"{display:none}";
style_element.textContent = "table#results > tbody > tr."+result_class+"{display:none}";
output_document.body.appendChild(style_element);
} else if (style_element && input_element.checked) {
style_element.parentNode.removeChild(style_element);
@ -1593,7 +1624,15 @@ policies and contribution forms [3].
+ escape_html(tests[i].message ? tests[i].message : " ")
+ "</td></tr>";
}
log.lastChild.innerHTML = html + "</tbody></table>";
html += "</tbody></table>";
try {
log.lastChild.innerHTML = html;
} catch (e) {
log.appendChild(document.createElementNS(xhtml_ns, "p"))
.textContent = "Setting innerHTML for the log threw an exception.";
log.appendChild(document.createElementNS(xhtml_ns, "pre"))
.textContent = html;
}
};
var output = new Output();