Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Unified Diff: LayoutTests/fast/dom/Range/surroundContents-for-detached-node.html

Issue 23404003: Make Range methods to work with detached node (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-08-27T11:16:22 Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/dom/Range/surroundContents-for-detached-node.html
diff --git a/LayoutTests/fast/dom/Range/surroundContents-for-detached-node.html b/LayoutTests/fast/dom/Range/surroundContents-for-detached-node.html
new file mode 100644
index 0000000000000000000000000000000000000000..856dd58a803d543618e372ace36d64649c8eb98c
--- /dev/null
+++ b/LayoutTests/fast/dom/Range/surroundContents-for-detached-node.html
@@ -0,0 +1,29 @@
+<div id="container">
+<p id="description"></p>
+<div id="sample">0123456789</div>
+</div>
+<div id="console"></div>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script>
+description('Range.surroundContents() should not throw exception for detached node.');
+function $(id) { return document.getElementById(id); }
+
+function surroundContents(node) {
+ var range = document.createRange();
+ range.setStart(node.firstChild, 2);
+ range.setEnd(node.firstChild, 6);
+ var newNode = document.createElement('b');
+ range.surroundContents(newNode);
+ return newNode.outerHTML;
+}
+
+var sample = $('sample');
+var expected = '<b>' + sample.firstChild.textContent.substring(2, 6) + '</b>';
+shouldBeEqualToString('surroundContents(sample.cloneNode(true))', expected);
+sample.parentNode.removeChild(sample);
+shouldBeEqualToString('surroundContents(sample)', expected);
+
+if (window.testRunner)
+ $('container').outerHTML = '';
+</script>
+<script src="../../js/resources/js-test-post.js"></script>

Powered by Google App Engine
This is Rietveld 408576698