OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <body> | 3 <body> |
4 <script type="data:text/html"> | 4 <script type="data:text/html"> |
5 <html xmlns:v="urn:schemas-microsoft-com:vml" | 5 <html xmlns:v="urn:schemas-microsoft-com:vml" |
6 xmlns:o="urn:schemas-microsoft-com:office:office" | 6 xmlns:o="urn:schemas-microsoft-com:office:office" |
7 xmlns:x="urn:schemas-microsoft-com:office:excel" | 7 xmlns:x="urn:schemas-microsoft-com:office:excel" |
8 xmlns="http://www.w3.org/TR/REC-html40"> | 8 xmlns="http://www.w3.org/TR/REC-html40"> |
9 <head> | 9 <head> |
10 <meta http-equiv=Content-Type content="text/html; charset=utf-8"> | 10 <meta http-equiv=Content-Type content="text/html; charset=utf-8"> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 </tr> | 57 </tr> |
58 <tr height=15 style='height:15.0pt'> | 58 <tr height=15 style='height:15.0pt'> |
59 <td height=15 style='height:15.0pt'></td> | 59 <td height=15 style='height:15.0pt'></td> |
60 <td>webkit</td> | 60 <td>webkit</td> |
61 </tr> | 61 </tr> |
62 <!--EndFragment--> | 62 <!--EndFragment--> |
63 </table> | 63 </table> |
64 </body> | 64 </body> |
65 </html> | 65 </html> |
66 </script> | 66 </script> |
67 <p>This test ensures WebKit strips away base, link, meta, style, and title eleme
nts before inserting HTML.</p> | 67 <p>This test ensures WebKit strips away base, link, meta and title elements befo
re inserting HTML.</p> |
68 <div id="test" contenteditable></div> | 68 <div id="test" contenteditable></div> |
69 <pre><script type="text/javascript"> | 69 <pre><script type="text/javascript"> |
70 | 70 |
71 var htmlInPasteboard = document.getElementsByTagName('script')[0].firstChild.tex
tContent; | 71 var htmlInPasteboard = document.getElementsByTagName('script')[0].firstChild.tex
tContent; |
72 document.getElementById('test').focus(); | 72 document.getElementById('test').focus(); |
73 document.execCommand('InsertHTML', false, htmlInPasteboard); | 73 document.execCommand('InsertHTML', false, htmlInPasteboard); |
74 | 74 |
75 var passed = true; | 75 var passed = true; |
76 function expectNoInstanceOf(elementName) { | 76 |
77 var elements = document.body.getElementsByTagName(elementName); | 77 function expectElementCount(test, selector) { |
78 if (elements.length <= 0) | 78 let actual = document.body.querySelectorAll(selector).length; |
| 79 if (test(actual)) |
79 return; | 80 return; |
80 | 81 |
81 document.write('FAIL - found ' + elements.length + ' '); | 82 document.write('FAIL - found ' + actual + ' '); |
82 document.write(elements.length == 1 ? 'instance' : 'instances'); | 83 document.write(actual == 1 ? 'instance' : 'instances'); |
83 document.writeln(' of ' + elementName + ' element'); | 84 document.writeln(' of ' + selector); |
84 passed = false; | 85 passed = false; |
85 } | 86 } |
86 | 87 |
| 88 function expectNoInstanceOf(elementName) { |
| 89 expectElementCount((x) => x == 0, elementName); |
| 90 } |
| 91 |
| 92 function expectInstancesOf(elementName) { |
| 93 expectElementCount((x) => x > 0, elementName); |
| 94 } |
| 95 |
87 if (window.testRunner) | 96 if (window.testRunner) |
88 testRunner.dumpAsText(); | 97 testRunner.dumpAsText(); |
89 | 98 |
90 expectNoInstanceOf('base'); | 99 expectNoInstanceOf('base'); |
91 expectNoInstanceOf('meta'); | 100 expectNoInstanceOf('meta'); |
92 expectNoInstanceOf('link'); | 101 expectNoInstanceOf('link'); |
93 expectNoInstanceOf('title'); | 102 expectNoInstanceOf('title'); |
94 expectNoInstanceOf('style'); | 103 |
| 104 expectInstancesOf('style'); |
| 105 |
95 if (passed) | 106 if (passed) |
96 document.writeln('PASS'); | 107 document.writeln('PASS'); |
97 | 108 |
98 document.getElementById('test').innerHTML = ''; | 109 document.getElementById('test').innerHTML = ''; |
99 | 110 |
100 </script></pre> | 111 </script></pre> |
101 </body> | 112 </body> |
102 </html> | 113 </html> |
OLD | NEW |