Bug 1282894 - Propagate exception on setting HTMLTableElement.caption. r=bz

--HG--
extra : rebase_source : ea1aff21fb0b410c1076775cd76d7569d0f6c695
This commit is contained in:
Jessica Jong 2016-07-21 22:40:00 +02:00
parent 61e4473134
commit b99dc5856a
5 changed files with 35 additions and 3 deletions

View File

@ -32,12 +32,11 @@ public:
{
return static_cast<HTMLTableCaptionElement*>(GetChild(nsGkAtoms::caption));
}
void SetCaption(HTMLTableCaptionElement* aCaption)
void SetCaption(HTMLTableCaptionElement* aCaption, ErrorResult& aError)
{
DeleteCaption();
if (aCaption) {
mozilla::ErrorResult rv;
nsINode::AppendChild(*aCaption, rv);
nsINode::AppendChild(*aCaption, aError);
}
}

View File

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
function boom() {
var table = document.createElement("table");
var cap = document.createElement("caption");
cap.appendChild(table)
table.caption = cap;
}
</script>
</head>
<body onload="boom();"></body>
</html>

View File

@ -76,3 +76,4 @@ load 1228876.html
load 1230110.html
load 1237633.html
load 1281972-1.html
load 1282894.html

View File

@ -12,6 +12,7 @@
*/
interface HTMLTableElement : HTMLElement {
[SetterThrows]
attribute HTMLTableCaptionElement? caption;
HTMLElement createCaption();
void deleteCaption();

View File

@ -36,6 +36,8 @@
</table>
<table id="table4" style="display:none">
</table>
<table id="table5" style="display:none">
</table>
<script>
test(function () {
var table0 = document.getElementById('table0');
@ -81,6 +83,18 @@
table4.deleteCaption();
assert_equals(caption.parentNode, table4);
}, "deleteCaption method not remove caption that is not in html namespace")
test(function() {
var table5 = document.getElementById('table5');
var caption = document.createElement('caption');
caption.appendChild(table5)
// Node cannot be inserted at the specified point in the hierarchy
assert_throws("HierarchyRequestError", function() {
table5.caption = caption;
});
assert_not_equals(table5.caption, caption);
}, "Setting caption rethrows exception");
</script>
</body>
</html>