зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1274806, got NS_ERROR_UNEXPECTED error when I call range.extractContents() for DOM element with iframe , r=mats
This commit is contained in:
Родитель
667d9f2396
Коммит
b8eb7f0a9e
|
@ -1842,8 +1842,23 @@ ValidateCurrentNode(nsRange* aRange, RangeSubtreeIterator& aIter)
|
|||
}
|
||||
|
||||
nsresult res = nsRange::CompareNodeToRange(node, aRange, &before, &after);
|
||||
NS_ENSURE_SUCCESS(res, false);
|
||||
|
||||
return NS_SUCCEEDED(res) && !before && !after;
|
||||
if (before || after) {
|
||||
nsCOMPtr<nsIDOMCharacterData> charData = do_QueryInterface(node);
|
||||
if (charData) {
|
||||
// If we're dealing with the start/end container which is a character
|
||||
// node, pretend that the node is in the range.
|
||||
if (before && node == aRange->GetStartParent()) {
|
||||
before = false;
|
||||
}
|
||||
if (after && node == aRange->GetEndParent()) {
|
||||
after = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return !before && !after;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title></title>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
setTimeout(function() {
|
||||
var rng = document.createRange();
|
||||
rng.setStart(document.getElementsByTagName("p").item(0).firstChild, 100);
|
||||
rng.setEndAfter(document.getElementsByTagName("p").item(0));
|
||||
try {
|
||||
rng.extractContents();
|
||||
opener.ok(true, "extractContents should not throw when document in iframe is being modified.");
|
||||
} catch(ex) {
|
||||
opener.ok(false, "extractContents shouldn't have thrown: " + ex);
|
||||
}
|
||||
|
||||
opener.setTimeout("SimpleTest.finish();", 0);
|
||||
window.close();
|
||||
|
||||
}, 0);
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur elit nisi, convallis sed scelerisque sit amet, vestibulum eu odio. Pellentesque et quam et nibh sollicitudin rutrum. Fusce tristique hendrerit ligula, et euismod sapien facilisis quis. Donec tincidunt turpis tortor, in pharetra tellus euismod ac. Vestibulum consectetur nulla lacinia, consectetur mauris ac, tempus libero. Nam non dui id enim dapibus porta id sed lectus. Praesent at suscipit neque. Vestibulum tellus lorem, placerat et volutpat sed, elementum eget lacus. Sed interdum nisi et imperdiet varius. Sed non magna odio. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vivamus velit risus, accumsan nec efficitur nec, semper sed arcu. Praesent consectetur lectus justo, fringilla imperdiet neque lobortis id. Donec efficitur pulvinar finibus.
|
||||
<iframe src="data:text/html,<script>window.onunload = function() {document.removeChild(document.documentElement); }</script>" width="10" height="10"></iframe>
|
||||
</p>
|
||||
<p>test</p>
|
||||
</body>
|
||||
</html>
|
|
@ -160,6 +160,7 @@ support-files =
|
|||
file_bug945152.jar
|
||||
file_bug1263696_frame_pass.html
|
||||
file_bug1263696_frame_fail.html
|
||||
file_bug1274806.html
|
||||
file_general_document.html
|
||||
file_html_in_xhr.html
|
||||
file_html_in_xhr.sjs
|
||||
|
@ -664,6 +665,7 @@ skip-if = buildapp == 'b2g'
|
|||
[test_bug1250148.html]
|
||||
[test_bug1259588.html]
|
||||
[test_bug1263696.html]
|
||||
[test_bug1274806.html]
|
||||
[test_caretPositionFromPoint.html]
|
||||
[test_change_policy.html]
|
||||
skip-if = buildapp == 'b2g' #no ssl support
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1274806
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 1274806</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
/** Test for Bug 1274806 **/
|
||||
function test() {
|
||||
window.testWindow = window.open("file_bug1274806.html", "", "");
|
||||
};
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body onload="setTimeout(test, 0);">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1274806">Mozilla Bug 1274806</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче