| OLD | NEW | 
 | (Empty) | 
|   1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |  | 
|   2 <html> |  | 
|   3 <head> |  | 
|   4 <script src="../../resources/js-test.js"></script> |  | 
|   5 </head> |  | 
|   6 <body> |  | 
|   7 <script> |  | 
|   8 description('Various tests for the main element.'); |  | 
|   9  |  | 
|  10 var testParent = document.createElement('div'); |  | 
|  11 document.body.appendChild(testParent); |  | 
|  12  |  | 
|  13 debug('<main> closes <p>:'); |  | 
|  14 testParent.innerHTML = '<p>Test that <main id="main1">an main element</main> clo
    ses <p>.</p>'; |  | 
|  15 var main1 = document.getElementById('main1'); |  | 
|  16 shouldBeFalse('main1.parentNode.nodeName == "p"'); |  | 
|  17  |  | 
|  18 debug('<p> does not close <main>:'); |  | 
|  19 testParent.innerHTML = '<main>Test that <p id="p1">a p element</p> does not clos
    e an main element.</main>'; |  | 
|  20 var p1 = document.getElementById('p1'); |  | 
|  21 shouldBe('p1.parentNode.nodeName', '"MAIN"'); |  | 
|  22  |  | 
|  23 debug('<main> can be nested inside <main>:'); |  | 
|  24 testParent.innerHTML = '<main id="main2">Test that <main id="main3">an main elem
    ent</main> can be nested inside another.</main>'; |  | 
|  25 var main3 = document.getElementById('main3'); |  | 
|  26 shouldBe('main3.parentNode.id', '"main2"'); |  | 
|  27  |  | 
|  28 debug('Residual style:'); |  | 
|  29 testParent.innerHTML = '<b><main id="main4">This text should be bold.</main> <sp
    an id="span1">This is also bold.</span></b>'; |  | 
|  30 function getWeight(id) { |  | 
|  31     return document.defaultView.getComputedStyle(document.getElementById(id), nu
    ll).getPropertyValue('font-weight'); |  | 
|  32 } |  | 
|  33 shouldBe('getWeight("main4")', '"bold"'); |  | 
|  34 shouldBe('getWeight("span1")', '"bold"'); |  | 
|  35 document.body.removeChild(testParent); |  | 
|  36  |  | 
|  37 debug('FormatBlock:'); |  | 
|  38 var editable = document.createElement('div'); |  | 
|  39 editable.innerHTML = '[<span id="span2">The text will be a child of <main>.</
    span>]'; |  | 
|  40 document.body.appendChild(editable); |  | 
|  41 editable.contentEditable = true; |  | 
|  42 var selection = window.getSelection(); |  | 
|  43 selection.selectAllChildren(editable); |  | 
|  44 document.execCommand('FormatBlock', false, 'main'); |  | 
|  45 selection.removeAllRanges(); |  | 
|  46 shouldBe('document.getElementById("span2").parentNode.nodeName', '"MAIN"'); |  | 
|  47 document.body.removeChild(editable); |  | 
|  48  |  | 
|  49 </script> |  | 
|  50 </body> |  | 
|  51 </html> |  | 
| OLD | NEW |