Bug 1176757 - Throw a DataCloneError when attempting to invoke 'cloneNode' on a 'ShadowRoot' and associated mochitest. r=wchen

This commit is contained in:
Sam E. Giles 2015-07-06 18:26:29 -07:00
parent 2c2295d295
commit e9068b5f19
5 changed files with 50 additions and 5 deletions

View File

@ -712,6 +712,13 @@ ShadowRoot::ContentRemoved(nsIDocument* aDocument,
}
}
nsresult
ShadowRoot::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const
{
*aResult = nullptr;
return NS_ERROR_DOM_DATA_CLONE_ERR;
}
void
ShadowRoot::DestroyContent()
{

View File

@ -183,6 +183,8 @@ protected:
// mark whether it is in the composed document, but we have run out of flags
// so instead we track it here.
bool mIsComposedDocParticipant;
nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
};
class ShadowRootStyleSheetList : public StyleSheetList

View File

@ -4,6 +4,7 @@ support-files =
[test_bug900724.html]
[test_bug1017896.html]
[test_bug1176757.html]
[test_content_element.html]
[test_custom_element_adopt_callbacks.html]
[test_custom_element_callback_innerhtml.html]

View File

@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1176757
-->
<head>
<title>Test for Bug 1176757</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=1176757">Mozilla Bug 1176757</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 1176757 **/
var element = document.createElement("a");
var shadowRoot = element.createShadowRoot();
var thrownException = false;
try {
shadowRoot.cloneNode();
} catch(err) {
thrownException = err;
}
ok(thrownException !== false, "An exception should've been thrown");
is(thrownException.name, "DataCloneError", "A DataCloneError exception should've been thrown");
</script>
</pre>
</body>
</html>

View File

@ -1,5 +0,0 @@
[test-010.html]
type: testharness
[A_10_01_02_09_T01]
expected: FAIL