| <html> |
| <head> |
| <style> |
| pre { margin: 0; } |
| </style> |
| <script src="../../resources/dump-as-markup.js"></script> |
| <script> |
| Markup.noAutoDump(); |
| |
| function assertMarkup(name, element, expected) |
| { |
| var markup = Markup.get(element); |
| if (markup == expected) |
| log('PASS: ' + name); |
| else |
| log('FAIL: ' + name + '\nWas:\n' + markup + '\nExpected:\n' + expected); |
| } |
| |
| function log(text) |
| { |
| var el = document.createElement('pre'); |
| el.appendChild(document.createTextNode(text)); |
| document.getElementById('result').appendChild(el); |
| } |
| |
| function runTest() |
| { |
| if (window.testRunner) |
| testRunner.dumpAsText() |
| |
| var items = document.getElementsByTagName('li'); |
| document.getElementById('testReplace').outerHTML = '<span>Replaced</span> node'; |
| assertMarkup('replace', items[0], '| <span>\n| "Replaced"\n| " node using outerHTML."'); |
| |
| document.getElementById('testRemove').outerHTML = ''; |
| assertMarkup('remove', items[1], '| " removing node using outerHTML."'); |
| |
| document.getElementById('testMerge').outerHTML = 'merging'; |
| assertMarkup('merge text nodes', items[2], '| "Testing merging text nodes."'); |
| |
| document.getElementById('testAddBr').outerHTML = '<br>'; |
| assertMarkup('line break', items[3], '| "Testing adding "\n| <br>\n| " using outerHTML."'); |
| } |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <ul> |
| <li><span id="testReplace">Testing replacing node</span> using outerHTML.</li> |
| <li><span id="testRemove">Testing</span> removing node using outerHTML.</li> |
| <li>Testing <span id="testMerge">merging</span> text nodes.</li> |
| <li>Testing adding <span id="testAddBr">line break</span> using outerHTML.</li> |
| </ul> |
| <div id="result"></div> |
| </body> |
| </html> |
| |