Bug 851916 part 1 - Update dom/imptests/webapps/ and harness; r=Ms2ger

--HG--
rename : dom/imptests/webapps/DOMCore/tests/submissions/Ms2ger/test_ChildNode-remove.js => dom/imptests/webapps/DOMCore/tests/submissions/Ms2ger/ChildNode-remove.js
This commit is contained in:
Aryeh Gregor 2013-03-21 14:54:43 +02:00
parent cd361e9bf8
commit 5384d0b989
31 changed files with 762 additions and 319 deletions

View File

@ -30,67 +30,130 @@
"DOMException exception: constant DATA_CLONE_ERR on exception interface prototype object": true,
"DOMException exception: field code on exception interface prototype object": true,
"DOMError interface: existence and properties of interface object": true,
"DOMError interface constructor": true,
"DOMError interface: existence and properties of interface prototype object": true,
"DOMError interface: existence and properties of interface prototype object's \"constructor\" property": true,
"DOMError interface: attribute name": true,
"Event interface: document.createEvent(\"Event\") must inherit property \"timeStamp\" with the proper type (14)": true,
"Event interface: new Event(\"foo\") must inherit property \"timeStamp\" with the proper type (14)": true,
"Event interface: document.createEvent(\"Event\") must have own property \"isTrusted\"": true,
"Event interface: document.createEvent(\"Event\") must inherit property \"timeStamp\" with the proper type (15)": true,
"Event interface: new Event(\"foo\") must have own property \"isTrusted\"": true,
"Event interface: new Event(\"foo\") must inherit property \"timeStamp\" with the proper type (15)": true,
"CustomEvent interface: existence and properties of interface object": true,
"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,
"CustomEvent interface: calling initCustomEvent(DOMString,boolean,boolean,any) on new CustomEvent(\"foo\") with too few arguments must throw TypeError": true,
"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,
"Event interface: calling initEvent(DOMString,boolean,boolean) on new CustomEvent(\"foo\") with too few arguments must throw TypeError": 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,
"EventListener interface: operation handleEvent(Event)": true,
"MutationCallback interface: existence and properties of interface object": true,
"MutationCallback interface: existence and properties of interface prototype object": true,
"MutationCallback interface: existence and properties of interface prototype object's \"constructor\" property": true,
"MutationCallback interface: operation handleEvent(MutationRecord,MutationObserver)": true,
"MutationObserver interface: operation observe(Node,MutationObserverInit)": 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(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(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(union) on xmlDoc with too few arguments must throw TypeError": true,
"DOMImplementation interface: operation createHTMLDocument(DOMString)": 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(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(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(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(union)": true,
"DocumentType interface: operation after(union)": true,
"DocumentType interface: operation replace(union)": true,
"DocumentType interface: operation remove()": true,
"DocumentType interface: document.doctype must inherit property \"remove\" with the proper type (3)": 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(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(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(union) on document.doctype with too few arguments must throw TypeError": true,
"DocumentType interface: document.doctype must inherit property \"remove\" with the proper type (8)": 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(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: operation remove()": true,
"Element interface: element must inherit property \"className\" with the proper type (5)": true,
"Element interface: element must inherit property \"remove\" with the proper type (25)": true,
"Element interface: element must inherit property \"prepend\" with the proper type (23)": 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(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(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(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(union) on element with too few arguments must throw TypeError": true,
"Element interface: element must inherit property \"remove\" with the proper type (30)": true,
"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 name": true,
"Stringification of document.querySelector(\"[id]\").attributes[0]": "debug",
"CharacterData interface: attribute previousElementSibling": true,
"CharacterData interface: attribute nextElementSibling": true,
"CharacterData interface: operation before(union)": true,
"CharacterData interface: operation after(union)": true,
"CharacterData interface: operation replace(union)": true,
"CharacterData interface: operation remove()": true,
"CharacterData interface: document.createTextNode(\"abc\") must inherit property \"remove\" with the proper type (7)": true,
"CharacterData interface: xmlDoc.createProcessingInstruction(\"abc\", \"def\") must inherit property \"remove\" with the proper type (7)": true,
"CharacterData interface: document.createComment(\"abc\") must inherit property \"remove\" with the proper type (7)": true,
"NodeFilter interface: existence and properties of interface prototype object": true,
"NodeFilter interface: existence and properties of interface prototype object's \"constructor\" property": true,
"NodeFilter interface: constant FILTER_ACCEPT on interface prototype object": true,
"NodeFilter interface: constant FILTER_REJECT on interface prototype object": true,
"NodeFilter interface: constant FILTER_SKIP on interface prototype object": true,
"NodeFilter interface: constant SHOW_ALL on interface prototype object": true,
"NodeFilter interface: constant SHOW_ELEMENT on interface prototype object": true,
"NodeFilter interface: constant SHOW_ATTRIBUTE on interface prototype object": true,
"NodeFilter interface: constant SHOW_TEXT on interface prototype object": true,
"NodeFilter interface: constant SHOW_CDATA_SECTION on interface prototype object": true,
"NodeFilter interface: constant SHOW_ENTITY_REFERENCE on interface prototype object": true,
"NodeFilter interface: constant SHOW_ENTITY on interface prototype object": true,
"NodeFilter interface: constant SHOW_PROCESSING_INSTRUCTION on interface prototype object": true,
"NodeFilter interface: constant SHOW_COMMENT on interface prototype object": true,
"NodeFilter interface: constant SHOW_DOCUMENT on interface prototype object": true,
"NodeFilter interface: constant SHOW_DOCUMENT_TYPE on interface prototype object": true,
"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,
"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
"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(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(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(union) on document.createTextNode(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: document.createTextNode(\"abc\") must inherit property \"remove\" with the proper type (12)": 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(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(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(union) on xmlDoc.createProcessingInstruction(\"abc\", \"def\") with too few arguments must throw TypeError": true,
"CharacterData interface: xmlDoc.createProcessingInstruction(\"abc\", \"def\") must inherit property \"remove\" with the proper type (12)": 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(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(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(union) on document.createComment(\"abc\") with too few arguments must throw TypeError": true,
"CharacterData interface: document.createComment(\"abc\") must inherit property \"remove\" with the proper type (12)": true,
"NodeFilter interface: existence and properties of interface object": true,
"NodeList interface: existence and properties of interface prototype object": true
}

View File

@ -11,18 +11,12 @@ include $(DEPTH)/config/autoconf.mk
MOCHITEST_FILES := \
test_CharacterData-remove.html.json \
test_DOMImplementation-createDocument.html.json \
test_DOMImplementation-createHTMLDocument.html.json \
test_Document-createElementNS.html.json \
test_Document-getElementsByTagName.html.json \
test_DocumentType-remove.html.json \
test_Element-remove.html.json \
test_Node-isEqualNode.xhtml.json \
test_NodeFilter-constants.html.json \
test_Range-attributes.html.json \
test_Range-commonAncestorContainer.html.json \
test_Range-comparePoint.html.json \
test_Range-detach.html.json \
test_attributes.html.json \
test_case.html.json \
test_historical.html.json \

View File

@ -1,5 +1,14 @@
{
"CharacterData.remove": true,
"CharacterData.remove 1": true,
"CharacterData.remove 2": true
"text should support remove()": true,
"remove() should work if text doesn't have a parent": true,
"remove() should work if text does have a parent": true,
"remove() should work if text does have a parent and siblings": true,
"comment should support remove()": true,
"remove() should work if comment doesn't have a parent": true,
"remove() should work if comment does have a parent": true,
"remove() should work if comment does have a parent and siblings": true,
"PI should support remove()": true,
"remove() should work if PI doesn't have a parent": true,
"remove() should work if PI does have a parent": true,
"remove() should work if PI does have a parent and siblings": true
}

View File

@ -1,4 +1,5 @@
{
"Document.getElementsByTagName 2": true,
"Document.getElementsByTagName 3": true
"Shouldn't be able to set unsigned properties on a HTMLCollection (strict mode)": true,
"Document.getElementsByTagName 1": true,
"Document.getElementsByTagName 2": true
}

View File

@ -1,3 +1,6 @@
{
"DocumentType.remove": true
"doctype should support remove()": true,
"remove() should work if doctype doesn't have a parent": true,
"remove() should work if doctype does have a parent": true,
"remove() should work if doctype does have a parent and siblings": true
}

View File

@ -1,3 +1,6 @@
{
"Element.remove": true
"element should support remove()": true,
"remove() should work if element doesn't have a parent": true,
"remove() should work if element does have a parent": true,
"remove() should work if element does have a parent and siblings": true
}

View File

@ -303,6 +303,10 @@ IdlArray.prototype.internal_add_idls = function(parsed_idls)
// TODO
break;
case "callback":
// TODO
break;
default:
throw parsed_idl.name + ": " + parsed_idl.type + " not yet supported";
}
@ -1029,18 +1033,42 @@ IdlException.prototype.test_object = function(desc)
/// IdlInterface ///
function IdlInterface(obj) { IdlExceptionOrInterface.call(this, obj); }
IdlInterface.prototype = Object.create(IdlExceptionOrInterface.prototype);
IdlInterface.prototype.is_callback = function()
//@{
{
return this.has_extended_attribute("Callback");
}
//@}
IdlInterface.prototype.has_constants = function()
//@{
{
return this.members.some(function(member) {
return member.type === "const";
});
}
//@}
IdlInterface.prototype.test_self = function()
//@{
{
test(function()
{
// "For every interface that is not declared with the
// [NoInterfaceObject] extended attribute, a corresponding property
// must exist on the interfaces relevant namespace object. The name of
// the property is the identifier of the interface, and its value is an
// object called the interface object. The property has the attributes
// { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true
// }."
// This function tests WebIDL as of 2012-11-28.
// "For every interface that:
// * is a callback interface that has constants declared on it, or
// * is a non-callback interface that is not declared with the
// [NoInterfaceObject] extended attribute,
// a corresponding property MUST exist on the ECMAScript global object.
// The name of the property is the identifier of the interface, and its
// value is an object called the interface object.
// The property has the attributes { [[Writable]]: true,
// [[Enumerable]]: false, [[Configurable]]: true }."
if (this.is_callback() && !this.has_constants()) {
return;
}
// TODO: Should we test here that the property is actually writable
// etc., or trust getOwnPropertyDescriptor?
assert_own_property(window, this.name,
@ -1052,43 +1080,53 @@ IdlInterface.prototype.test_self = function()
assert_false(desc.enumerable, "window's property " + format_value(this.name) + " is enumerable");
assert_true(desc.configurable, "window's property " + format_value(this.name) + " is not configurable");
// "Interface objects are always function objects."
if (this.is_callback()) {
// "The internal [[Prototype]] property of an interface object for
// a callback interface MUST be the Object.prototype object."
assert_equals(Object.getPrototypeOf(window[this.name]), Object.prototype,
"prototype of window's property " + format_value(this.name) + " is not Object.prototype");
return;
}
// "The interface object for a given non-callback interface is a
// function object."
// "If an object is defined to be a function object, then it has
// characteristics as follows:"
// "Its [[Prototype]] internal property is the Function prototype
// object."
// Note: This doesn't match browsers as of December 2011, see
// http://www.w3.org/Bugs/Public/show_bug.cgi?id=14813
// "* Its [[Prototype]] internal property is the Function prototype
// object."
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."
// "* Its [[Get]] internal property is set as described in ECMA-262
// section 15.3.5.4."
// Not much to test for this.
// "Its [[Construct]] internal property is set as described in ECMA-262
// section 13.2.2."
// "* Its [[Construct]] internal property is set as described in
// ECMA-262 section 13.2.2."
// Tested below if no constructor is defined. TODO: test constructors
// if defined.
// "Its [[HasInstance]] internal property is set as described in
// ECMA-262 section 15.3.5.3, unless otherwise specified."
// "* Its [[HasInstance]] internal property is set as described in
// ECMA-262 section 15.3.5.3, unless otherwise specified."
// TODO
// "Its [[Class]] internal property is “Function”."
// "* Its [[NativeBrand]] internal property is “Function”."
// String() returns something implementation-dependent, because it calls
// Function#toString.
assert_class_string(window[this.name], "Function", "class string of " + this.name);
if (!this.has_extended_attribute("Constructor"))
{
if (!this.has_extended_attribute("Constructor")) {
// "The internal [[Call]] method of the interface object behaves as
// follows . . .
//
// "If I was not declared with a [Constructor] extended attribute,
// then throw a TypeError."
assert_throws(new TypeError(), function()
{
assert_throws(new TypeError(), function() {
window[this.name]();
}.bind(this), "interface object didn't throw TypeError when called as a function");
assert_throws(new TypeError(), function()
{
assert_throws(new TypeError(), function() {
new window[this.name]();
}.bind(this), "interface object didn't throw TypeError when called as a constructor");
}
@ -1138,6 +1176,12 @@ IdlInterface.prototype.test_self = function()
assert_own_property(window, this.name,
"window does not have own property " + format_value(this.name));
if (this.has_extended_attribute("Callback")) {
assert_false("prototype" in window[this.name],
this.name + ' should not have a "prototype" property');
return;
}
// "The interface object must also have a property named “prototype”
// with attributes { [[Writable]]: false, [[Enumerable]]: false,
// [[Configurable]]: false } whose value is an object called the
@ -1219,6 +1263,13 @@ IdlInterface.prototype.test_self = function()
{
assert_own_property(window, this.name,
"window does not have own property " + format_value(this.name));
if (this.has_extended_attribute("Callback")) {
assert_false("prototype" in window[this.name],
this.name + ' should not have a "prototype" property');
return;
}
assert_own_property(window[this.name], "prototype",
'interface "' + this.name + '" does not have own property "prototype"');
@ -1282,6 +1333,13 @@ IdlInterface.prototype.test_members = function()
{
assert_own_property(window, this.name,
"window does not have own property " + format_value(this.name));
if (this.has_extended_attribute("Callback")) {
assert_false("prototype" in window[this.name],
this.name + ' should not have a "prototype" property');
return;
}
assert_own_property(window[this.name], "prototype",
'interface "' + this.name + '" does not have own property "prototype"');
@ -1331,6 +1389,13 @@ IdlInterface.prototype.test_members = function()
{
assert_own_property(window, this.name,
"window does not have own property " + format_value(this.name));
if (this.has_extended_attribute("Callback")) {
assert_false("prototype" in window[this.name],
this.name + ' should not have a "prototype" property');
return;
}
assert_own_property(window[this.name], "prototype",
'interface "' + this.name + '" does not have own property "prototype"');

View File

@ -71,6 +71,9 @@ policies and contribution forms [3].
* 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
@ -94,6 +97,19 @@ policies and contribution forms [3].
*
* t.done();
*
* As a convenience, async_test can also takes a function as first argument.
* This function is called with the test object as both its `this` object and
* first argument. The above example can be rewritten as:
*
* async_test(function(t) {
* object.some_event = function() {
* t.step(function (){assert_true(true); t.done();});
* };
* }, "Simple async test");
*
* which avoids cluttering the global scope with references to async
* tests instances.
*
* The properties argument is identical to that for test().
*
* In many cases it is convenient to run a step in response to an event or a
@ -222,7 +238,7 @@ policies and contribution forms [3].
*
* In order to collect the results of multiple pages containing tests, the test
* harness will, when loaded in a nested browsing context, attempt to call
* certain functions in each ancestor browsing context:
* certain functions in each ancestor and opener browsing context:
*
* start - start_callback
* result - result_callback
@ -231,6 +247,22 @@ policies and contribution forms [3].
* These are given the same arguments as the corresponding internal callbacks
* described above.
*
* == External API through cross-document messaging ==
*
* Where supported, the test harness will also send messages using
* cross-document messaging to each ancestor and opener browsing context. Since
* it uses the wildcard keyword (*), cross-origin communication is enabled and
* script on different origins can collect the results.
*
* This API follows similar conventions as those described above only slightly
* modified to accommodate message event API. Each message is sent by the harness
* is passed a single vanilla object, available as the `data` property of the
* event object. These objects are structures as follows:
*
* start - { type: "start" }
* result - { type: "result", test: Test }
* complete - { type: "complete", tests: [Test, ...], status: TestsStatus }
*
* == List of assertions ==
*
* assert_true(actual, description)
@ -376,11 +408,19 @@ policies and contribution forms [3].
}
}
function async_test(name, properties)
function async_test(func, name, properties)
{
if (typeof func !== "function") {
properties = name;
name = func;
func = null;
}
var test_name = name ? name : next_default_name();
properties = properties ? properties : {};
var test_obj = new Test(test_name, properties);
if (func) {
test_obj.step(func, test_obj, test_obj);
}
return test_obj;
}
@ -652,7 +692,7 @@ policies and contribution forms [3].
}
else
{
assert(actual[p] === expected[p], "assert_object_equals", description,
assert(same_value(actual[p], expected[p]), "assert_object_equals", description,
"property ${p} expected ${expected} got ${actual}",
{p:p, expected:expected, actual:actual});
}
@ -683,7 +723,7 @@ policies and contribution forms [3].
"property ${i}, property expected to be $expected but was $actual",
{i:i, expected:expected.hasOwnProperty(i) ? "present" : "missing",
actual:actual.hasOwnProperty(i) ? "present" : "missing"});
assert(expected[i] === actual[i],
assert(same_value(expected[i], actual[i]),
"assert_array_equals", description,
"property ${i}, expected ${expected} but got ${actual}",
{i:i, expected:expected[i], actual:actual[i]});
@ -777,7 +817,7 @@ policies and contribution forms [3].
//Note that this can have side effects in the case where
//the property has PutForwards
object[property_name] = initial_value + "a"; //XXX use some other value here?
assert(object[property_name] === initial_value,
assert(same_value(object[property_name], initial_value),
"assert_readonly", description,
"changing property ${p} succeeded",
{p:property_name});
@ -838,7 +878,7 @@ policies and contribution forms [3].
QUOTA_EXCEEDED_ERR: 'QuotaExceededError',
TIMEOUT_ERR: 'TimeoutError',
INVALID_NODE_TYPE_ERR: 'InvalidNodeTypeError',
DATA_CLONE_ERR: 'DataCloneError',
DATA_CLONE_ERR: 'DataCloneError'
};
var name = code in code_name_map ? code_name_map[code] : code;
@ -871,7 +911,7 @@ policies and contribution forms [3].
DataError: 0,
TransactionInactiveError: 0,
ReadOnlyError: 0,
VersionError: 0,
VersionError: 0
};
if (!(name in name_code_map))
@ -954,13 +994,29 @@ policies and contribution forms [3].
tests.push(this);
}
Test.prototype = {
Test.statuses = {
PASS:0,
FAIL:1,
TIMEOUT:2,
NOTRUN:3
};
Test.prototype = merge({}, Test.statuses);
Test.prototype.structured_clone = function()
{
if(!this._structured_clone)
{
var msg = this.message;
msg = msg ? String(msg) : msg;
this._structured_clone = merge({
name:String(this.name),
status:this.status,
message:msg
}, Test.statuses);
}
return this._structured_clone;
};
Test.prototype.step = function(func, this_obj)
{
@ -1085,12 +1141,29 @@ policies and contribution forms [3].
this.status = null;
this.message = null;
}
TestsStatus.prototype = {
TestsStatus.statuses = {
OK:0,
ERROR:1,
TIMEOUT:2
};
TestsStatus.prototype = merge({}, TestsStatus.statuses);
TestsStatus.prototype.structured_clone = function()
{
if(!this._structured_clone)
{
var msg = this.message;
msg = msg ? String(msg) : msg;
this._structured_clone = merge({
status:this.status,
message:msg
}, TestsStatus.statuses);
}
return this._structured_clone;
};
function Tests()
{
this.tests = [];
@ -1232,10 +1305,10 @@ policies and contribution forms [3].
{
callback(this_obj.properties);
});
forEach(ancestor_windows(),
function(w)
forEach_windows(
function(w, is_same_origin)
{
if(w.start_callback)
if(is_same_origin && w.start_callback)
{
try
{
@ -1249,6 +1322,13 @@ policies and contribution forms [3].
}
}
}
if (supports_post_message(w) && w !== self)
{
w.postMessage({
type: "start",
properties: this_obj.properties
}, "*");
}
});
};
@ -1272,10 +1352,10 @@ policies and contribution forms [3].
callback(test, this_obj);
});
forEach(ancestor_windows(),
function(w)
forEach_windows(
function(w, is_same_origin)
{
if(w.result_callback)
if(is_same_origin && w.result_callback)
{
try
{
@ -1288,6 +1368,13 @@ policies and contribution forms [3].
}
}
}
if (supports_post_message(w) && w !== self)
{
w.postMessage({
type: "result",
test: test.structured_clone()
}, "*");
}
});
this.processing_callbacks = false;
if (this_obj.all_done())
@ -1318,6 +1405,11 @@ policies and contribution forms [3].
{
clearTimeout(this.timeout_id);
var this_obj = this;
var tests = map(this_obj.tests,
function(test)
{
return test.structured_clone();
});
if (this.status.status === null)
{
this.status.status = this.status.OK;
@ -1329,10 +1421,10 @@ policies and contribution forms [3].
callback(this_obj.tests, this_obj.status);
});
forEach(ancestor_windows(),
function(w)
forEach_windows(
function(w, is_same_origin)
{
if(w.completion_callback)
if(is_same_origin && w.completion_callback)
{
try
{
@ -1346,6 +1438,14 @@ policies and contribution forms [3].
}
}
}
if (supports_post_message(w) && w !== self)
{
w.postMessage({
type: "complete",
tests: tests,
status: this_obj.status.structured_clone()
}, "*");
}
});
};
@ -1382,7 +1482,7 @@ policies and contribution forms [3].
*/
function Output() {
this.output_document = null;
this.output_document = document;
this.output_node = null;
this.done_count = 0;
this.enabled = settings.output;
@ -1939,22 +2039,107 @@ policies and contribution forms [3].
target[components[components.length - 1]] = object;
}
function ancestor_windows() {
//Get the windows [self ... top] as an array
if ("result_cache" in ancestor_windows)
{
return ancestor_windows.result_cache;
}
var rv = [self];
var w = self;
while (w != w.parent)
{
w = w.parent;
rv.push(w);
}
ancestor_windows.result_cache = rv;
return rv;
}
function forEach_windows(callback) {
// Iterate of the the windows [self ... top, opener]. The callback is passed
// two objects, the first one is the windows object itself, the second one
// is a boolean indicating whether or not its on the same origin as the
// current window.
var cache = forEach_windows.result_cache;
if (!cache) {
cache = [[self, true]];
var w = self;
var i = 0;
var so;
var origins = location.ancestorOrigins;
while (w != w.parent)
{
w = w.parent;
// In WebKit, calls to parent windows' properties that aren't on the same
// origin cause an error message to be displayed in the error console but
// don't throw an exception. This is a deviation from the current HTML5
// spec. See: https://bugs.webkit.org/show_bug.cgi?id=43504
// The problem with WebKit's behavior is that it pollutes the error console
// with error messages that can't be caught.
//
// This issue can be mitigated by relying on the (for now) proprietary
// `location.ancestorOrigins` property which returns an ordered list of
// the origins of enclosing windows. See:
// http://trac.webkit.org/changeset/113945.
if(origins) {
so = (location.origin == origins[i]);
}
else
{
so = is_same_origin(w);
}
cache.push([w, so]);
i++;
}
w = window.opener;
if(w)
{
// window.opener isn't included in the `location.ancestorOrigins` prop.
// We'll just have to deal with a simple check and an error msg on WebKit
// browsers in this case.
cache.push([w, is_same_origin(w)]);
}
forEach_windows.result_cache = cache;
}
forEach(cache,
function(a)
{
callback.apply(null, a);
});
}
function is_same_origin(w) {
try {
'random_prop' in w;
return true;
} catch(e) {
return false;
}
}
function supports_post_message(w)
{
var supports;
var type;
// Given IE implements postMessage across nested iframes but not across
// windows or tabs, you can't infer cross-origin communication from the presence
// of postMessage on the current window object only.
//
// Touching the postMessage prop on a window can throw if the window is
// not from the same origin AND post message is not supported in that
// browser. So just doing an existence test here won't do, you also need
// to wrap it in a try..cacth block.
try
{
type = typeof w.postMessage;
if (type === "function")
{
supports = true;
}
// IE8 supports postMessage, but implements it as a host object which
// returns "object" as its `typeof`.
else if (type === "object")
{
supports = true;
}
// This is the case where postMessage isn't supported AND accessing a
// window property across origins does NOT throw (e.g. old Safari browser).
else
{
supports = false;
}
}
catch(e) {
// This is the case where postMessage isn't supported AND accessing a
// window property across origins throws (e.g. old Firefox browser).
supports = false;
}
return supports;
}
})();
// vim: set expandtab shiftwidth=4 tabstop=4:

View File

@ -1,4 +1,4 @@
# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT
# THIS FILE IS AUTOGENERATED BY importTestSuites.py - DO NOT EDIT
DIRS += [
'webapps/DOMCore/tests/approved',

View File

@ -23,7 +23,7 @@ exception DOMException {
const unsigned short NAMESPACE_ERR = 14;
const unsigned short INVALID_ACCESS_ERR = 15;
const unsigned short VALIDATION_ERR = 16; // historical
const unsigned short TYPE_MISMATCH_ERR = 17;
const unsigned short TYPE_MISMATCH_ERR = 17; // historical; use TypeError instead
const unsigned short SECURITY_ERR = 18;
const unsigned short NETWORK_ERR = 19;
const unsigned short ABORT_ERR = 20;
@ -35,6 +35,7 @@ exception DOMException {
unsigned short code;
};
[Constructor(DOMString name)]
interface DOMError {
readonly attribute DOMString name;
};
@ -45,6 +46,7 @@ interface Event {
readonly attribute EventTarget? target;
readonly attribute EventTarget? currentTarget;
const unsigned short NONE = 0;
const unsigned short CAPTURING_PHASE = 1;
const unsigned short AT_TARGET = 2;
const unsigned short BUBBLING_PHASE = 3;
@ -58,29 +60,31 @@ interface Event {
void preventDefault();
readonly attribute boolean defaultPrevented;
readonly attribute boolean isTrusted;
[Unforgeable] readonly attribute boolean isTrusted;
readonly attribute DOMTimeStamp timeStamp;
void initEvent(DOMString type, boolean bubbles, boolean cancelable);
};
dictionary EventInit {
boolean bubbles;
boolean cancelable;
boolean bubbles = false;
boolean cancelable = false;
};
[Constructor(DOMString type, optional CustomEventInit eventInitDict)]
interface CustomEvent : Event {
readonly attribute any detail;
void initCustomEvent(DOMString type, boolean bubbles, boolean cancelable, any details);
};
dictionary CustomEventInit : EventInit {
any detail;
any detail = null;
};
interface EventTarget {
void addEventListener(DOMString type, EventListener? listener, optional boolean capture);
void removeEventListener(DOMString type, EventListener? listener, optional boolean capture);
void addEventListener(DOMString type, EventListener? callback, optional boolean capture);
void removeEventListener(DOMString type, EventListener? callback, optional boolean capture);
boolean dispatchEvent(Event event);
};
@ -89,71 +93,63 @@ interface EventListener {
void handleEvent(Event event);
};
[NoInterfaceObject]
interface ParentNode {
readonly attribute HTMLCollection children;
readonly attribute Element? firstElementChild;
readonly attribute Element? lastElementChild;
readonly attribute unsigned long childElementCount;
void prepend((Node or DOMString)... nodes);
void append((Node or DOMString)... nodes);
};
Document implements ParentNode;
DocumentFragment implements ParentNode;
Element implements ParentNode;
[NoInterfaceObject]
interface ChildNode {
readonly attribute Element? previousElementSibling;
readonly attribute Element? nextElementSibling;
void before((Node or DOMString)... nodes);
void after((Node or DOMString)... nodes);
void replace((Node or DOMString)... nodes);
void remove();
};
DocumentType implements ChildNode;
Element implements ChildNode;
CharacterData implements ChildNode;
[Constructor(MutationCallback callback)]
interface MutationObserver {
void observe(Node target, optional MutationObserverInit options);
void observe(Node target, MutationObserverInit options);
void disconnect();
sequence<MutationRecord> takeRecords();
};
[Callback]
interface MutationCallback {
void handleEvent(MutationRecord[] mutations, MutationObserver observer);
};
callback MutationCallback = void (sequence<MutationRecord> mutations, MutationObserver observer);
dictionary MutationObserverInit {
// Mutation types
boolean childList; // If true, mutations affecting nodes childNodes are included.
boolean attributes; // If true, mutations affecting elements attributes are included.
boolean characterData; // If true, mutations affecting the value of CharacterData nodes are included.
// [Note: If none of the known mutation types is specified, an Error is thrown]
// Subtree observation
boolean subtree; // If true, the observed set of nodes for this registration should include
// descendants of MutationTarget (behavior described below).
// Old values
boolean attributeOldValue;
// If true, MutationRecords describing changes to attributes should
// contain the value of the attribute before the change. If true
// without attribute: true specified, an Error is thrown.
boolean characterDataOldValue;
// If true, MutationRecords describing changes to
// CharacterData nodes should contain the value
// of the node before the change. If true without
// characterData: true, an Error is thrown.
// Filtering
DOMString[] attributeFilter;
// If provided, only changes to attributes with localName equaling
// one of the provided strings will be delivered. If provided without
// attribute: true, an Error is thrown.
boolean childList = false;
boolean attributes = false;
boolean characterData = false;
boolean subtree = false;
boolean attributeOldValue = false;
boolean characterDataOldValue = false;
sequence<DOMString> attributeFilter;
};
interface MutationRecord {
// Mutation type: one of 'childList', 'attributes', or 'characterData'
readonly attribute DOMString type;
// For childList and attributes, target is the owner node affected.
// For CharacterData, target is the node affected.
readonly attribute Node target;
// For type == 'childList', Sequence of added and removed nodes in this operation.
readonly attribute NodeList addedNodes;
readonly attribute NodeList removedNodes;
// For type == 'childList', The siblings in childNodes immediately preceding following the first
// and last nodes added and/or removed.
readonly attribute Node previousSibling;
readonly attribute Node nextSibling;
// For type == 'attribute', the name and namespaceURI of the attribute affected
readonly attribute DOMString attributeName;
readonly attribute DOMString attributeNamespace;
// For type == 'attribute' or 'characterData', if requested, the value immediately
// preceding the mutation.
readonly attribute DOMString oldValue;
readonly attribute Node? previousSibling;
readonly attribute Node? nextSibling;
readonly attribute DOMString? attributeName;
readonly attribute DOMString? attributeNamespace;
readonly attribute DOMString? oldValue;
};
interface Node : EventTarget {
@ -184,29 +180,30 @@ interface Node : EventTarget {
readonly attribute Node? previousSibling;
readonly attribute Node? nextSibling;
const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;
const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04;
const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08;
const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; // historical
unsigned short compareDocumentPosition(Node other);
boolean contains(Node? other);
attribute DOMString? nodeValue;
attribute DOMString? textContent;
Node insertBefore(Node node, Node? child);
Node appendChild(Node node);
Node replaceChild(Node node, Node child);
Node removeChild(Node child);
void normalize();
Node cloneNode(optional boolean deep);
boolean isEqualNode(Node? node);
DOMString lookupPrefix(DOMString? namespace);
DOMString lookupNamespaceURI(DOMString? prefix);
const unsigned short DOCUMENT_POSITION_DISCONNECTED = 0x01;
const unsigned short DOCUMENT_POSITION_PRECEDING = 0x02;
const unsigned short DOCUMENT_POSITION_FOLLOWING = 0x04;
const unsigned short DOCUMENT_POSITION_CONTAINS = 0x08;
const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 0x10;
const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;
unsigned short compareDocumentPosition(Node other);
boolean contains(Node? other);
DOMString? lookupPrefix(DOMString? namespace);
DOMString? lookupNamespaceURI(DOMString? prefix);
boolean isDefaultNamespace(DOMString? namespace);
Node insertBefore(Node node, Node? child);
Node appendChild(Node node);
Node replaceChild(Node node, Node child);
Node removeChild(Node child);
};
[Constructor]
@ -220,9 +217,9 @@ interface Document : Node {
readonly attribute DocumentType? doctype;
readonly attribute Element? documentElement;
NodeList getElementsByTagName(DOMString qualifiedName);
NodeList getElementsByTagNameNS(DOMString? namespace, DOMString localName);
NodeList getElementsByClassName(DOMString classNames);
HTMLCollection getElementsByTagName(DOMString localName);
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
HTMLCollection getElementsByClassName(DOMString classNames);
Element? getElementById(DOMString elementId);
Element createElement(DOMString localName);
@ -235,47 +232,33 @@ interface Document : Node {
Node importNode(Node node, optional boolean deep);
Node adoptNode(Node node);
Event createEvent(DOMString eventInterfaceName);
Event createEvent(DOMString interface);
Range createRange();
// NodeFilter.SHOW_ALL = 0xFFFFFFFF
NodeIterator createNodeIterator(Node root, optional unsigned long whatToShow, optional NodeFilter? filter);
TreeWalker createTreeWalker(Node root, optional unsigned long whatToShow, optional NodeFilter? filter);
// NEW
// Invalid WebIDL https://www.w3.org/Bugs/Public/show_bug.cgi?id=15346
//void prepend((Node or DOMString)... nodes);
//void append((Node or DOMString)... nodes);
};
interface XMLDocument : Document {};
interface DOMImplementation {
boolean hasFeature(DOMString feature, [TreatNullAs=EmptyString] DOMString version);
DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);
XMLDocument createDocument(DOMString? namespace, DOMString qualifiedName, DocumentType? doctype);
Document createHTMLDocument(DOMString title);
XMLDocument createDocument(DOMString? namespace, [TreatNullAs=EmptyString] DOMString qualifiedName, DocumentType? doctype);
Document createHTMLDocument(optional DOMString title);
boolean hasFeature(DOMString feature, [TreatNullAs=EmptyString] DOMString version);
};
[Constructor]
interface DocumentFragment : Node {
// NEW
// Invalid WebIDL https://www.w3.org/Bugs/Public/show_bug.cgi?id=15346
//void prepend((Node or DOMString)... nodes);
//void append((Node or DOMString)... nodes);
};
interface DocumentType : Node {
readonly attribute DOMString name;
readonly attribute DOMString publicId;
readonly attribute DOMString systemId;
// NEW
// Invalid WebIDL https://www.w3.org/Bugs/Public/show_bug.cgi?id=15346
//void before((Node or DOMString)... nodes);
//void after((Node or DOMString)... nodes);
//void replace((Node or DOMString)... nodes);
void remove();
};
interface Element : Node {
@ -298,34 +281,18 @@ interface Element : Node {
boolean hasAttribute(DOMString name);
boolean hasAttributeNS(DOMString? namespace, DOMString localName);
NodeList getElementsByTagName(DOMString qualifiedName);
NodeList getElementsByTagNameNS(DOMString? namespace, DOMString localName);
NodeList getElementsByClassName(DOMString classNames);
readonly attribute HTMLCollection children;
readonly attribute Element? firstElementChild;
readonly attribute Element? lastElementChild;
readonly attribute Element? previousElementSibling;
readonly attribute Element? nextElementSibling;
readonly attribute unsigned long childElementCount;
// NEW
// Invalid WebIDL https://www.w3.org/Bugs/Public/show_bug.cgi?id=15346
//void prepend((Node or DOMString)... nodes);
//void append((Node or DOMString)... nodes);
//void before((Node or DOMString)... nodes);
//void after((Node or DOMString)... nodes);
//void replace((Node or DOMString)... nodes);
void remove();
HTMLCollection getElementsByTagName(DOMString localName);
HTMLCollection getElementsByTagNameNS(DOMString? namespace, DOMString localName);
HTMLCollection getElementsByClassName(DOMString classNames);
};
interface Attr {
readonly attribute DOMString name;
readonly attribute DOMString localName;
attribute DOMString value;
readonly attribute DOMString name;
readonly attribute DOMString? namespaceURI;
readonly attribute DOMString? prefix;
readonly attribute DOMString localName;
};
interface CharacterData : Node {
@ -336,15 +303,9 @@ interface CharacterData : Node {
void insertData(unsigned long offset, DOMString data);
void deleteData(unsigned long offset, unsigned long count);
void replaceData(unsigned long offset, unsigned long count, DOMString data);
// NEW
// Invalid WebIDL https://www.w3.org/Bugs/Public/show_bug.cgi?id=15346
//void before((Node or DOMString)... nodes);
//void after((Node or DOMString)... nodes);
//void replace((Node or DOMString)... nodes);
void remove();
};
[Constructor(optional DOMString data)]
interface Text : CharacterData {
Text splitText(unsigned long offset);
readonly attribute DOMString wholeText;
@ -354,9 +315,11 @@ interface ProcessingInstruction : CharacterData {
readonly attribute DOMString target;
};
[Constructor(optional DOMString data)]
interface Comment : CharacterData {
};
[Constructor]
interface Range {
readonly attribute Node startContainer;
readonly attribute unsigned long startOffset;
@ -428,8 +391,7 @@ interface TreeWalker {
[Callback]
interface NodeFilter {
// Constants for acceptNode
// Constants for acceptNode()
const unsigned short FILTER_ACCEPT = 1;
const unsigned short FILTER_REJECT = 2;
const unsigned short FILTER_SKIP = 3;
@ -452,6 +414,7 @@ interface NodeFilter {
unsigned short acceptNode(Node node);
};
[ArrayClass]
interface NodeList {
getter Node? item(unsigned long index);
readonly attribute unsigned long length;
@ -463,20 +426,14 @@ interface HTMLCollection {
getter object? namedItem(DOMString name); // only returns Element
};
interface DOMStringList {
readonly attribute unsigned long length;
getter DOMString? item(unsigned long index);
boolean contains(DOMString string);
};
interface DOMTokenList {
readonly attribute unsigned long length;
getter DOMString? item(unsigned long index);
boolean contains(DOMString token);
void add(DOMString token);
void remove(DOMString token);
boolean toggle(DOMString token);
stringifier DOMString ();
void add(DOMString... tokens);
void remove(DOMString... tokens);
boolean toggle(DOMString token, optional boolean force);
stringifier;
};
interface DOMSettableTokenList : DOMTokenList {
@ -509,8 +466,8 @@ idlArray.add_objects({
ProcessingInstruction: ['xmlDoc.createProcessingInstruction("abc", "def")'],
Comment: ['document.createComment("abc")'],
Range: ['document.createRange()', 'detachedRange'],
NodeIterator: ['document.createNodeIterator(document.body, NodeFilter.SHOW_ALL, null)'],
TreeWalker: ['document.createTreeWalker(document.body, NodeFilter.SHOW_ALL, null)'],
NodeIterator: ['document.createNodeIterator(document.body, NodeFilter.SHOW_ALL, null, false)'],
TreeWalker: ['document.createTreeWalker(document.body, NodeFilter.SHOW_ALL, null, false)'],
NodeList: ['document.querySelectorAll("script")'],
HTMLCollection: ['document.body.children'],
DOMTokenList: ['document.body.classList'],

View File

@ -17,7 +17,6 @@ MOCHITEST_FILES := \
test_CharacterData-insertData.html \
test_CharacterData-remove.html \
test_CharacterData-replaceData.html \
test_ChildNode-remove.js \
test_Document-adoptNode.html \
test_Document-createComment.html \
test_Document-createElement.html \
@ -27,6 +26,7 @@ MOCHITEST_FILES := \
test_Document-createProcessingInstruction-literal-1.xhtml \
test_Document-createProcessingInstruction-literal-2.xhtml \
test_Document-createProcessingInstruction.xhtml \
test_Document-createTreeWalker.html \
test_Document-getElementById.html \
test_Document-getElementsByTagName.html \
test_Document-getElementsByTagNameNS.html \
@ -47,6 +47,7 @@ MOCHITEST_FILES := \
test_Event-defaultPrevented.html \
test_Event-initEvent.html \
test_EventTarget-dispatchEvent.html \
test_Event-type.html \
test_historical.html \
test_interfaces.html \
test_Node-appendChild.html \
@ -73,6 +74,7 @@ MOCHITEST_FILES := \
case.js \
creators.js \
constants.js \
ChildNode-remove.js \
Document-createProcessingInstruction.js \
productions.js \
$(NULL)

View File

@ -18,7 +18,9 @@ test(function() {
* the doctype argument
* the expected exception, or null if none
*/
[null, null, false, new TypeError()],
[null, null, null, null],
[null, undefined, null, null],
[null, "", null, null],
[null, "foo", null, null],
[null, "1foo", null, "INVALID_CHARACTER_ERR"],
@ -33,6 +35,22 @@ test(function() {
[null, "xml:foo", null, "NAMESPACE_ERR"],
[null, "xmlns:foo", null, "NAMESPACE_ERR"],
[null, "xmlfoo:bar", null, "NAMESPACE_ERR"],
[undefined, null, undefined, null],
[undefined, undefined, undefined, null],
[undefined, "", undefined, null],
[undefined, "foo", undefined, null],
[undefined, "1foo", undefined, "INVALID_CHARACTER_ERR"],
[undefined, "f1oo", undefined, null],
[undefined, "foo1", undefined, null],
[undefined, ":foo", undefined, "NAMESPACE_ERR"],
[undefined, "f:oo", undefined, "NAMESPACE_ERR"],
[undefined, "foo:", undefined, "NAMESPACE_ERR"],
[undefined, "xml", undefined, null],
[undefined, "xmlns", undefined, "NAMESPACE_ERR"],
[undefined, "xmlfoo", undefined, null],
[undefined, "xml:foo", undefined, "NAMESPACE_ERR"],
[undefined, "xmlns:foo", undefined, "NAMESPACE_ERR"],
[undefined, "xmlfoo:bar", undefined, "NAMESPACE_ERR"],
["http://example.com/", null, null, null],
["http://example.com/", "", null, null],
["http://example.com/", "foo", null, null],
@ -108,36 +126,28 @@ test(function() {
["foo:", "xml:foo", null, "NAMESPACE_ERR"],
["foo:", "xmlns:foo", null, "NAMESPACE_ERR"],
["foo:", "xmlfoo:bar", null, null],
[null, null, document.implementation.createDocumentType("foo", "", ""), null],
[null, null, document.doctype, null], // This causes a horrible WebKit bug (now fixed in trunk).
[null, null, function() {
var foo = document.implementation.createDocumentType("foo", "", "");
document.implementation.createDocument(null, null, foo);
return foo;
}(), null], // DOCTYPE already associated with a document.
[null, null, function() {
var bar = document.implementation.createDocument(null, null, null);
return bar.implementation.createDocumentType("bar", "", "");
}(), null], // DOCTYPE created by a different implementation.
[null, null, function() {
var bar = document.implementation.createDocument(null, null, null);
var magic = bar.implementation.createDocumentType("bar", "", "");
bar.implementation.createDocument(null, null, magic);
return magic;
}(), null], // DOCTYPE created by a different implementation and already associated with a document.
[null, "foo", document.implementation.createDocumentType("foo", "", ""), null],
["foo", null, document.implementation.createDocumentType("foo", "", ""), null],
["foo", "bar", document.implementation.createDocumentType("foo", "", ""), null],
]
try { // XXX merge?!
var tempTests = tests.concat([
[null, null, document.implementation.createDocumentType("foo", "", ""), null],
[null, null, document.doctype, "WRONG_DOCUMENT_ERR"], // This causes a horrible WebKit bug (now fixed in trunk).
[null, null, function() {
var foo = document.implementation.createDocumentType("foo", "", "");
document.implementation.createDocument(null, null, foo);
return foo;
}(), "WRONG_DOCUMENT_ERR"], // DOCTYPE already associated with a document.
[null, null, function() {
var bar = document.implementation.createDocument(null, null, null);
return bar.implementation.createDocumentType("bar", "", "");
}(), null], // DOCTYPE created by a different implementation.
[null, null, function() {
var bar = document.implementation.createDocument(null, null, null);
var magic = bar.implementation.createDocumentType("bar", "", "");
bar.implementation.createDocument(null, null, magic);
return magic;
}(), "WRONG_DOCUMENT_ERR"], // DOCTYPE created by a different implementation and already associated with a document.
[null, "foo", document.implementation.createDocumentType("foo", "", ""), null],
["foo", null, document.implementation.createDocumentType("foo", "", ""), null],
["foo", "bar", document.implementation.createDocumentType("foo", "", ""), null],
]);
tests = tempTests;
} catch (e) {
assert_unreached()
}
tests.forEach(function(t, i) {
test(function() {
var namespace = t[0], qualifiedName = t[1], doctype = t[2], expected = t[3]
@ -147,14 +157,31 @@ test(function() {
var doc = document.implementation.createDocument(namespace, qualifiedName, doctype)
assert_equals(doc.nodeType, Node.DOCUMENT_NODE)
assert_equals(doc.nodeType, doc.DOCUMENT_NODE)
if (qualifiedName === "" || qualifiedName === null) {
var omitRootElement = qualifiedName === null || String(qualifiedName) === ""
if (omitRootElement) {
assert_equals(doc.documentElement, null)
} else {
assert_not_equals(doc.documentElement, null)
assert_equals(doc.documentElement.nodeType, Node.ELEMENT_NODE)
var element = doc.documentElement
assert_not_equals(element, null)
assert_equals(element.nodeType, Node.ELEMENT_NODE)
assert_equals(element.ownerDocument, doc)
var qualified = String(qualifiedName), names = []
if (qualified.indexOf(":") >= 0) {
names = qualified.split(":", 2)
} else {
names = [null, qualified]
}
assert_equals(element.prefix, names[0])
assert_equals(element.localName, names[1])
assert_equals(element.namespaceURI, namespace === undefined ? null : namespace)
}
assert_equals(doc.doctype, doctype)
assert_equals(doc.childNodes.length, !!qualifiedName + !!doctype)
if (!doctype) {
assert_equals(doc.doctype, null)
} else {
assert_equals(doc.doctype, doctype)
assert_equals(doc.doctype.ownerDocument, doc)
}
assert_equals(doc.childNodes.length, !omitRootElement + !!doctype)
}
}, "createDocument test " + i + ": " + t.map(function(el) { return format_value(el) }))
})

View File

@ -10,6 +10,18 @@
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
function toASCIIUppercase(str) {
var diff = "a".charCodeAt(0) - "A".charCodeAt(0);
var res = "";
for (var i = 0; i < str.length; ++i) {
if ("a" <= str[i] && str[i] <= "z") {
res += String.fromCharCode(str.charCodeAt(i) - diff);
} else {
res += str[i];
}
}
return res;
}
test(function() {
var HTMLNS = "http://www.w3.org/1999/xhtml",
valid = [
@ -32,7 +44,10 @@ test(function() {
["xmlfoo:bar", "xmlfoo:bar"],
["svg", "svg"],
["math", "math"],
["FOO", "foo"]
["FOO", "foo"],
["mar\u212a", "mar\u212a"],
["\u0130nput", "\u0130nput"],
["\u0131nput", "\u0131nput"]
],
invalid = [
"",
@ -56,7 +71,7 @@ test(function() {
assert_true(elt instanceof Element)
assert_true(elt instanceof Node)
assert_equals(elt.localName, t[1])
assert_equals(elt.tagName, t[1].toUpperCase())
assert_equals(elt.tagName, toASCIIUppercase(t[1]))
assert_equals(elt.prefix, null)
assert_equals(elt.namespaceURI, HTMLNS)
}, "createElement(" + format_value(t[0]) + ")");

View File

@ -22,7 +22,7 @@ function testAlias(arg, iface) {
["HTMLEvents", "Event"],
["MouseEvent", "MouseEvent"],
["MouseEvents", "MouseEvent"],
["UIEvent", "UIEvent"]
["UIEvent", "UIEvent"],
["UIEvents", "UIEvent"]
].forEach(function(alias) {
testAlias(alias[0], alias[1]);

View File

@ -0,0 +1,42 @@
<!doctype html>
<meta charset=utf-8>
<title>Document.createTreeWalker</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function() {
assert_throws(new TypeError(), function() {
document.createTreeWalker();
});
}, "Required arguments to createTreeWalker should be required.");
test(function() {
var tw = document.createTreeWalker(document.body);
assert_equals(tw.root, document.body);
assert_equals(tw.currentNode, document.body);
assert_equals(tw.whatToShow, 0xFFFFFFFF);
assert_equals(tw.filter, null);
}, "Optional arguments to createTreeWalker should be optional (1 passed).");
test(function() {
var tw = document.createTreeWalker(document.body, 42);
assert_equals(tw.root, document.body);
assert_equals(tw.currentNode, document.body);
assert_equals(tw.whatToShow, 42);
assert_equals(tw.filter, null);
}, "Optional arguments to createTreeWalker should be optional (2 passed).");
test(function() {
var tw = document.createTreeWalker(document.body, 42, null);
assert_equals(tw.root, document.body);
assert_equals(tw.currentNode, document.body);
assert_equals(tw.whatToShow, 42);
assert_equals(tw.filter, null);
}, "Optional arguments to createTreeWalker should be optional (3 passed, null).");
test(function() {
var fn = function() {};
var tw = document.createTreeWalker(document.body, 42, fn);
assert_equals(tw.root, document.body);
assert_equals(tw.currentNode, document.body);
assert_equals(tw.whatToShow, 42);
assert_equals(tw.filter, fn);
}, "Optional arguments to createTreeWalker should be optional (3 passed, function).");
</script>

View File

@ -5,22 +5,71 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<pre id="x"></pre>
<script>
// TODO: getElementsByTagName("*")
test(function() {
assert_false(document.getElementsByTagName("html") instanceof NodeList, "NodeList")
assert_true(document.getElementsByTagName("html") instanceof HTMLCollection, "HTMLCollection")
assert_false(document.getElementsByTagName("html") instanceof NodeList,
"Should not return a NodeList")
assert_true(document.getElementsByTagName("html") instanceof HTMLCollection,
"Should return an HTMLCollection")
}, "Interfaces")
test(function() {
var firstCollection = document.getElementsByTagName("html"),
secondCollection = document.getElementsByTagName("html")
assert_true(firstCollection !== secondCollection || firstCollection === secondCollection,
"Caching is allowed.")
})
assert_true(firstCollection !== secondCollection ||
firstCollection === secondCollection)
}, "Caching is allowed")
test(function() {
var l = document.getElementsByTagName("nosuchtag")
l[5] = "foopy"
assert_equals(l[5], undefined)
assert_equals(l.item(5), null)
}, "Shouldn't be able to set unsigned properties on a HTMLCollection")
}, "Shouldn't be able to set unsigned properties on a HTMLCollection (non-strict mode)")
test(function() {
var l = document.getElementsByTagName("nosuchtag")
assert_throws(new TypeError(), function() {
"use strict";
l[5] = "foopy"
})
assert_equals(l[5], undefined)
assert_equals(l.item(5), null)
}, "Shouldn't be able to set unsigned properties on a HTMLCollection (strict mode)")
test(function() {
var l = document.getElementsByTagName("nosuchtag")
var fn = l.item;
assert_equals(fn, HTMLCollection.prototype.item);
l.item = "pass"
assert_equals(l.item, "pass")
assert_equals(HTMLCollection.prototype.item, fn);
}, "Should be able to set expando shadowing a proto prop (item)")
test(function() {
var l = document.getElementsByTagName("nosuchtag")
var fn = l.namedItem;
assert_equals(fn, HTMLCollection.prototype.namedItem);
l.namedItem = "pass"
assert_equals(l.namedItem, "pass")
assert_equals(HTMLCollection.prototype.namedItem, fn);
}, "Should be able to set expando shadowing a proto prop (namedItem)")
test(function() {
var list = document.getElementsByTagName('pre');
var pre = list[0];
assert_equals(pre.id, "x");
assert_equals(list['x'], pre);
assert_true('x' in list, "'x' in list");
assert_true(list.hasOwnProperty('x'), "list.hasOwnProperty('x')");
assert_array_equals(Object.getOwnPropertyNames(list).sort(), ["0", "x"]);
var desc = Object.getOwnPropertyDescriptor(list, 'x');
assert_equals(typeof desc, "object", "descriptor should be an object");
assert_true(desc.enumerable, "desc.enumerable");
assert_true(desc.configurable, "desc.configurable");
}, "hasOwnProperty, getOwnPropertyDescriptor, getOwnPropertyNames")
test(function() {
assert_equals(document.createElementNS("http://www.w3.org/1999/xhtml", "i").localName, "i") // Sanity
var i = document.body.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "I"))

View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<title>Event.type</title>
<link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com">
<link rel="help" href="http://dom.spec.whatwg.org/#dom-event-type">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
test(function() {
var e = document.createEvent("Event")
assert_equals(e.type, "");
}, "Event.type should initially be the empty string");
test(function() {
var e = document.createEvent("Event")
e.initEvent("foo", false, false)
assert_equals(e.type, "foo")
}, "Event.type should be initialized by initEvent");
test(function() {
var e = new Event("bar")
assert_equals(e.type, "bar")
}, "Event.type should be initialized by the constructor");
</script>

View File

@ -50,6 +50,7 @@ function iframeLoaded() {
assert_true(doc1.doctype.isEqualNode(doc2.doctype), "doc1.doctype.isEqualNode(doc2.doctype)")
assert_true(doc1.isEqualNode(doc2), "doc1.isEqualNode(doc2)")
})
internalSubset.done()
}
}
</script>

View File

@ -7,7 +7,6 @@
<script>
var objects = [
[NodeFilter, "NodeFilter interface object"],
[NodeFilter.prototype, "NodeFilter prototype object"]
]
testConstants(objects, [
["FILTER_ACCEPT", 1],

View File

@ -13,10 +13,10 @@ test(function() {
assert_equals(r.endOffset, 0)
assert_true(r.collapsed)
r.detach()
assert_throws("INVALID_STATE_ERR", function() { r.startContainer })
assert_throws("INVALID_STATE_ERR", function() { r.startOffset })
assert_throws("INVALID_STATE_ERR", function() { r.endContainer })
assert_throws("INVALID_STATE_ERR", function() { r.endOffset })
assert_throws("INVALID_STATE_ERR", function() { r.collapsed })
assert_equals(r.startContainer, document)
assert_equals(r.endContainer, document)
assert_equals(r.startOffset, 0)
assert_equals(r.endOffset, 0)
assert_true(r.collapsed)
})
</script>

View File

@ -7,9 +7,7 @@
test(function() {
var range = document.createRange();
range.detach();
assert_throws("INVALID_STATE_ERR", function() {
range.commonAncestorContainer();
}, "Detached Range must throw INVALID_STATE_ERR on accessing commonAncestorContainer");
assert_equals(range.commonAncestorContainer, document);
}, "Detached Range")
test(function() {
var df = document.createDocumentFragment();

View File

@ -8,7 +8,7 @@
test(function() {
var r = document.createRange();
r.detach()
assert_throws("INVALID_STATE_ERR", function() { r.comparePoint(document.body, 0) })
assert_equals(r.comparePoint(document.body, 0), 1)
})
test(function() {
var r = document.createRange();

View File

@ -8,6 +8,6 @@
test(function() {
var r = document.createRange();
r.detach()
assert_throws("INVALID_STATE_ERR", function() { r.detach() })
r.detach()
})
</script>

View File

@ -10,6 +10,7 @@ relativesrcdir := @relativesrcdir@
include $(DEPTH)/config/autoconf.mk
MOCHITEST_FILES := \
test_FormData-append.html \
test_interfaces.html \
test_setrequestheader-invalid-arguments.htm \
$(NULL)

View File

@ -0,0 +1,14 @@
<!doctype html>
<meta charset=utf-8>
<title>FormData.append</title>
<link rel=help href=http://xhr.spec.whatwg.org/#dom-formdata-append>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function() {
var fd = new FormData();
fd.append("name", new String("value"));
// TODO: test that it actually worked.
}, "Passing a String object to FormData.append should work.");
</script>

View File

@ -244,6 +244,9 @@
"docshell/test/test_bug669671.html": " Test timed out.",
"dom/bindings/test/test_InstanceOf.html":"",
"dom/imptests/editing/conformancetest/test_event.html": "",
"dom/imptests/editing/conformancetest/test_runtest.html": "",
"dom/imptests/editing/selecttest/test_addRange.html": "bug 775227",
"dom/imptests/html/webgl": "WebGL",
"dom/imptests/webapps/DOMCore/tests/approved/test_interfaces.html":"",
"dom/tests/mochitest/crypto/test_getRandomValues.html": "",
@ -294,9 +297,11 @@
"dom/imptests/editing/conformancetest/test_runtest.html":"",
"dom/imptests/editing/selecttest/test_Document-open.html":"",
"dom/imptests/webapps/DOMCore/tests/approved/test_Range-cloneContents.html":"",
"dom/imptests/webapps/DOMCore/tests/approved/test_Range-compareBoundaryPoints.html":"",
"dom/imptests/webapps/DOMCore/tests/approved/test_Range-deleteContents.html":"",
"dom/imptests/webapps/DOMCore/tests/approved/test_Range-extractContents.html":"",
"dom/imptests/webapps/DOMCore/tests/approved/test_Range-insertNode.html":"",
"dom/imptests/webapps/DOMCore/tests/approved/test_Range-set.html":"",
"dom/imptests/webapps/DOMCore/tests/approved/test_Range-surroundContents.html":"",
"dom/imptests/webapps/DOMCore/tests/approved/test_Range-mutations.html":" Test timed out.",
"dom/indexedDB/": "",