зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1177914 - throw a NotSupportedError when running document.importNode on a ShadowRoot or Document. r=wchen
--HG-- extra : rebase_source : c133fba7b8222dd3a89b1ab486269a1639e405ee
This commit is contained in:
Родитель
1a7515c6f8
Коммит
2845c57fba
|
@ -6724,8 +6724,17 @@ nsIDocument::ImportNode(nsINode& aNode, bool aDeep, ErrorResult& rv) const
|
|||
nsINode* imported = &aNode;
|
||||
|
||||
switch (imported->NodeType()) {
|
||||
case nsIDOMNode::ATTRIBUTE_NODE:
|
||||
case nsIDOMNode::DOCUMENT_NODE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case nsIDOMNode::DOCUMENT_FRAGMENT_NODE:
|
||||
{
|
||||
if (ShadowRoot::FromNode(imported)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
case nsIDOMNode::ATTRIBUTE_NODE:
|
||||
case nsIDOMNode::ELEMENT_NODE:
|
||||
case nsIDOMNode::PROCESSING_INSTRUCTION_NODE:
|
||||
case nsIDOMNode::TEXT_NODE:
|
||||
|
@ -6745,11 +6754,10 @@ nsIDocument::ImportNode(nsINode& aNode, bool aDeep, ErrorResult& rv) const
|
|||
default:
|
||||
{
|
||||
NS_WARNING("Don't know how to clone this nodetype for importNode.");
|
||||
|
||||
rv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
rv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -684,6 +684,7 @@ skip-if = buildapp == 'b2g' || toolkit == 'android' #bug 904183 # b2g(bug 904183
|
|||
[test_createHTMLDocument.html]
|
||||
[test_declare_stylesheet_obsolete.html]
|
||||
[test_document_constructor.html]
|
||||
[test_document_importNode_document.html]
|
||||
[test_domparser_null_char.html]
|
||||
[test_domparsing.html]
|
||||
[test_elementTraversal.html]
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1177914
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1177914</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=1177914">Mozilla Bug 1177914</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
var thrownException = false;
|
||||
|
||||
try {
|
||||
document.importNode(document);
|
||||
} catch(err) {
|
||||
thrownException = err;
|
||||
}
|
||||
|
||||
ok(thrownException !== false, "An exception should've been thrown");
|
||||
is(thrownException.name, "NotSupportedError", "A NotSupportedError exception should've been thrown");
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -18,6 +18,7 @@ support-files =
|
|||
[test_fallback_dest_insertion_points.html]
|
||||
[test_detached_style.html]
|
||||
[test_dynamic_content_element_matching.html]
|
||||
[test_document_importnode.html]
|
||||
[test_document_register.html]
|
||||
[test_document_register_base_queue.html]
|
||||
[test_document_register_lifecycle.html]
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1177914
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 1177914</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=1177914">Mozilla Bug 1177914</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var thrownException = false;
|
||||
var shadowRoot = document.createElement('a').createShadowRoot();
|
||||
|
||||
try {
|
||||
document.importNode(shadowRoot);
|
||||
} catch(err) {
|
||||
thrownException = err;
|
||||
}
|
||||
|
||||
|
||||
ok(thrownException !== false, "An exception should've been thrown");
|
||||
is(thrownException.name, "NotSupportedError", "A NotSupportedError exception should've been thrown");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче