diff options
author | ddh <dianehosfelt@gmail.com> | 2017-05-30 12:38:21 +0100 |
---|---|---|
committer | ddh <dianehosfelt@gmail.com> | 2017-05-30 12:38:21 +0100 |
commit | 8a682cf1f1d3d71d224654ae9bf67f04b987e1c2 (patch) | |
tree | 7b1a95f12629c649b6987bc1bb28eec90f1c8cdd | |
parent | 0d9d5b33d537f99e2239240d8085e116fca72955 (diff) | |
download | servo-8a682cf1f1d3d71d224654ae9bf67f04b987e1c2.tar.gz servo-8a682cf1f1d3d71d224654ae9bf67f04b987e1c2.zip |
show which tests work
-rw-r--r-- | tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html | 152 |
1 files changed, 80 insertions, 72 deletions
diff --git a/tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html b/tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html index c39668e55a5..9bef6d12211 100644 --- a/tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html +++ b/tests/wpt/web-platform-tests/html/browsers/origin/cross-origin-objects/cross-origin-objects.html @@ -73,7 +73,7 @@ addTest(function() { * * Also tests for [[GetOwnProperty]] and [[HasOwnProperty]] behavior. */ -/* + var whitelistedWindowIndices = ['0', '1']; var whitelistedWindowPropNames = ['location', 'postMessage', 'window', 'frames', 'self', 'top', 'parent', 'opener', 'closed', 'close', 'blur', 'focus', 'length']; @@ -88,46 +88,42 @@ var whitelistedWindowProps = whitelistedWindowPropNames.concat(whitelistedSymbol addTest(function() { for (var prop in window) { 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. - //assert_true(Object.prototype.hasOwnProperty.call(C, prop), "hasOwnProperty for " + String(prop)); + + //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)); } else { - //assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + String(prop) + " on Window"); - //assert_throws("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); }, - // "Should throw when accessing property descriptor for " + prop + " on Window"); - //assert_throws("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); }, - // "Should throw when invoking hasOwnProperty for " + prop + " on Window"); + //TODO uses isframeid + assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + String(prop) + " on Window"); + assert_throws("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); }, + "Should throw when accessing property descriptor 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') - // assert_throws("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Window"); + if (prop != 'location') + assert_throws("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Window"); } for (var prop in location) { if (prop == 'replace') { - try { - 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); + //try { + // 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); } else { - //assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + prop + " on Location"); - //assert_throws("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); }, - // "Should throw when accessing property descriptor for " + prop + " on Location"); - //assert_throws("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); }, - // "Should throw when invoking hasOwnProperty for " + prop + " on Location"); + assert_throws("SecurityError", function() { C[prop]; }, "Should throw when accessing " + prop + " on Location"); + assert_throws("SecurityError", function() { Object.getOwnPropertyDescriptor(C, prop); }, + "Should throw when accessing property descriptor for " + prop + " on Location"); + assert_throws("SecurityError", function() { Object.prototype.hasOwnProperty.call(C, prop); }, + "Should throw when invoking hasOwnProperty for " + prop + " on Location"); } - //if (prop != 'href') - //assert_throws("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Location"); + if (prop != 'href') + assert_throws("SecurityError", function() { C[prop] = undefined; }, "Should throw when writing to " + prop + " on Location"); } }, "Only whitelisted properties are accessible cross-origin"); -*/ + /* * ES Internal Methods. */ @@ -135,8 +131,8 @@ addTest(function() { /* * [[GetPrototypeOf]] */ -/* -addTest(function() { +//FIXME +//addTest(function() { //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__)"); //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.location.__proto__; }, "__proto__ property not available cross-origin"); -}, "[[GetPrototypeOf]] should return null"); -*/ +//}, "[[GetPrototypeOf]] should return null"); + /* * [[SetPrototypeOf]] */ -/*addTest(function() { +addTest(function() { 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"); 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.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.location, new Object()); }, "proto setter |call| on cross-origin Location"); - }); - if (Reflect.setPrototypeOf) { - assert_false(Reflect.setPrototypeOf(C, new Object()), - "Reflect.setPrototypeOf on cross-origin Window"); - assert_false(Reflect.setPrototypeOf(C.location, new Object()), - "Reflect.setPrototypeOf on cross-origin Location"); - } + });*/ + //FIXME + //if (Reflect.setPrototypeOf) { + // assert_false(Reflect.setPrototypeOf(C, new Object()), + // "Reflect.setPrototypeOf on cross-origin Window"); + // assert_false(Reflect.setPrototypeOf(C.location, new Object()), + // "Reflect.setPrototypeOf on cross-origin Location"); + //} }, "[[SetPrototypeOf]] should return false"); -*/ + /* * [[IsExtensible]] */ -/* + addTest(function() { assert_true(Object.isExtensible(C), "cross-origin Window should be extensible"); assert_true(Object.isExtensible(C.location), "cross-origin Location should be extensible"); }, "[[IsExtensible]] should return true for cross-origin objects"); -*/ + /* * [[PreventExtensions]] */ -/* + addTest(function() { assert_throws(new TypeError, function() { Object.preventExtensions(C) }, "preventExtensions on cross-origin Window should throw"); assert_throws(new TypeError, function() { Object.preventExtensions(C.location) }, "preventExtensions on cross-origin Location should throw"); }, "[[PreventExtensions]] should throw for cross-origin objects"); -*/ + /* * [[GetOwnProperty]] */ -/* -addTest(function() { +//FIXME assert failure +/*addTest(function() { 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.location, 'href')), "C.location.href 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|"); + +//TODO need to go through function checkPropertyDescriptor(desc, propName, expectWritable) { var isSymbol = (typeof(propName) == "symbol"); propName = String(propName); @@ -239,26 +239,26 @@ addTest(function() { /* * [[Delete]] */ -/* +//TODO location is causing issues addTest(function() { 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.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.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.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.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.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.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.foopy; }, "Can't delete cross-origin property"); }, "[[Delete]] Should throw on cross-origin objects"); -*/ + /* * [[DefineOwnProperty]] */ -/* + function checkDefine(obj, prop) { var valueDesc = { configurable: true, enumerable: false, writable: false, value: 2 }; var accessorDesc = { configurable: true, enumerable: false, get: function() {} }; @@ -268,32 +268,32 @@ function checkDefine(obj, prop) { addTest(function() { checkDefine(C, 'length'); checkDefine(C, 'parent'); - checkDefine(C, 'location'); + // checkDefine(C, 'location'); checkDefine(C, 'document'); checkDefine(C, 'foopy'); - checkDefine(C.location, 'href'); - checkDefine(C.location, 'replace'); - checkDefine(C.location, 'port'); - checkDefine(C.location, 'foopy'); + // checkDefine(C.location, 'href'); + // checkDefine(C.location, 'replace'); + // checkDefine(C.location, 'port'); + // checkDefine(C.location, 'foopy'); }, "[[DefineOwnProperty]] Should throw for cross-origin objects"); -*/ + /* * [[Enumerate]] */ -/* +//FIXME fails addTest(function() { for (var prop in C) assert_unreached("Shouldn't have been able to enumerate " + prop + " on cross-origin Window"); 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"); -*/ + /* * [[OwnPropertyKeys]] */ -/* +//FIXME fails addTest(function() { assert_array_equals(Object.getOwnPropertyNames(C).sort(), whitelistedWindowPropNames, @@ -303,6 +303,7 @@ addTest(function() { "Object.getOwnPropertyNames() gives the right answer for cross-origin Location"); }, "[[OwnPropertyKeys]] should return all properties from cross-origin objects"); +//FIXME fails addTest(function() { assert_array_equals(Object.getOwnPropertySymbols(C), whitelistedSymbols, "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"); }, "[[OwnPropertyKeys]] should return the right symbol-named properties for cross-origin objects"); +//FIXME fails addTest(function() { var allWindowProps = Reflect.ownKeys(C); 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.") }, "[[OwnPropertyKeys]] should place the symbols after the property names after the subframe indices"); +// works 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.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); }, "Cross-origin functions get local Function.prototype"); +// FIXME throws assertion error +/* addTest(function() { assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'parent')), "Need to be able to use Object.getOwnPropertyDescriptor do this test"); checkFunction(Object.getOwnPropertyDescriptor(C, 'parent').get, Function.prototype); checkFunction(Object.getOwnPropertyDescriptor(C.location, 'href').set, Function.prototype); }, "Cross-origin Window accessors get local Function.prototype"); - +*/ addTest(function() { checkFunction(close, Function.prototype); 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); }, "Same-origin observers get different functions for cross-origin objects"); +/* TODO i don't think get own property descriptor is working properly addTest(function() { assert_true(isObject(Object.getOwnPropertyDescriptor(C, 'parent')), "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_B, B.Function.prototype); }, "Same-origin observers get different accessors for cross-origin Location"); - +*/ +/* TODO is exception pending failure addTest(function() { 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"); */ + // 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 // disrupting the test harness. |