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

Unified Diff: LayoutTests/fast/dom/Range/range-on-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/range-on-detached-node.html
diff --git a/LayoutTests/fast/dom/Range/range-on-detached-node.html b/LayoutTests/fast/dom/Range/range-on-detached-node.html
new file mode 100644
index 0000000000000000000000000000000000000000..13646114909b8aee18f10b042c68b6e117635b87
--- /dev/null
+++ b/LayoutTests/fast/dom/Range/range-on-detached-node.html
@@ -0,0 +1,34 @@
+<div id="container">
+<p id="description"></p>
+<div id="sample">0123<b>45</b>6789</div>
+</div>
+<div id="console"></div>
+<script src="../../js/resources/js-test-pre.js"></script>
+<script>
+description('Range on detached node should not throw exception.');
+function $(id) { return document.getElementById(id); }
+
+function invalidNodeMessage(methodName)
+{
+ return '"InvalidNodeTypeError: Failed to execute \'' + methodName + '\' on \'Range\': the given Node has no parent."'
+}
+
+var sample = $('sample').cloneNode(true);
+var range = document.createRange();
+
+shouldBe('range.selectNode(sample.firstChild); range.startContainer', 'sample');
+shouldBe('range.setEndBefore(sample.firstChild); range.startContainer', 'sample');
+shouldBe('range.setEndAfter(sample.firstChild); range.startContainer', 'sample');
+shouldBe('range.setStartAfter(sample.firstChild); range.startContainer', 'sample');
+shouldBe('range.setStartBefore(sample.firstChild); range.startContainer', 'sample');
+
+shouldThrow('range.selectNode(sample); range.startContainer', invalidNodeMessage('selectNode'));
+shouldThrow('range.setEndAfter(sample); range.startContainer', invalidNodeMessage('setEndAfter'));
+shouldThrow('range.setEndBefore(sample); range.startContainer', invalidNodeMessage('setEndBefore'));
+shouldThrow('range.setStartAfter(sample); range.startContainer', invalidNodeMessage('setStartAfter'));
+shouldThrow('range.setStartBefore(sample); range.startContainer', invalidNodeMessage('setStartBefore'));
+
+if (window.testRunner)
+ $('container').outerHTML = '';
+</script>
+<script src="../../js/resources/js-test-post.js"></script>

Powered by Google App Engine
This is Rietveld 408576698