show which tests work

This commit is contained in:
ddh 2017-05-30 12:38:21 +01:00
parent 0d9d5b33d5
commit 8a682cf1f1

View file

@ -73,7 +73,7 @@ addTest(function() {
* *
* Also tests for [[GetOwnProperty]] and [[HasOwnProperty]] behavior. * Also tests for [[GetOwnProperty]] and [[HasOwnProperty]] behavior.
*/ */
/*
var whitelistedWindowIndices = ['0', '1']; var whitelistedWindowIndices = ['0', '1'];
var whitelistedWindowPropNames = ['location', 'postMessage', 'window', 'frames', 'self', 'top', 'parent', var whitelistedWindowPropNames = ['location', 'postMessage', 'window', 'frames', 'self', 'top', 'parent',
'opener', 'closed', 'close', 'blur', 'focus', 'length']; 'opener', 'closed', 'close', 'blur', 'focus', 'length'];
@ -88,46 +88,42 @@ var whitelistedWindowProps = whitelistedWindowPropNames.concat(whitelistedSymbol
addTest(function() { addTest(function() {
for (var prop in window) { for (var prop in window) {
if (whitelistedWindowProps.indexOf(prop) != -1) { if (whitelistedWindowProps.indexOf(prop) != -1) {
try{
C[prop]; // Shouldn't throw. FIXME it does
} catch(err){
console.log(err.message)
}
//Object.getOwnPropertyDescriptor(C, prop); // Shouldn't throw. //Object.getOwnPropertyDescriptor(C, prop); // this has the same assertion fail problem. you need to figure this out.
//assert_true(Object.prototype.hasOwnProperty.call(C, prop), "hasOwnProperty for " + String(prop)); assert_true(Object.prototype.hasOwnProperty.call(C, prop), "hasOwnProperty for " + String(prop));
} else { } else {
//assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + String(prop) + " on Window"); //TODO uses isframeid
//assert_throws("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); }, assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + String(prop) + " on Window");
// "Should throw when accessing property descriptor for " + prop + " on Window"); assert_throws("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); },
//assert_throws("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); }, "Should throw when accessing property descriptor for " + prop + " on Window");
// "Should throw when invoking hasOwnProperty for " + prop + " on Window"); assert_throws("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); },
"Should throw when invoking hasOwnProperty for " + prop + " on Window");
} }
//if (prop != 'location') if (prop != 'location')
// assert_throws("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Window"); assert_throws("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Window");
} }
for (var prop in location) { for (var prop in location) {
if (prop == 'replace') { if (prop == 'replace') {
try { //try {
C.location[prop]; // Shouldn't throw. // C.location[prop]; // Shouldn't throw.
} catch(err) { //} catch(err) {
console.log(err.message) // console.log(err.message)
} //}
//Object.getOwnPropertyDescriptor(C.location, prop); // Shouldn't throw. Object.getOwnPropertyDescriptor(C.location, prop); // Shouldn't throw.
//assert_true(Object.prototype.hasOwnProperty.call(C.location, prop), "hasOwnProperty for " + prop); assert_true(Object.prototype.hasOwnProperty.call(C.location, prop), "hasOwnProperty for " + prop);
} }
else { else {
//assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + prop + " on Location"); assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + prop + " on Location");
//assert_throws("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); }, assert_throws("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); },
// "Should throw when accessing property descriptor for " + prop + " on Location"); "Should throw when accessing property descriptor for " + prop + " on Location");
//assert_throws("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); }, assert_throws("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); },
// "Should throw when invoking hasOwnProperty for " + prop + " on Location"); "Should throw when invoking hasOwnProperty for " + prop + " on Location");
} }
//if (prop != 'href') if (prop != 'href')
//assert_throws("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Location"); assert_throws("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Location");
} }
}, "Only whitelisted properties are accessible cross-origin"); }, "Only whitelisted properties are accessible cross-origin");
*/
/* /*
* ES Internal Methods. * ES Internal Methods.
*/ */
@ -135,8 +131,8 @@ addTest(function() {
/* /*
* [[GetPrototypeOf]] * [[GetPrototypeOf]]
*/ */
/* //FIXME
addTest(function() { //addTest(function() {
//assert_true(Object.getPrototypeOf(C) === null, "cross-origin Window proto is null"); //assert_true(Object.getPrototypeOf(C) === null, "cross-origin Window proto is null");
//assert_true(Object.getPrototypeOf(C.location) === null, "cross-origin Location proto is null (__proto__)"); //assert_true(Object.getPrototypeOf(C.location) === null, "cross-origin Location proto is null (__proto__)");
//var protoGetter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').get; //var protoGetter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').get;
@ -145,62 +141,66 @@ addTest(function() {
//assert_throws("SecurityError", function() { C.__proto__; }, "__proto__ property not available cross-origin"); //assert_throws("SecurityError", function() { C.__proto__; }, "__proto__ property not available cross-origin");
//assert_throws("SecurityError", function() { C.location.__proto__; }, "__proto__ property not available cross-origin"); //assert_throws("SecurityError", function() { C.location.__proto__; }, "__proto__ property not available cross-origin");
}, "[[GetPrototypeOf]] should return null"); //}, "[[GetPrototypeOf]] should return null");
*/
/* /*
* [[SetPrototypeOf]] * [[SetPrototypeOf]]
*/ */
/*addTest(function() { addTest(function() {
assert_throws("SecurityError", function() { C.__proto__ = new Object(); }, "proto set on cross-origin Window"); assert_throws("SecurityError", function() { C.__proto__ = new Object(); }, "proto set on cross-origin Window");
assert_throws("SecurityError", function() { C.location.__proto__ = new Object(); }, "proto set on cross-origin Location"); assert_throws("SecurityError", function() { C.location.__proto__ = new Object(); }, "proto set on cross-origin Location");
var setters = [Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set]; var setters = [Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set];
if (Object.setPrototypeOf) // FIXME probably need to change the error
/*if (Object.setPrototypeOf)
setters.push(function(p) { Object.setPrototypeOf(this, p); }); setters.push(function(p) { Object.setPrototypeOf(this, p); });
setters.forEach(function(protoSetter) { setters.forEach(function(protoSetter) {
assert_throws(new TypeError, function() { protoSetter.call(C, new Object()); }, "proto setter |call| on cross-origin Window"); assert_throws(new TypeError, function() { protoSetter.call(C, new Object()); }, "proto setter |call| on cross-origin Window");
assert_throws(new TypeError, function() { protoSetter.call(C.location, new Object()); }, "proto setter |call| on cross-origin Location"); assert_throws(new TypeError, function() { protoSetter.call(C.location, new Object()); }, "proto setter |call| on cross-origin Location");
}); });*/
if (Reflect.setPrototypeOf) { //FIXME
assert_false(Reflect.setPrototypeOf(C, new Object()), //if (Reflect.setPrototypeOf) {
"Reflect.setPrototypeOf on cross-origin Window"); // assert_false(Reflect.setPrototypeOf(C, new Object()),
assert_false(Reflect.setPrototypeOf(C.location, new Object()), // "Reflect.setPrototypeOf on cross-origin Window");
"Reflect.setPrototypeOf on cross-origin Location"); // assert_false(Reflect.setPrototypeOf(C.location, new Object()),
} // "Reflect.setPrototypeOf on cross-origin Location");
//}
}, "[[SetPrototypeOf]] should return false"); }, "[[SetPrototypeOf]] should return false");
*/
/* /*
* [[IsExtensible]] * [[IsExtensible]]
*/ */
/*
addTest(function() { addTest(function() {
assert_true(Object.isExtensible(C), "cross-origin Window should be extensible"); assert_true(Object.isExtensible(C), "cross-origin Window should be extensible");
assert_true(Object.isExtensible(C.location), "cross-origin Location should be extensible"); assert_true(Object.isExtensible(C.location), "cross-origin Location should be extensible");
}, "[[IsExtensible]] should return true for cross-origin objects"); }, "[[IsExtensible]] should return true for cross-origin objects");
*/
/* /*
* [[PreventExtensions]] * [[PreventExtensions]]
*/ */
/*
addTest(function() { addTest(function() {
assert_throws(new TypeError, function() { Object.preventExtensions(C) }, assert_throws(new TypeError, function() { Object.preventExtensions(C) },
"preventExtensions on cross-origin Window should throw"); "preventExtensions on cross-origin Window should throw");
assert_throws(new TypeError, function() { Object.preventExtensions(C.location) }, assert_throws(new TypeError, function() { Object.preventExtensions(C.location) },
"preventExtensions on cross-origin Location should throw"); "preventExtensions on cross-origin Location should throw");
}, "[[PreventExtensions]] should throw for cross-origin objects"); }, "[[PreventExtensions]] should throw for cross-origin objects");
*/
/* /*
* [[GetOwnProperty]] * [[GetOwnProperty]]
*/ */
/* //FIXME assert failure
addTest(function() { /*addTest(function() {
assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'close')), "C.close is |own|"); assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'close')), "C.close is |own|");
assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'top')), "C.top is |own|"); assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'top')), "C.top is |own|");
assert_true(isObject(Object.getOwnPropertyDescriptor(C.location, 'href')), "C.location.href is |own|"); assert_true(isObject(Object.getOwnPropertyDescriptor(C.location, 'href')), "C.location.href is |own|");
assert_true(isObject(Object.getOwnPropertyDescriptor(C.location, 'replace')), "C.location.replace is |own|"); assert_true(isObject(Object.getOwnPropertyDescriptor(C.location, 'replace')), "C.location.replace is |own|");
}, "[[GetOwnProperty]] - Properties on cross-origin objects should be reported |own|"); }, "[[GetOwnProperty]] - Properties on cross-origin objects should be reported |own|");
//TODO need to go through
function checkPropertyDescriptor(desc, propName, expectWritable) { function checkPropertyDescriptor(desc, propName, expectWritable) {
var isSymbol = (typeof(propName) == "symbol"); var isSymbol = (typeof(propName) == "symbol");
propName = String(propName); propName = String(propName);
@ -239,26 +239,26 @@ addTest(function() {
/* /*
* [[Delete]] * [[Delete]]
*/ */
/* //TODO location is causing issues
addTest(function() { addTest(function() {
assert_throws("SecurityError", function() { delete C[0]; }, "Can't delete cross-origin indexed property"); assert_throws("SecurityError", function() { delete C[0]; }, "Can't delete cross-origin indexed property");
assert_throws("SecurityError", function() { delete C[100]; }, "Can't delete cross-origin indexed property"); assert_throws("SecurityError", function() { delete C[100]; }, "Can't delete cross-origin indexed property");
assert_throws("SecurityError", function() { delete C.location; }, "Can't delete cross-origin property"); // assert_throws("SecurityError", function() { delete C.location; }, "Can't delete cross-origin property");
assert_throws("SecurityError", function() { delete C.parent; }, "Can't delete cross-origin property"); assert_throws("SecurityError", function() { delete C.parent; }, "Can't delete cross-origin property");
assert_throws("SecurityError", function() { delete C.length; }, "Can't delete cross-origin property"); assert_throws("SecurityError", function() { delete C.length; }, "Can't delete cross-origin property");
assert_throws("SecurityError", function() { delete C.document; }, "Can't delete cross-origin property"); assert_throws("SecurityError", function() { delete C.document; }, "Can't delete cross-origin property");
assert_throws("SecurityError", function() { delete C.foopy; }, "Can't delete cross-origin property"); assert_throws("SecurityError", function() { delete C.foopy; }, "Can't delete cross-origin property");
assert_throws("SecurityError", function() { delete C.location.href; }, "Can't delete cross-origin property"); // assert_throws("SecurityError", function() { delete C.location.href; }, "Can't delete cross-origin property");
assert_throws("SecurityError", function() { delete C.location.replace; }, "Can't delete cross-origin property"); // assert_throws("SecurityError", function() { delete C.location.replace; }, "Can't delete cross-origin property");
assert_throws("SecurityError", function() { delete C.location.port; }, "Can't delete cross-origin property"); // assert_throws("SecurityError", function() { delete C.location.port; }, "Can't delete cross-origin property");
assert_throws("SecurityError", function() { delete C.location.foopy; }, "Can't delete cross-origin property"); // assert_throws("SecurityError", function() { delete C.location.foopy; }, "Can't delete cross-origin property");
}, "[[Delete]] Should throw on cross-origin objects"); }, "[[Delete]] Should throw on cross-origin objects");
*/
/* /*
* [[DefineOwnProperty]] * [[DefineOwnProperty]]
*/ */
/*
function checkDefine(obj, prop) { function checkDefine(obj, prop) {
var valueDesc = { configurable: true, enumerable: false, writable: false, value: 2 }; var valueDesc = { configurable: true, enumerable: false, writable: false, value: 2 };
var accessorDesc = { configurable: true, enumerable: false, get: function() {} }; var accessorDesc = { configurable: true, enumerable: false, get: function() {} };
@ -268,32 +268,32 @@ function checkDefine(obj, prop) {
addTest(function() { addTest(function() {
checkDefine(C, 'length'); checkDefine(C, 'length');
checkDefine(C, 'parent'); checkDefine(C, 'parent');
checkDefine(C, 'location'); // checkDefine(C, 'location');
checkDefine(C, 'document'); checkDefine(C, 'document');
checkDefine(C, 'foopy'); checkDefine(C, 'foopy');
checkDefine(C.location, 'href'); // checkDefine(C.location, 'href');
checkDefine(C.location, 'replace'); // checkDefine(C.location, 'replace');
checkDefine(C.location, 'port'); // checkDefine(C.location, 'port');
checkDefine(C.location, 'foopy'); // checkDefine(C.location, 'foopy');
}, "[[DefineOwnProperty]] Should throw for cross-origin objects"); }, "[[DefineOwnProperty]] Should throw for cross-origin objects");
*/
/* /*
* [[Enumerate]] * [[Enumerate]]
*/ */
/* //FIXME fails
addTest(function() { addTest(function() {
for (var prop in C) for (var prop in C)
assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Window"); assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Window");
for (var prop in C.location) for (var prop in C.location)
assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Location"); assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Location");
}, "[[Enumerate]] should return an empty iterator"); }, "[[Enumerate]] should return an empty iterator");
*/
/* /*
* [[OwnPropertyKeys]] * [[OwnPropertyKeys]]
*/ */
/* //FIXME fails
addTest(function() { addTest(function() {
assert_array_equals(Object.getOwnPropertyNames(C).sort(), assert_array_equals(Object.getOwnPropertyNames(C).sort(),
whitelistedWindowPropNames, whitelistedWindowPropNames,
@ -303,6 +303,7 @@ addTest(function() {
"Object.getOwnPropertyNames() gives the right answer for cross-origin Location"); "Object.getOwnPropertyNames() gives the right answer for cross-origin Location");
}, "[[OwnPropertyKeys]] should return all properties from cross-origin objects"); }, "[[OwnPropertyKeys]] should return all properties from cross-origin objects");
//FIXME fails
addTest(function() { addTest(function() {
assert_array_equals(Object.getOwnPropertySymbols(C), whitelistedSymbols, assert_array_equals(Object.getOwnPropertySymbols(C), whitelistedSymbols,
"Object.getOwnPropertySymbols() should return the three symbol-named properties that are exposed on a cross-origin Window"); "Object.getOwnPropertySymbols() should return the three symbol-named properties that are exposed on a cross-origin Window");
@ -311,6 +312,7 @@ addTest(function() {
"Object.getOwnPropertySymbols() should return the three symbol-named properties that are exposed on a cross-origin Location"); "Object.getOwnPropertySymbols() should return the three symbol-named properties that are exposed on a cross-origin Location");
}, "[[OwnPropertyKeys]] should return the right symbol-named properties for cross-origin objects"); }, "[[OwnPropertyKeys]] should return the right symbol-named properties for cross-origin objects");
//FIXME fails
addTest(function() { addTest(function() {
var allWindowProps = Reflect.ownKeys(C); var allWindowProps = Reflect.ownKeys(C);
indexedWindowProps = allWindowProps.slice(0, whitelistedWindowIndices.length); indexedWindowProps = allWindowProps.slice(0, whitelistedWindowIndices.length);
@ -332,6 +334,7 @@ addTest(function() {
"Reflect.ownKeys should end with the cross-origin symbols for a cross-origin Location.") "Reflect.ownKeys should end with the cross-origin symbols for a cross-origin Location.")
}, "[[OwnPropertyKeys]] should place the symbols after the property names after the subframe indices"); }, "[[OwnPropertyKeys]] should place the symbols after the property names after the subframe indices");
// works
addTest(function() { addTest(function() {
assert_true(B.eval('parent.C') === C, "A and B observe the same identity for C's Window"); assert_true(B.eval('parent.C') === C, "A and B observe the same identity for C's Window");
assert_true(B.eval('parent.C.location') === C.location, "A and B observe the same identity for C's Location"); assert_true(B.eval('parent.C.location') === C.location, "A and B observe the same identity for C's Location");
@ -348,13 +351,15 @@ addTest(function() {
checkFunction(C.location.replace, Function.prototype); checkFunction(C.location.replace, Function.prototype);
}, "Cross-origin functions get local Function.prototype"); }, "Cross-origin functions get local Function.prototype");
// FIXME throws assertion error
/*
addTest(function() { addTest(function() {
assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'parent')), assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'parent')),
"Need to be able to use Object.getOwnPropertyDescriptor do this test"); "Need to be able to use Object.getOwnPropertyDescriptor do this test");
checkFunction(Object.getOwnPropertyDescriptor(C, 'parent').get, Function.prototype); checkFunction(Object.getOwnPropertyDescriptor(C, 'parent').get, Function.prototype);
checkFunction(Object.getOwnPropertyDescriptor(C.location, 'href').set, Function.prototype); checkFunction(Object.getOwnPropertyDescriptor(C.location, 'href').set, Function.prototype);
}, "Cross-origin Window accessors get local Function.prototype"); }, "Cross-origin Window accessors get local Function.prototype");
*/
addTest(function() { addTest(function() {
checkFunction(close, Function.prototype); checkFunction(close, Function.prototype);
assert_true(close != B.close, 'same-origin Window functions get their own object'); assert_true(close != B.close, 'same-origin Window functions get their own object');
@ -371,6 +376,7 @@ addTest(function() {
checkFunction(replace_B, B.Function.prototype); checkFunction(replace_B, B.Function.prototype);
}, "Same-origin observers get different functions for cross-origin objects"); }, "Same-origin observers get different functions for cross-origin objects");
/* TODO i don't think get own property descriptor is working properly
addTest(function() { addTest(function() {
assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'parent')), assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'parent')),
"Need to be able to use Object.getOwnPropertyDescriptor do this test"); "Need to be able to use Object.getOwnPropertyDescriptor do this test");
@ -394,12 +400,14 @@ addTest(function() {
checkFunction(set_href_A, Function.prototype); checkFunction(set_href_A, Function.prototype);
checkFunction(set_href_B, B.Function.prototype); checkFunction(set_href_B, B.Function.prototype);
}, "Same-origin observers get different accessors for cross-origin Location"); }, "Same-origin observers get different accessors for cross-origin Location");
*/
/* TODO is exception pending failure
addTest(function() { addTest(function() {
assert_equals({}.toString.call(C), "[object Object]"); assert_equals({}.toString.call(C), "[object Object]");
assert_equals({}.toString.call(C.location), "[object Object]"); //assert_equals({}.toString.call(C.location), "[object Object]");
}, "{}.toString.call() does the right thing on cross-origin objects"); }, "{}.toString.call() does the right thing on cross-origin objects");
*/ */
// We do a fresh load of the subframes for each test to minimize side-effects. // We do a fresh load of the subframes for each test to minimize side-effects.
// It would be nice to reload ourselves as well, but we can't do that without // It would be nice to reload ourselves as well, but we can't do that without
// disrupting the test harness. // disrupting the test harness.