Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Range / range-extract-contents.html
blob2d2d44c2abcbe7594d755f0bd93ab3b8abf53beb
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <div id="test">hello world<span style="font-weight: bold;">WebKit</span><em><script>var i=0;</script><b><code>This</code> is</u></b> a <tt>test <wbr>of <blockquote>Range's extractContents.</blockquote></tt></em><q><dfn>This</dfn></q><!-- test --> <header><h3>test</header> also works in Firefox.</h3></div>
5 <div id="expectations">
6 <div id="test_empty"></div>
7 <div id="test_text">hello world</div>
8 <div id="test_substring">llo</div>
9 <div id="test_text_with_start_tag">hello world<span style="font-weight: bold;"></span></div>
10 <div id="test_text_and_span">hello world<span style="font-weight: bold;">WebKit</span></div>
11 <div id="test_span_b"><span style="font-weight: bold;">WebKit</span><em><script>var i=0;</script><b></b></em></div>
12 <div id="test_code_blockquote"><b><code>This</code> is</u></b> a <tt>test <wbr>of <blockquote>Range's extractContents.</blockquote></tt></div>
13 <div id="test_wbr_blockquote"><wbr>of <blockquote>Range's extractContents.</blockquote></div>
14 <div id="test_q_header"><q><dfn>This</dfn></q><!-- test --> <header><h3>test</h3></header></div>
15 <div id="test_script_dfn"><em><script>var i=0;</script><b><code>This</code> is</u></b> a <tt>test <wbr>of <blockquote>Range's extractContents.</blockquote></tt></em><q><dfn>This</dfn></div>
16 <div id="test_blockquote_em"><tt><blockquote>Range's extractContents.</blockquote></tt></div>
17 </div>
18 <pre id="console"></pre>
19 <script src="../../../resources/dump-as-markup.js"></script>
20 <script>
22 function log(message) {
23 document.getElementById('console').innerHTML += message + '\n';
26 function testExtractContents(description, startContainer, startOffset, endContainer, endOffset, expectedContentsId) {
27 var testContents = document.getElementById('test').innerHTML;
29 var range = document.createRange();
30 range.setStart(startContainer, startOffset);
31 range.setEnd(endContainer, endOffset);
32 var actualContents = range.extractContents();
34 document.getElementById('test').innerHTML = testContents;
36 var action = description + ' yields:\n' + Markup.get(actualContents).replace(/</g, '&lt;');
37 var expectedContents = document.getElementById(expectedContentsId);
38 if (Markup.get(actualContents) == Markup.get(expectedContents))
39 log('PASS: ' + action);
40 else
41 log('FAIL: ' + action + '\n but expected:\n' + Markup.get(expectedContents).replace(/</g, '&lt;'));
43 log('');
46 Markup.noAutoDump();
48 var test = document.getElementById('test');
49 log('test contents:\n' + Markup.get(test).replace(/</g, '&lt;') + '\n')
51 function firstElement(name) {
52 return test.getElementsByTagName(name)[0];
55 testExtractContents('Extracting empty contents', test, 0, test, 0, 'test_empty');
56 testExtractContents('Extracting entire contents', test, 0, test, test.childNodes.length, 'test');
57 testExtractContents('Extracting single text node', test, 0, test, 1, 'test_text')
58 testExtractContents('Extracting substring of a text node (2, 5)', test.firstChild, 2, test.firstChild, 5, 'test_substring');
59 testExtractContents('Extracting single text node and start of span', test, 0, test.childNodes[1], 0, 'test_text_with_start_tag');
60 testExtractContents('Extracting single text node and a span', test, 0, test, 2, 'test_text_and_span');
61 testExtractContents('Extracting span through first b', firstElement('span'), 0, firstElement('b'), 0, 'test_span_b');
62 testExtractContents('Extracting code through blockquote', firstElement('code'), 0, firstElement('blockquote'), 1, 'test_code_blockquote');
63 testExtractContents('Extracting wbr through blockquote', firstElement('wbr'), 0, firstElement('blockquote'), 1, 'test_wbr_blockquote');
64 testExtractContents('Extracting q through header', firstElement('q'), 0, firstElement('header'), 1, 'test_q_header');
65 testExtractContents('Extracting q through header using node index', test, 3, test, 7, 'test_q_header');
66 testExtractContents('Extracting dfn through header', firstElement('dfn'), 0, firstElement('header'), 1, 'test_q_header');
67 testExtractContents('Extracting script through dfn', firstElement('script'), 0, firstElement('dfn'), 1, 'test_script_dfn');
68 testExtractContents('Extracting blockquote through em', firstElement('blockquote'), 0, firstElement('em'), firstElement('em').childNodes.length, 'test_blockquote_em');
70 test.style.display = 'none';
71 document.getElementById('expectations').style.display = 'none';
73 log('DONE');
75 </script>
76 </body>
77 </html>