Skip to content

Commit

Permalink
addressing web-platform-tests#271 (comment) (Moved from HTMLPreElemen…
Browse files Browse the repository at this point in the history
…t.width to HTMLOListElement.start)
  • Loading branch information
ylafon committed Mar 28, 2014
1 parent d5c0255 commit f14d518
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions WebIDL/tests/submissions/heycam/long-001.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@
1.5, 1, "1.5"
];

// feature: HTMLPreElement.width (attribute) (writable, of type long)
// feature: HTMLOLElement.start (attribute) (writable, of type long)

var pre = document.createElement("pre");
var ol = document.createElement("ol");

for (var i = 0; i < values.length; i += 3) {
var value = values[i];
var expected = values[i + 1];
var desc = values[i + 2];
test(function() {
pre.width = value;
assert_equals(+pre.getAttribute("width"), expected);
}, "assigning " + desc + " to HTMLPreElement.width coerces the value to an IDL long correctly");
ol.start = value;
assert_equals(+ol.getAttribute("start"), expected);
}, "assigning " + desc + " to HTMLOListElement.start coerces the value to an IDL long correctly");
}

for (var i = 0; i < values.length; i += 3) {
Expand All @@ -60,13 +60,13 @@
test(function() {
var objectValue = { valueOf: function() { return value; }, toString: function() { return { } } };
if (value === null || typeof value != "object") {
pre.width = objectValue;
assert_equals(+pre.getAttribute("width"), expected);
ol.start = objectValue;
assert_equals(+ol.getAttribute("start"), expected);
} else {
// ToPrimitive() will throw a TypeError if valueOf and toString both return an object.
assert_throws(new TypeError(), function() { pre.width = objectValue; });
assert_throws(new TypeError(), function() { ol.start = objectValue; });
}
}, "assigning { valueOf: function() { return " + desc + " } } to HTMLPreElement.width coerces the value to an IDL long correctly");
}, "assigning { valueOf: function() { return " + desc + " } } to HTMLOListElement.start coerces the value to an IDL long correctly");
}

for (var i = 0; i < values.length; i += 3) {
Expand All @@ -76,16 +76,16 @@
test(function() {
var objectValue = { valueOf: function() { return { } }, toString: function() { return value; } };
if (value === null || typeof value != "object") {
pre.width = objectValue;
assert_equals(+pre.getAttribute("width"), expected);
ol.start = objectValue;
assert_equals(+ol.getAttribute("start"), expected);
} else {
// ToPrimitive() will throw a TypeError if valueOf and toString both return an object.
assert_throws(new TypeError(), function() { pre.width = objectValue; });
assert_throws(new TypeError(), function() { ol.start = objectValue; });
}
}, "assigning { toString: function() { return " + desc + " } } to HTMLPreElement.width coerces the value to an IDL long correctly");
}, "assigning { toString: function() { return " + desc + " } } to HTMLOListElement.start coerces the value to an IDL long correctly");
}

test(function() {
assert_throws({ name: "SomeError" }, function() { pre.width = { toString: function() { throw { name: "SomeError" }; } }; });
}, "assigning { toString: function() { throw ... } } to HTMLPreElement.width will propagate the exception");
assert_throws({ name: "SomeError" }, function() { ol.start = { toString: function() { throw { name: "SomeError" }; } }; });
}, "assigning { toString: function() { throw ... } } to HTMLOListElement.start will propagate the exception");
</script>

1 comment on commit f14d518

@travisleithead
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Please sign in to comment.