mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
debugging
This commit is contained in:
parent
9a7978ef4c
commit
2346420654
1 changed files with 41 additions and 35 deletions
|
@ -51,7 +51,7 @@ function addTest(fun, desc) { testList.push([fun, desc]); }
|
||||||
/*
|
/*
|
||||||
* Basic sanity testing.
|
* Basic sanity testing.
|
||||||
*/
|
*/
|
||||||
///* passes -1
|
/* passes -1
|
||||||
addTest(function() {
|
addTest(function() {
|
||||||
// Note: we do not check location.host as its default port semantics are hard to reflect statically
|
// Note: we do not check location.host as its default port semantics are hard to reflect statically
|
||||||
assert_equals(location.hostname, host_info.ORIGINAL_HOST, 'Need to run the top-level test from domain ' + host_info.ORIGINAL_HOST);
|
assert_equals(location.hostname, host_info.ORIGINAL_HOST, 'Need to run the top-level test from domain ' + host_info.ORIGINAL_HOST);
|
||||||
|
@ -66,13 +66,13 @@ addTest(function() {
|
||||||
console.log(C.frames);
|
console.log(C.frames);
|
||||||
//assert_equals(C.frames, C, "Overrides invisible in the cross-origin case");
|
//assert_equals(C.frames, C, "Overrides invisible in the cross-origin case");
|
||||||
}, "Basic sanity-checking");
|
}, "Basic sanity-checking");
|
||||||
//*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Whitelist behavior.
|
* Whitelist behavior.
|
||||||
*
|
*
|
||||||
* Also tests for [[GetOwnProperty]] and [[HasOwnProperty]] behavior.
|
* Also tests for [[GetOwnProperty]] and [[HasOwnProperty]] behavior.
|
||||||
*/
|
*/
|
||||||
//passes -location
|
/*
|
||||||
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'];
|
||||||
|
@ -92,10 +92,9 @@ addTest(function() {
|
||||||
for (var prop in window) {
|
for (var prop in window) {
|
||||||
if (whitelistedWindowProps.indexOf(prop) != -1) {
|
if (whitelistedWindowProps.indexOf(prop) != -1) {
|
||||||
|
|
||||||
//Object.getOwnPropertyDescriptor(C, prop); // this has the same assertion fail problem. you need to figure this out.
|
Object.getOwnPropertyDescriptor(C, prop);
|
||||||
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 {
|
||||||
//TODO uses isframeid
|
|
||||||
assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + String(prop) + " on Window");
|
assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + String(prop) + " on Window");
|
||||||
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 Window");
|
"Should throw when accessing property descriptor for " + prop + " on Window");
|
||||||
|
@ -107,12 +106,7 @@ addTest(function() {
|
||||||
}
|
}
|
||||||
for (var prop in location) {
|
for (var prop in location) {
|
||||||
if (prop == 'replace') {
|
if (prop == 'replace') {
|
||||||
//try {
|
Object.getOwnPropertyDescriptor(C.location, prop);
|
||||||
// C.location[prop]; // Shouldn't throw.
|
|
||||||
//} catch(err) {
|
|
||||||
// console.log(err.message)
|
|
||||||
//}
|
|
||||||
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 {
|
||||||
|
@ -126,7 +120,7 @@ addTest(function() {
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
|
@ -134,7 +128,7 @@ addTest(function() {
|
||||||
/*
|
/*
|
||||||
* [[GetPrototypeOf]]
|
* [[GetPrototypeOf]]
|
||||||
*/
|
*/
|
||||||
///* works
|
/* works
|
||||||
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__)");
|
||||||
|
@ -145,12 +139,12 @@ addTest(function() {
|
||||||
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]]
|
||||||
*/
|
*/
|
||||||
//TODO i changed everything to a security error instead of false/typeerror. at least it's not allowed?
|
//TODO i changed everything to a security error instead of false/typeerror. at least it's not allowed?
|
||||||
///*
|
/*
|
||||||
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");
|
||||||
|
@ -174,40 +168,41 @@ addTest(function() {
|
||||||
// "Reflect.setPrototypeOf on cross-origin Location");
|
// "Reflect.setPrototypeOf on cross-origin Location");
|
||||||
}
|
}
|
||||||
}, "[[SetPrototypeOf]] should return false");
|
}, "[[SetPrototypeOf]] should return false");
|
||||||
//*/
|
*/
|
||||||
/*
|
/*
|
||||||
* [[IsExtensible]]
|
* [[IsExtensible]]
|
||||||
*/
|
*/
|
||||||
///* passes
|
/* passes
|
||||||
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]]
|
||||||
*/
|
*/
|
||||||
///* passes
|
/* passes
|
||||||
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]]
|
||||||
*/
|
*/
|
||||||
///* passes
|
/* passes
|
||||||
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
|
//TODO need to go through
|
||||||
function checkPropertyDescriptor(desc, propName, expectWritable) {
|
function checkPropertyDescriptor(desc, propName, expectWritable) {
|
||||||
|
@ -248,7 +243,7 @@ addTest(function() {
|
||||||
/*
|
/*
|
||||||
* [[Delete]]
|
* [[Delete]]
|
||||||
*/
|
*/
|
||||||
///*
|
/*
|
||||||
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");
|
||||||
|
@ -262,12 +257,12 @@ addTest(function() {
|
||||||
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() {} };
|
||||||
|
@ -285,24 +280,35 @@ addTest(function() {
|
||||||
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
|
//FIXME fails
|
||||||
// addTest(function() {
|
addTest(function() {
|
||||||
// for (var prop in C)
|
console.log("absurd");
|
||||||
// assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Window");
|
// try {
|
||||||
// for (var prop in C.location)
|
for (var prop in C) {
|
||||||
// assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Location");
|
// //console.log("this is nonsense");
|
||||||
// }, "[[Enumerate]] should return an empty iterator");
|
// console.log(prop);
|
||||||
|
assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Window");
|
||||||
|
}
|
||||||
|
// } catch (err) {
|
||||||
|
// console.log(err);
|
||||||
|
// }
|
||||||
|
// works
|
||||||
|
// for (var prop in C.location) {
|
||||||
|
// assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Location");
|
||||||
|
// }
|
||||||
|
console.log("finish")
|
||||||
|
}, "[[Enumerate]] should return an empty iterator");
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* [[OwnPropertyKeys]]
|
* [[OwnPropertyKeys]]
|
||||||
*/
|
*/
|
||||||
//FIXME fails
|
//FIXME is missing 7 properties
|
||||||
addTest(function() {
|
/*addTest(function() {
|
||||||
assert_array_equals(Object.getOwnPropertyNames(C).sort(),
|
assert_array_equals(Object.getOwnPropertyNames(C).sort(),
|
||||||
whitelistedWindowPropSubset,//whitelistedWindowPropNames,
|
whitelistedWindowPropSubset,//whitelistedWindowPropNames,
|
||||||
"Object.getOwnPropertyNames() gives the almost-right answer for cross-origin Window");
|
"Object.getOwnPropertyNames() gives the almost-right answer for cross-origin Window");
|
||||||
|
@ -310,7 +316,7 @@ addTest(function() {
|
||||||
whitelistedLocationPropNames,
|
whitelistedLocationPropNames,
|
||||||
"Object.getOwnPropertyNames() gives the right answer for cross-origin Location");
|
"Object.getOwnPropertyNames() gives the right answer for cross-origin Location");
|
||||||
}, "[[OwnPropertyKeys]] almost returns all properties from cross-origin objects (FIXME)");
|
}, "[[OwnPropertyKeys]] almost returns all properties from cross-origin objects (FIXME)");
|
||||||
|
*/
|
||||||
// //FIXME fails
|
// //FIXME fails
|
||||||
// addTest(function() {
|
// addTest(function() {
|
||||||
// assert_array_equals(Object.getOwnPropertySymbols(C), whitelistedSymbols,
|
// assert_array_equals(Object.getOwnPropertySymbols(C), whitelistedSymbols,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue