mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Update web-platform-tests to revision 7ed49cff4d031720f829c01df837ed7a09ad5c60
This commit is contained in:
parent
33f0040496
commit
62a9bebeef
220 changed files with 8623 additions and 559 deletions
|
@ -271,6 +271,7 @@ ReflectionTests.typeMap = {
|
|||
* "keywords": array of keywords as given by the spec (required)
|
||||
* "nonCanon": dictionary mapping non-canonical values to their
|
||||
* canonical equivalents (defaults to {})
|
||||
* "isNullable": Indicates if attribute is nullable (defaults to false)
|
||||
*
|
||||
* Tests are mostly hardcoded into reflects(), since they depend on the
|
||||
* keywords. All expected values are computed in reflects() using a helper
|
||||
|
@ -592,9 +593,14 @@ ReflectionTests.doReflects = function(data, idlName, idlObj, domName, domObj) {
|
|||
|
||||
var typeInfo = this.typeMap[data.type];
|
||||
|
||||
if (typeof data.isNullable == "undefined") {
|
||||
data.isNullable = false;
|
||||
}
|
||||
|
||||
// Test that typeof idlObj[idlName] is correct. If not, further tests are
|
||||
// probably pointless, so bail out.
|
||||
if (!ReflectionHarness.test(typeof idlObj[idlName], typeInfo.jsType, "typeof IDL attribute")) {
|
||||
var isDefaultValueNull = data.isNullable && data.defaultVal === null;
|
||||
if (!ReflectionHarness.test(typeof idlObj[idlName], isDefaultValueNull ? "object" : typeInfo.jsType, "typeof IDL attribute")) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -603,7 +609,7 @@ ReflectionTests.doReflects = function(data, idlName, idlObj, domName, domObj) {
|
|||
if (defaultVal === undefined) {
|
||||
defaultVal = typeInfo.defaultVal;
|
||||
}
|
||||
if (defaultVal !== null) {
|
||||
if (defaultVal !== null || data.isNullable) {
|
||||
ReflectionHarness.test(idlObj[idlName], defaultVal, "IDL get with DOM attribute unset");
|
||||
}
|
||||
|
||||
|
@ -650,7 +656,14 @@ ReflectionTests.doReflects = function(data, idlName, idlObj, domName, domObj) {
|
|||
|
||||
// Per spec, the expected DOM values are the same as the value we set
|
||||
// it to.
|
||||
idlDomExpected = idlTests.slice(0);
|
||||
if (!data.isNullable) {
|
||||
idlDomExpected = idlTests.slice(0);
|
||||
} else {
|
||||
idlDomExpected = [];
|
||||
for (var i = 0; i < idlTests.length; i++) {
|
||||
idlDomExpected.push((idlTests[i] === null || idlTests[i] === undefined) ? null : idlTests[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Now we have the fun of calculating what the expected IDL values are.
|
||||
domExpected = [];
|
||||
|
@ -659,7 +672,11 @@ ReflectionTests.doReflects = function(data, idlName, idlObj, domName, domObj) {
|
|||
domExpected.push(this.enumExpected(data.keywords, data.nonCanon, data.invalidVal, domTests[i]));
|
||||
}
|
||||
for (var i = 0; i < idlTests.length; i++) {
|
||||
idlIdlExpected.push(this.enumExpected(data.keywords, data.nonCanon, data.invalidVal, idlTests[i]));
|
||||
if (data.isNullable && (idlTests[i] === null || idlTests[i] === undefined)) {
|
||||
idlIdlExpected.push(null);
|
||||
} else {
|
||||
idlIdlExpected.push(this.enumExpected(data.keywords, data.nonCanon, data.invalidVal, idlTests[i]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -687,7 +704,7 @@ ReflectionTests.doReflects = function(data, idlName, idlObj, domName, domObj) {
|
|||
|
||||
if (!data.customGetter) {
|
||||
for (var i = 0; i < domTests.length; i++) {
|
||||
if (domExpected[i] === null) {
|
||||
if (domExpected[i] === null && !data.isNullable) {
|
||||
// If you follow all the complicated logic here, you'll find that
|
||||
// this will only happen if there's no expected value at all (like
|
||||
// for tabIndex, where the default is too complicated). So skip
|
||||
|
@ -723,10 +740,14 @@ ReflectionTests.doReflects = function(data, idlName, idlObj, domName, domObj) {
|
|||
if (data.type == "boolean") {
|
||||
// Special case yay
|
||||
ReflectionHarness.test(domObj.hasAttribute(domName), Boolean(idlTests[i]), "IDL set to " + ReflectionHarness.stringRep(idlTests[i]) + " followed by hasAttribute()");
|
||||
} else if (idlDomExpected[i] !== null) {
|
||||
ReflectionHarness.test(domObj.getAttribute(domName), idlDomExpected[i] + "", "IDL set to " + ReflectionHarness.stringRep(idlTests[i]) + " followed by getAttribute()");
|
||||
} else if (idlDomExpected[i] !== null || data.isNullable) {
|
||||
var expected = idlDomExpected[i] + "";
|
||||
if (data.isNullable && idlDomExpected[i] === null) {
|
||||
expected = null;
|
||||
}
|
||||
ReflectionHarness.test(domObj.getAttribute(domName), expected, "IDL set to " + ReflectionHarness.stringRep(idlTests[i]) + " followed by getAttribute()");
|
||||
}
|
||||
if (idlIdlExpected[i] !== null) {
|
||||
if (idlIdlExpected[i] !== null || data.isNullable) {
|
||||
ReflectionHarness.test(idlObj[idlName], idlIdlExpected[i], "IDL set to " + ReflectionHarness.stringRep(idlTests[i]) + " followed by IDL get");
|
||||
}
|
||||
if (ReflectionHarness.catchUnexpectedExceptions) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue