mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Update web-platform-tests to revision 0d318188757a9c996e20b82db201fd04de5aa255
This commit is contained in:
parent
b2a5225831
commit
1a81b18b9f
12321 changed files with 544385 additions and 6 deletions
52
tests/wpt/web-platform-tests/common/stringifiers.js
Normal file
52
tests/wpt/web-platform-tests/common/stringifiers.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
// Tests <http://heycam.github.io/webidl/#es-stringifier>.
|
||||
function test_stringifier_attribute(aObject, aAttribute, aIsUnforgeable) {
|
||||
// Step 1.
|
||||
test(function() {
|
||||
[null, undefined].forEach(function(v) {
|
||||
assert_throws(new TypeError(), function() {
|
||||
aObject.toString.call(v);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// TODO Step 2: security check.
|
||||
|
||||
// Step 3.
|
||||
test(function() {
|
||||
assert_false("Window" in window && aObject instanceof window.Window);
|
||||
[{}, window].forEach(function(v) {
|
||||
assert_throws(new TypeError(), function() {
|
||||
aObject.toString.call(v)
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Step 4-6.
|
||||
var expected_value;
|
||||
test(function() {
|
||||
expected_value = aObject[aAttribute];
|
||||
assert_equals(aObject[aAttribute], expected_value,
|
||||
"The attribute " + aAttribute + " should be pure.");
|
||||
});
|
||||
|
||||
var test_error = { name: "test" };
|
||||
test(function() {
|
||||
if (!aIsUnforgeable) {
|
||||
Object.defineProperty(aObject, aAttribute, {
|
||||
configurable: true,
|
||||
get: function() { throw test_error; }
|
||||
});
|
||||
}
|
||||
assert_equals(aObject.toString(), expected_value);
|
||||
});
|
||||
|
||||
test(function() {
|
||||
if (!aIsUnforgeable) {
|
||||
Object.defineProperty(aObject, aAttribute, {
|
||||
configurable: true,
|
||||
value: { toString: function() { throw test_error; } }
|
||||
});
|
||||
}
|
||||
assert_equals(aObject.toString(), expected_value);
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue