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

Side by Side 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, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <div id="container">
2 <p id="description"></p>
3 <div id="sample">0123456789</div>
4 </div>
5 <div id="console"></div>
6 <script src="../../js/resources/js-test-pre.js"></script>
7 <script>
8 description('Range.surroundContents() should not throw exception for detached no de.');
9 function $(id) { return document.getElementById(id); }
10
11 function surroundContents(node) {
12 var range = document.createRange();
13 range.setStart(node.firstChild, 2);
14 range.setEnd(node.firstChild, 6);
15 var newNode = document.createElement('b');
16 range.surroundContents(newNode);
17 return newNode.outerHTML;
18 }
19
20 var sample = $('sample');
21 var expected = '<b>' + sample.firstChild.textContent.substring(2, 6) + '</b>';
22 shouldBeEqualToString('surroundContents(sample.cloneNode(true))', expected);
23 sample.parentNode.removeChild(sample);
24 shouldBeEqualToString('surroundContents(sample)', expected);
25
26 if (window.testRunner)
27 $('container').outerHTML = '';
28 </script>
29 <script src="../../js/resources/js-test-post.js"></script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698