Backed out changeset bf423f63b3a1 (bug 885107)

This commit is contained in:
Ed Morley 2013-07-18 14:43:19 +01:00
parent 01185cf81d
commit 496b5f94d7
5 changed files with 6134 additions and 1179 deletions

File diff suppressed because it is too large Load Diff

View File

@ -37,109 +37,109 @@
"Event interface: new CustomEvent(\"foo\") must have own property \"isTrusted\"": true,
"Event interface: new CustomEvent(\"foo\") must inherit property \"timeStamp\" with the proper type (15)": true,
"MutationObserver interface: operation observe(Node,MutationObserverInit)": true,
"Node interface: existence and properties of interface object": true,
"Document interface: existence and properties of interface object": true,
"Document interface: attribute children": true,
"Document interface: attribute firstElementChild": true,
"Document interface: attribute lastElementChild": true,
"Document interface: attribute childElementCount": true,
"Document interface: operation prepend([object Object],[object Object])": true,
"Document interface: operation append([object Object],[object Object])": true,
"XMLDocument interface: existence and properties of interface object": true,
"Document interface: operation prepend(union)": true,
"Document interface: operation append(union)": true,
"Document interface: xmlDoc must inherit property \"children\" with the proper type (24)": true,
"Document interface: xmlDoc must inherit property \"firstElementChild\" with the proper type (25)": true,
"Document interface: xmlDoc must inherit property \"lastElementChild\" with the proper type (26)": true,
"Document interface: xmlDoc must inherit property \"childElementCount\" with the proper type (27)": true,
"Document interface: xmlDoc must inherit property \"prepend\" with the proper type (28)": true,
"Document interface: calling prepend([object Object],[object Object]) on xmlDoc with too few arguments must throw TypeError": true,
"Document interface: calling prepend(union) on xmlDoc with too few arguments must throw TypeError": true,
"Document interface: xmlDoc must inherit property \"append\" with the proper type (29)": true,
"Document interface: calling append([object Object],[object Object]) on xmlDoc with too few arguments must throw TypeError": true,
"DocumentFragment interface: existence and properties of interface object": true,
"Document interface: calling append(union) on xmlDoc with too few arguments must throw TypeError": true,
"DocumentFragment interface: attribute children": true,
"DocumentFragment interface: attribute firstElementChild": true,
"DocumentFragment interface: attribute lastElementChild": true,
"DocumentFragment interface: attribute childElementCount": true,
"DocumentFragment interface: operation prepend([object Object],[object Object])": true,
"DocumentFragment interface: operation append([object Object],[object Object])": true,
"DocumentFragment interface: operation prepend(union)": true,
"DocumentFragment interface: operation append(union)": true,
"DocumentFragment interface: document.createDocumentFragment() must inherit property \"children\" with the proper type (0)": true,
"DocumentFragment interface: document.createDocumentFragment() must inherit property \"firstElementChild\" with the proper type (1)": true,
"DocumentFragment interface: document.createDocumentFragment() must inherit property \"lastElementChild\" with the proper type (2)": true,
"DocumentFragment interface: document.createDocumentFragment() must inherit property \"childElementCount\" with the proper type (3)": true,
"DocumentFragment interface: document.createDocumentFragment() must inherit property \"prepend\" with the proper type (4)": true,
"DocumentFragment interface: calling prepend([object Object],[object Object]) on document.createDocumentFragment() with too few arguments must throw TypeError": true,
"DocumentFragment interface: calling prepend(union) on document.createDocumentFragment() with too few arguments must throw TypeError": true,
"DocumentFragment interface: document.createDocumentFragment() must inherit property \"append\" with the proper type (5)": true,
"DocumentFragment interface: calling append([object Object],[object Object]) on document.createDocumentFragment() with too few arguments must throw TypeError": true,
"DocumentType interface: existence and properties of interface object": true,
"DocumentFragment interface: calling append(union) on document.createDocumentFragment() with too few arguments must throw TypeError": true,
"DocumentType interface: attribute previousElementSibling": true,
"DocumentType interface: attribute nextElementSibling": true,
"DocumentType interface: operation before([object Object],[object Object])": true,
"DocumentType interface: operation after([object Object],[object Object])": true,
"DocumentType interface: operation replace([object Object],[object Object])": true,
"DocumentType interface: operation before(union)": true,
"DocumentType interface: operation after(union)": true,
"DocumentType interface: operation replace(union)": true,
"DocumentType interface: document.doctype must inherit property \"previousElementSibling\" with the proper type (3)": true,
"DocumentType interface: document.doctype must inherit property \"nextElementSibling\" with the proper type (4)": true,
"DocumentType interface: document.doctype must inherit property \"before\" with the proper type (5)": true,
"DocumentType interface: calling before([object Object],[object Object]) on document.doctype with too few arguments must throw TypeError": true,
"DocumentType interface: calling before(union) on document.doctype with too few arguments must throw TypeError": true,
"DocumentType interface: document.doctype must inherit property \"after\" with the proper type (6)": true,
"DocumentType interface: calling after([object Object],[object Object]) on document.doctype with too few arguments must throw TypeError": true,
"DocumentType interface: calling after(union) on document.doctype with too few arguments must throw TypeError": true,
"DocumentType interface: document.doctype must inherit property \"replace\" with the proper type (7)": true,
"DocumentType interface: calling replace([object Object],[object Object]) on document.doctype with too few arguments must throw TypeError": true,
"Element interface: existence and properties of interface object": true,
"DocumentType interface: calling replace(union) on document.doctype with too few arguments must throw TypeError": true,
"Element interface: attribute namespaceURI": true,
"Element interface: attribute prefix": true,
"Element interface: attribute localName": true,
"Element interface: attribute className": true,
"Element interface: operation prepend([object Object],[object Object])": true,
"Element interface: operation append([object Object],[object Object])": true,
"Element interface: operation before([object Object],[object Object])": true,
"Element interface: operation after([object Object],[object Object])": true,
"Element interface: operation replace([object Object],[object Object])": true,
"Element interface: operation prepend(union)": true,
"Element interface: operation append(union)": true,
"Element interface: operation before(union)": true,
"Element interface: operation after(union)": true,
"Element interface: operation replace(union)": true,
"Element interface: element must inherit property \"className\" with the proper type (5)": true,
"Element interface: element must inherit property \"prepend\" with the proper type (23)": true,
"Element interface: calling prepend([object Object],[object Object]) on element with too few arguments must throw TypeError": true,
"Element interface: calling prepend(union) on element with too few arguments must throw TypeError": true,
"Element interface: element must inherit property \"append\" with the proper type (24)": true,
"Element interface: calling append([object Object],[object Object]) on element with too few arguments must throw TypeError": true,
"Element interface: calling append(union) on element with too few arguments must throw TypeError": true,
"Element interface: element must inherit property \"before\" with the proper type (27)": true,
"Element interface: calling before([object Object],[object Object]) on element with too few arguments must throw TypeError": true,
"Element interface: calling before(union) on element with too few arguments must throw TypeError": true,
"Element interface: element must inherit property \"after\" with the proper type (28)": true,
"Element interface: calling after([object Object],[object Object]) on element with too few arguments must throw TypeError": true,
"Element interface: calling after(union) on element with too few arguments must throw TypeError": true,
"Element interface: element must inherit property \"replace\" with the proper type (29)": true,
"Element interface: calling replace([object Object],[object Object]) on element with too few arguments must throw TypeError": true,
"Attr interface: existence and properties of interface object": true,
"Element interface: calling replace(union) on element with too few arguments must throw TypeError": true,
"Attr interface: existence and properties of interface prototype object": true,
"CharacterData interface: existence and properties of interface object": true,
"CharacterData interface: attribute previousElementSibling": true,
"CharacterData interface: attribute nextElementSibling": true,
"CharacterData interface: operation before([object Object],[object Object])": true,
"CharacterData interface: operation after([object Object],[object Object])": true,
"CharacterData interface: operation replace([object Object],[object Object])": true,
"Text interface: existence and properties of interface object": true,
"CharacterData interface: operation before(union)": true,
"CharacterData interface: operation after(union)": true,
"CharacterData interface: operation replace(union)": true,
"CharacterData interface: document.createTextNode(\"abc\") must inherit property \"previousElementSibling\" with the proper type (7)": true,
"CharacterData interface: document.createTextNode(\"abc\") must inherit property \"nextElementSibling\" with the proper type (8)": true,
"CharacterData interface: document.createTextNode(\"abc\") must inherit property \"before\" with the proper type (9)": true,
"CharacterData interface: calling before([object Object],[object Object]) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: calling before(union) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: document.createTextNode(\"abc\") must inherit property \"after\" with the proper type (10)": true,
"CharacterData interface: calling after([object Object],[object Object]) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: calling after(union) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: document.createTextNode(\"abc\") must inherit property \"replace\" with the proper type (11)": true,
"CharacterData interface: calling replace([object Object],[object Object]) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
"ProcessingInstruction interface: existence and properties of interface object": true,
"CharacterData interface: calling replace(union) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: xmlDoc.createProcessingInstruction(\"abc\", \"def\") must inherit property \"previousElementSibling\" with the proper type (7)": true,
"CharacterData interface: xmlDoc.createProcessingInstruction(\"abc\", \"def\") must inherit property \"nextElementSibling\" with the proper type (8)": true,
"CharacterData interface: xmlDoc.createProcessingInstruction(\"abc\", \"def\") must inherit property \"before\" with the proper type (9)": true,
"CharacterData interface: calling before([object Object],[object Object]) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
"CharacterData interface: calling before(union) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
"CharacterData interface: xmlDoc.createProcessingInstruction(\"abc\", \"def\") must inherit property \"after\" with the proper type (10)": true,
"CharacterData interface: calling after([object Object],[object Object]) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
"CharacterData interface: calling after(union) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
"CharacterData interface: xmlDoc.createProcessingInstruction(\"abc\", \"def\") must inherit property \"replace\" with the proper type (11)": true,
"CharacterData interface: calling replace([object Object],[object Object]) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
"Comment interface: existence and properties of interface object": true,
"CharacterData interface: calling replace(union) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
"CharacterData interface: document.createComment(\"abc\") must inherit property \"previousElementSibling\" with the proper type (7)": true,
"CharacterData interface: document.createComment(\"abc\") must inherit property \"nextElementSibling\" with the proper type (8)": true,
"CharacterData interface: document.createComment(\"abc\") must inherit property \"before\" with the proper type (9)": true,
"CharacterData interface: calling before([object Object],[object Object]) on document.createComment(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: calling before(union) on document.createComment(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: document.createComment(\"abc\") must inherit property \"after\" with the proper type (10)": true,
"CharacterData interface: calling after([object Object],[object Object]) on document.createComment(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: calling after(union) on document.createComment(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: document.createComment(\"abc\") must inherit property \"replace\" with the proper type (11)": true,
"CharacterData interface: calling replace([object Object],[object Object]) on document.createComment(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: calling replace(union) on document.createComment(\"abc\") with too few arguments must throw TypeError": true,
"Node interface: existence and properties of interface object": true,
"Document interface: existence and properties of interface object": true,
"XMLDocument interface: existence and properties of interface object": true,
"DocumentFragment interface: existence and properties of interface object": true,
"DocumentType interface: existence and properties of interface object": true,
"Element interface: existence and properties of interface object": true,
"Attr interface: existence and properties of interface object": true,
"CharacterData interface: existence and properties of interface object": true,
"Text interface: existence and properties of interface object": true,
"ProcessingInstruction interface: existence and properties of interface object": true,
"Comment interface: existence and properties of interface object": true,
"DOMSettableTokenList interface: existence and properties of interface object": true,
"NodeFilter interface: existence and properties of interface object": true,
"NodeList interface: existence and properties of interface prototype object": true,
"DOMSettableTokenList interface: existence and properties of interface object": true
"NodeList interface: existence and properties of interface prototype object": true
}

View File

@ -14,7 +14,7 @@ policies and contribution forms [3].
*
* <script src=/resources/testharness.js></script>
* <script src=/resources/testharnessreport.js></script>
* <script src=/resources/webidl2.js></script>
* <script src=/resources/WebIDLParser.js></script>
* <script src=/resources/idlharness.js></script>
*
* Then you'll need some type of IDLs. Here's some script that can be run on a
@ -170,16 +170,8 @@ policies and contribution forms [3].
* The members and methods of the classes defined by this file are all at least
* briefly documented, hopefully.
*/
(function(){
"use strict";
/// Helpers ///
function constValue (cnt) {
if (cnt.type === "null") return null;
if (cnt.type === "NaN") return NaN;
if (cnt.type === "Infinity") return cnt.negative ? -Infinity : Infinity;
return cnt.value;
}
(function(){
/// IdlArray ///
// Entry point
window.IdlArray = function()
@ -221,15 +213,15 @@ window.IdlArray = function()
* results in { A: ["B", "C"], D: ["E"] }.
*/
this.partials = [];
this["implements"] = {};
};
this.implements = {};
}
//@}
IdlArray.prototype.add_idls = function(raw_idls)
//@{
{
/** Entry point. See documentation at beginning of file. */
this.internal_add_idls(WebIDL2.parse(raw_idls));
this.internal_add_idls(WebIDLParser.parse(raw_idls));
};
//@}
@ -237,7 +229,7 @@ IdlArray.prototype.add_untested_idls = function(raw_idls)
//@{
{
/** Entry point. See documentation at beginning of file. */
var parsed_idls = WebIDL2.parse(raw_idls);
var parsed_idls = WebIDLParser.parse(raw_idls);
for (var i = 0; i < parsed_idls.length; i++)
{
parsed_idls[i].untested = true;
@ -250,7 +242,7 @@ IdlArray.prototype.add_untested_idls = function(raw_idls)
}
}
this.internal_add_idls(parsed_idls);
};
}
//@}
IdlArray.prototype.internal_add_idls = function(parsed_idls)
@ -266,7 +258,7 @@ IdlArray.prototype.internal_add_idls = function(parsed_idls)
*/
parsed_idls.forEach(function(parsed_idl)
{
if (parsed_idl.type == "interface" && parsed_idl.partial)
if (parsed_idl.type == "partialinterface")
{
this.partials.push(parsed_idl);
return;
@ -274,11 +266,11 @@ IdlArray.prototype.internal_add_idls = function(parsed_idls)
if (parsed_idl.type == "implements")
{
if (!(parsed_idl.target in this["implements"]))
if (!(parsed_idl.target in this.implements))
{
this["implements"][parsed_idl.target] = [];
this.implements[parsed_idl.target] = [];
}
this["implements"][parsed_idl.target].push(parsed_idl["implements"]);
this.implements[parsed_idl.target].push(parsed_idl.implements);
return;
}
@ -305,16 +297,10 @@ IdlArray.prototype.internal_add_idls = function(parsed_idls)
case "typedef":
// TODO
console.log("typedef not yet supported");
break;
case "callback":
// TODO
console.log("callback not yet supported");
break;
case "enum":
this.members[parsed_idl.name] = new IdlEnum(parsed_idl);
// TODO
break;
case "callback":
@ -325,7 +311,7 @@ IdlArray.prototype.internal_add_idls = function(parsed_idls)
throw parsed_idl.name + ": " + parsed_idl.type + " not yet supported";
}
}.bind(this));
};
}
//@}
IdlArray.prototype.add_objects = function(dict)
@ -343,7 +329,7 @@ IdlArray.prototype.add_objects = function(dict)
this.objects[k] = dict[k];
}
}
};
}
//@}
IdlArray.prototype.prevent_multiple_testing = function(name)
@ -351,7 +337,7 @@ IdlArray.prototype.prevent_multiple_testing = function(name)
{
/** Entry point. See documentation at beginning of file. */
this.members[name].prevent_multiple_testing = true;
};
}
//@}
IdlArray.prototype.recursively_get_implements = function(interface_name)
@ -367,12 +353,12 @@ IdlArray.prototype.recursively_get_implements = function(interface_name)
*
* then recursively_get_implements("A") should return ["B", "C", "D"].
*/
var ret = this["implements"][interface_name];
var ret = this.implements[interface_name];
if (ret === undefined)
{
return [];
}
for (var i = 0; i < this["implements"][interface_name].length; i++)
for (var i = 0; i < this.implements[interface_name].length; i++)
{
ret = ret.concat(this.recursively_get_implements(ret[i]));
if (ret.indexOf(ret[i]) != ret.lastIndexOf(ret[i]))
@ -381,7 +367,7 @@ IdlArray.prototype.recursively_get_implements = function(interface_name)
}
}
return ret;
};
}
//@}
IdlArray.prototype.test = function()
@ -412,22 +398,24 @@ IdlArray.prototype.test = function()
}.bind(this));
this.partials = [];
for (var lhs in this["implements"])
for (var lhs in this.implements)
{
this.recursively_get_implements(lhs).forEach(function(rhs)
{
var errStr = lhs + " implements " + rhs + ", but ";
if (!(lhs in this.members)) throw errStr + lhs + " is undefined.";
if (!(this.members[lhs] instanceof IdlInterface)) throw errStr + lhs + " is not an interface.";
if (!(rhs in this.members)) throw errStr + rhs + " is undefined.";
if (!(this.members[rhs] instanceof IdlInterface)) throw errStr + rhs + " is not an interface.";
if (!(lhs in this.members)
|| !(this.members[lhs] instanceof IdlInterface)
|| !(rhs in this.members)
|| !(this.members[rhs] instanceof IdlInterface))
{
throw lhs + " implements " + rhs + ", but one is undefined or not an interface";
}
this.members[rhs].members.forEach(function(member)
{
this.members[lhs].members.push(new IdlInterfaceMember(member));
}.bind(this));
}.bind(this));
}
this["implements"] = {};
this.implements = {};
// Now run test() on every member, and test_object() for every object.
for (var name in this.members)
@ -576,10 +564,6 @@ IdlArray.prototype.assert_type_is = function(value, type)
assert_true(value instanceof window[type], "not instanceof " + type);
}
}
else if (this.members[type] instanceof IdlEnum)
{
assert_equals(typeof value, "string");
}
else if (this.members[type] instanceof IdlDictionary)
{
// TODO: Test when we actually have something to test this on
@ -638,7 +622,10 @@ function IdlDictionary(obj)
* The name (as a string) of the dictionary type we inherit from, or null
* if there is none.
*/
this.base = obj.inheritance;
if (obj.inheritance.length > 1) {
throw "Multiple inheritance is no longer supported in WebIDL";
}
this.base = obj.inheritance.length ? obj.inheritance[0] : null;
}
//@}
@ -671,13 +658,16 @@ function IdlExceptionOrInterface(obj)
this.extAttrs = obj.extAttrs;
/** An array of IdlInterfaceMembers. */
this.members = obj.members.map(function(m){return new IdlInterfaceMember(m); });
this.members = obj.members.map(function(m){return new IdlInterfaceMember(m)});
/**
* The name (as a string) of the type we inherit from, or null if there is
* none.
*/
this.base = obj.inheritance;
if (obj.inheritance.length > 1) {
throw "Multiple inheritance is no longer supported in WebIDL";
}
this.base = obj.inheritance.length ? obj.inheritance[0] : null;
}
//@}
@ -707,7 +697,7 @@ IdlExceptionOrInterface.prototype.test = function()
// members will be marked as untested, but the members added by the partial
// interface are still tested.
this.test_members();
};
}
//@}
@ -861,7 +851,7 @@ IdlException.prototype.test_self = function()
assert_equals(window[this.name].prototype.constructor, window[this.name],
this.name + '.prototype.constructor is not the same object as ' + this.name);
}.bind(this), this.name + " exception: existence and properties of exception interface prototype object's \"constructor\" property");
};
}
//@}
IdlException.prototype.test_members = function()
@ -889,7 +879,7 @@ IdlException.prototype.test_members = function()
// "The value of the property is the ECMAScript value that is
// equivalent to the constants IDL value, according to the
// rules in section 4.2 above."
assert_equals(window[this.name][member.name], constValue(member.value),
assert_equals(window[this.name][member.name], eval(member.value),
"property has wrong value");
// "The property has attributes { [[Writable]]: false,
// [[Enumerable]]: true, [[Configurable]]: false }."
@ -910,7 +900,7 @@ IdlException.prototype.test_members = function()
'exception "' + this.name + '" does not have own property "prototype"');
assert_own_property(window[this.name].prototype, member.name);
assert_equals(window[this.name].prototype[member.name], constValue(member.value),
assert_equals(window[this.name].prototype[member.name], eval(member.value),
"property has wrong value");
var desc = Object.getOwnPropertyDescriptor(window[this.name].prototype, member.name);
assert_false("get" in desc, "property has getter");
@ -969,7 +959,7 @@ IdlException.prototype.test_members = function()
}.bind(this), this.name + " exception: field " + member.name + " on exception interface prototype object");
}
}
};
}
//@}
IdlException.prototype.test_object = function(desc)
@ -1029,7 +1019,7 @@ IdlException.prototype.test_object = function(desc)
assert_inherits(obj, member.name);
if (member.type == "const")
{
assert_equals(obj[member.name], constValue(member.value));
assert_equals(obj[member.name], eval(member.value));
}
if (member.type == "field")
{
@ -1037,7 +1027,7 @@ IdlException.prototype.test_object = function(desc)
}
}.bind(this), this.name + " exception: " + desc + ' must inherit property "' + member.name + '" with the proper type');
}
};
}
//@}
/// IdlInterface ///
@ -1047,7 +1037,7 @@ IdlInterface.prototype.is_callback = function()
//@{
{
return this.has_extended_attribute("Callback");
};
}
//@}
IdlInterface.prototype.has_constants = function()
@ -1056,7 +1046,7 @@ IdlInterface.prototype.has_constants = function()
return this.members.some(function(member) {
return member.type === "const";
});
};
}
//@}
IdlInterface.prototype.test_self = function()
@ -1160,14 +1150,14 @@ IdlInterface.prototype.test_self = function()
// 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"; })
.filter(function(attr) { return attr.name == "Constructor" })
.map(function(attr) {
return attr.arguments ? attr.arguments.filter(
function(arg) {
return !arg.optional;
}).length : 0;
}).length : 0
})
.reduce(function(m, n) { return Math.min(m, n); });
.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");
@ -1299,7 +1289,7 @@ IdlInterface.prototype.test_self = function()
assert_equals(window[this.name].prototype.constructor, window[this.name],
this.name + '.prototype.constructor is not the same object as ' + this.name);
}.bind(this), this.name + ' interface: existence and properties of interface prototype object\'s "constructor" property');
};
}
//@}
IdlInterface.prototype.test_members = function()
@ -1326,7 +1316,7 @@ IdlInterface.prototype.test_members = function()
// "The value of the property is that which is obtained by
// converting the constants IDL value to an ECMAScript
// value."
assert_equals(window[this.name][member.name], constValue(member.value),
assert_equals(window[this.name][member.name], eval(member.value),
"property has wrong value");
// "The property has attributes { [[Writable]]: false,
// [[Enumerable]]: true, [[Configurable]]: false }."
@ -1354,7 +1344,7 @@ IdlInterface.prototype.test_members = function()
'interface "' + this.name + '" does not have own property "prototype"');
assert_own_property(window[this.name].prototype, member.name);
assert_equals(window[this.name].prototype[member.name], constValue(member.value),
assert_equals(window[this.name].prototype[member.name], eval(member.value),
"property has wrong value");
var desc = Object.getOwnPropertyDescriptor(window[this.name], member.name);
assert_false("get" in desc, "property has getter");
@ -1377,9 +1367,6 @@ IdlInterface.prototype.test_members = function()
"window does not have own property " + format_value(this.name));
assert_own_property(window[this.name], "prototype",
'interface "' + this.name + '" does not have own property "prototype"');
assert_true(member.name in window[this.name].prototype,
"The prototype object must have a property " +
format_value(member.name));
// TODO: Needs to test for LenientThis.
assert_throws(new TypeError(), function() {
@ -1451,7 +1438,7 @@ IdlInterface.prototype.test_members = function()
// Make some suitable arguments
var args = member.arguments.map(function(arg) {
return create_suitable_object(arg.idlType);
return create_suitable_object(arg.type);
});
// "Let O be a value determined as follows:
@ -1475,12 +1462,12 @@ IdlInterface.prototype.test_members = 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.idlType.idlType; }) +
"(" + member.arguments.map(function(m) { return m.type.idlType; }) +
")");
}
// TODO: check more member types, like stringifier
}
};
}
//@}
IdlInterface.prototype.test_object = function(desc)
@ -1521,7 +1508,7 @@ IdlInterface.prototype.test_object = function(desc)
current_interface.test_interface_of(desc, obj, exception, expected_typeof);
current_interface = this.array.members[current_interface.base];
}
};
}
//@}
IdlInterface.prototype.test_primary_interface_of = function(desc, obj, exception, expected_typeof)
@ -1566,7 +1553,7 @@ IdlInterface.prototype.test_primary_interface_of = function(desc, obj, exception
assert_equals(String(obj), "[object " + this.name + "]", "String(" + desc + ")");
}
}.bind(this), "Stringification of " + desc);
};
}
//@}
IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expected_typeof)
@ -1599,7 +1586,7 @@ IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expect
assert_inherits(obj, member.name);
if (member.type == "const")
{
assert_equals(obj[member.name], constValue(member.value));
assert_equals(obj[member.name], eval(member.value));
}
if (member.type == "attribute")
{
@ -1648,20 +1635,20 @@ IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expect
obj[member.name].apply(obj, args);
}.bind(this), "Called with " + i + " arguments");
args.push(create_suitable_object(member.arguments[i].idlType));
args.push(create_suitable_object(member.arguments[i].type));
}
}.bind(this), this.name + " interface: calling " + member.name +
"(" + member.arguments.map(function(m) { return m.idlType.idlType; }) +
"(" + member.arguments.map(function(m) { return m.type.idlType; }) +
") on " + desc + " with too few arguments must throw TypeError");
}
}
};
}
//@}
IdlInterface.prototype.has_stringifier = function()
//@{
{
if (this.members.some(function(member) { return member.stringifier; })) {
if (this.members.some(function(member) { return member.stringifier })) {
return true;
}
if (this.base &&
@ -1669,7 +1656,7 @@ IdlInterface.prototype.has_stringifier = function()
return true;
}
return false;
};
}
//@}
function do_interface_attribute_asserts(obj, member)
@ -1799,39 +1786,5 @@ function create_suitable_object(type)
return null;
}
//@}
/// IdlEnum ///
// Used for IdlArray.prototype.assert_type_is
function IdlEnum(obj)
//@{
{
/**
* obj is an object produced by the WebIDLParser.js "dictionary"
* production.
*/
/** Self-explanatory. */
this.name = obj.name;
console.log("Name is " + this.name);
/** An array of values produced by the "enum" production. */
this.values = obj.values;
}
//@}
IdlEnum.prototype = Object.create(IdlObject.prototype);
IdlEnum.prototype.test = function()
//@{
{
test(function()
{
// NOTHING to test
return;
});
}
//@}
}());
})();
// vim: set expandtab shiftwidth=4 tabstop=4 foldmarker=@{,@} foldmethod=marker:

View File

@ -59,18 +59,21 @@ policies and contribution forms [3].
* would run test_function with a timeout of 1s.
*
* Additionally, test-specific metadata can be passed in the properties. These
* are used when the individual test has different metadata from that stored
* are used when the individual test has different metadata from that stored
* in the <head>.
* The recognized metadata properties are:
*
* help - The url of the part of the specification being tested
*
* assert - A human readable description of what the test is attempting
* assert - A human readable description of what the test is attempting
* to prove
*
* author - Name and contact information for the author of the test in the
* format: "Name <email_addr>" or "Name http://contact/url"
*
* flags - space separated list of test flags in addition to any present in
* the head metadata
*
* == Asynchronous Tests ==
*
* Testing asynchronous features is somewhat more complex since the result of
@ -163,10 +166,6 @@ policies and contribution forms [3].
* use when integrating with some existing test framework
* that has its own timeout mechanism).
*
* allow_uncaught_exception - don't treat an uncaught exception as an error;
* needed when e.g. testing the window.onerror
* handler.
*
* == Determining when all tests are complete ==
*
* By default the test harness will assume there are no more results to come
@ -205,7 +204,7 @@ policies and contribution forms [3].
* Note that the first item in each parameter list corresponds to the name of
* the test.
*
* The properties argument is identical to that for test(). This may be a
* The properties argument is identical to that for test(). This may be a
* single object (used for all generated tests) or an array.
*
* == Callback API ==
@ -291,18 +290,6 @@ policies and contribution forms [3].
* assert_approx_equals(actual, expected, epsilon, description)
* asserts that /actual/ is a number within +/- /epsilon/ of /expected/
*
* assert_less_than(actual, expected, description)
* asserts that /actual/ is a number less than /expected/
*
* assert_greater_than(actual, expected, description)
* asserts that /actual/ is a number greater than /expected/
*
* assert_less_than_equal(actual, expected, description)
* asserts that /actual/ is a number less than or equal to /expected/
*
* assert_greater_than_equal(actual, expected, description)
* asserts that /actual/ is a number greater than or equal to /expected/
*
* assert_regexp_match(actual, expected, description)
* asserts that /actual/ matches the regexp /expected/
*
@ -344,7 +331,7 @@ policies and contribution forms [3].
* is true for some expected_array_N in expected_array. This only works for assert_func
* with signature assert_func(actual, expected, args_1, ..., args_N). Note that tests
* with multiple allowed pass conditions are bad practice unless the spec specifically
* allows multiple behaviours. Test authors should not use this method simply to hide
* allows multiple behaviours. Test authors should not use this method simply to hide
* UA bugs.
*
* assert_exists(object, property_name, description)
@ -402,8 +389,9 @@ policies and contribution forms [3].
function next_default_name()
{
//Don't use document.title to work around an Opera bug in XHTML documents
var title = document.getElementsByTagName("title")[0];
var prefix = (title && title.firstChild && title.firstChild.data) || "Untitled";
var prefix = document.getElementsByTagName("title").length > 0 ?
document.getElementsByTagName("title")[0].firstChild.data :
"Untitled";
var suffix = name_counter > 0 ? " " + name_counter : "";
name_counter++;
return prefix + suffix;
@ -463,8 +451,8 @@ policies and contribution forms [3].
test(function()
{
func.apply(this, x.slice(1));
},
name,
},
name,
Array.isArray(properties) ? properties[i] : properties);
});
}
@ -496,22 +484,11 @@ policies and contribution forms [3].
/*
* Convert a value to a nice, human-readable string
*/
function format_value(val, seen)
function format_value(val)
{
if (!seen) {
seen = [];
}
if (typeof val === "object" && val !== null)
{
if (seen.indexOf(val) >= 0)
{
return "[...]";
}
seen.push(val);
}
if (Array.isArray(val))
{
return "[" + val.map(function(x) {return format_value(x, seen)}).join(", ") + "]";
return "[" + val.map(format_value).join(", ") + "]";
}
switch (typeof val)
@ -771,74 +748,6 @@ policies and contribution forms [3].
};
expose(assert_approx_equals, "assert_approx_equals");
function assert_less_than(actual, expected, description)
{
/*
* Test if a primitive number is less than another
*/
assert(typeof actual === "number",
"assert_less_than", description,
"expected a number but got a ${type_actual}",
{type_actual:typeof actual});
assert(actual < expected,
"assert_less_than", description,
"expected a number less than ${expected} but got ${actual}",
{expected:expected, actual:actual});
};
expose(assert_less_than, "assert_less_than");
function assert_greater_than(actual, expected, description)
{
/*
* Test if a primitive number is greater than another
*/
assert(typeof actual === "number",
"assert_greater_than", description,
"expected a number but got a ${type_actual}",
{type_actual:typeof actual});
assert(actual > expected,
"assert_greater_than", description,
"expected a number greater than ${expected} but got ${actual}",
{expected:expected, actual:actual});
};
expose(assert_greater_than, "assert_greater_than");
function assert_less_than_equal(actual, expected, description)
{
/*
* Test if a primitive number is less than or equal to another
*/
assert(typeof actual === "number",
"assert_less_than_equal", description,
"expected a number but got a ${type_actual}",
{type_actual:typeof actual});
assert(actual <= expected,
"assert_less_than", description,
"expected a number less than or equal to ${expected} but got ${actual}",
{expected:expected, actual:actual});
};
expose(assert_less_than_equal, "assert_less_than_equal");
function assert_greater_than_equal(actual, expected, description)
{
/*
* Test if a primitive number is greater than or equal to another
*/
assert(typeof actual === "number",
"assert_greater_than_equal", description,
"expected a number but got a ${type_actual}",
{type_actual:typeof actual});
assert(actual >= expected,
"assert_greater_than_equal", description,
"expected a number greater than or equal to ${expected} but got ${actual}",
{expected:expected, actual:actual});
};
expose(assert_greater_than_equal, "assert_greater_than_equal");
function assert_regexp_match(actual, expected, description) {
/*
* Test if a string (actual) matches a regexp (expected)
@ -1046,12 +955,12 @@ policies and contribution forms [3].
}
expose(assert_unreached, "assert_unreached");
function assert_any(assert_func, actual, expected_array)
function assert_any(assert_func, actual, expected_array)
{
var args = [].slice.call(arguments, 3)
var errors = []
var passed = false;
forEach(expected_array,
forEach(expected_array,
function(expected)
{
try {
@ -1132,7 +1041,7 @@ policies and contribution forms [3].
try
{
return func.apply(this_obj, Array.prototype.slice.call(arguments, 2));
func.apply(this_obj, Array.prototype.slice.call(arguments, 2));
}
catch(e)
{
@ -1276,8 +1185,6 @@ policies and contribution forms [3].
this.wait_for_finish = false;
this.processing_callbacks = false;
this.allow_uncaught_exception = false;
this.timeout_length = settings.timeout;
this.timeout_id = null;
@ -1298,8 +1205,6 @@ policies and contribution forms [3].
this_obj.complete();
}
});
this.set_timeout();
}
Tests.prototype.setup = function(func, properties)
@ -1313,30 +1218,26 @@ policies and contribution forms [3].
this.phase = this.phases.SETUP;
}
this.properties = properties;
for (var p in properties)
{
if (properties.hasOwnProperty(p))
{
var value = properties[p]
if (p == "timeout")
{
this.timeout_length = value;
}
else if (p == "allow_uncaught_exception") {
this.allow_uncaught_exception = value;
}
else if (p == "explicit_done" && value)
{
this.wait_for_finish = true;
}
else if (p == "explicit_timeout" && value) {
this.timeout_length = null;
}
this.properties[p] = properties[p];
}
}
if (properties.timeout)
{
this.timeout_length = properties.timeout;
}
if (properties.explicit_done)
{
this.wait_for_finish = true;
}
if (properties.explicit_timeout) {
this.timeout_length = null;
}
if (func)
{
try
@ -1548,15 +1449,6 @@ policies and contribution forms [3].
var tests = new Tests();
window.onerror = function(msg) {
if (!tests.allow_uncaught_exception)
{
tests.status.status = tests.status.ERROR;
tests.status.message = msg;
tests.complete();
}
}
function timeout() {
if (tests.timeout_length === null)
{
@ -1710,11 +1602,6 @@ policies and contribution forms [3].
}
}
var status_text_harness = {};
status_text_harness[harness_status.OK] = "OK";
status_text_harness[harness_status.ERROR] = "Error";
status_text_harness[harness_status.TIMEOUT] = "Timeout";
var status_text = {};
status_text[Test.prototype.PASS] = "Pass";
status_text[Test.prototype.FAIL] = "Fail";
@ -1739,34 +1626,6 @@ policies and contribution forms [3].
var summary_template = ["section", {"id":"summary"},
["h2", {}, "Summary"],
function(vars)
{
if (harness_status.status === harness_status.OK)
{
return null;
}
else
{
var status = status_text_harness[harness_status.status];
var rv = [["p", {"class":status_class(status)}]];
if (harness_status.status === harness_status.ERROR)
{
rv[0].push("Harness encountered an error:");
rv.push(["pre", {}, harness_status.message]);
}
else if (harness_status.status === harness_status.TIMEOUT)
{
rv[0].push("Harness timed out.");
}
else
{
rv[0].push("Harness got an unexpected status.");
}
return rv;
}
},
["p", {}, "Found ${num_tests} tests"],
function(vars) {
var rv = [["div", {}]];
@ -1832,7 +1691,7 @@ policies and contribution forms [3].
}
return false;
}
function get_assertion(test)
{
if (test.properties.hasOwnProperty("assert")) {
@ -1843,7 +1702,7 @@ policies and contribution forms [3].
}
return '';
}
log.appendChild(document.createElementNS(xhtml_ns, "section"));
var assertions = has_assertions();
var html = "<h2>Details</h2><table id='results' " + (assertions ? "class='assertions'" : "" ) + ">"

View File

@ -7,19 +7,13 @@ from __future__ import unicode_literals
import subprocess
repo = "https://github.com/w3c/testharness.js"
repo = "https://dvcs.w3.org/hg/resources"
dest = "resources-upstream"
files = [{"f":"testharness.js"},
{"f":"testharness.css"},
{"f":"idlharness.js"},
{"d":"webidl2/lib/webidl2.js", "f":"WebIDLParser.js"}]
files = ["testharness.js", "testharness.css", "idlharness.js", "WebIDLParser.js"]
subprocess.check_call(["git", "clone", repo, dest])
subprocess.check_call(["git", "submodule", "init"], cwd=dest)
subprocess.check_call(["git", "submodule", "update"], cwd=dest)
subprocess.check_call(["hg", "clone", repo, dest])
for f in files:
path = f["d"] if "d" in f else f["f"]
subprocess.check_call(["cp", "%s/%s" % (dest, path), f["f"]])
subprocess.check_call(["hg", "add", f["f"]])
subprocess.check_call(["cp", "%s/%s" % (dest, f), f])
subprocess.check_call(["hg", "add", f])
subprocess.check_call(["rm", "-rf", dest])