Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / style / script-tests / text-decoration-state.js
bloba994693430971f881d999f1489fddc9d1093ab01
1 description('Test to make sure we return correct text-decoration state.  Note that "text-decoration: none" SHOULD NOT cancel text decorations.')
3 var testContainer = document.createElement("div");
4 testContainer.contentEditable = true;
5 document.body.appendChild(testContainer);
7 function textdecorationState(decoration, content)
9     testContainer.innerHTML = content;
10     var e = document.getElementById('e');
11     var s = window.getSelection();
12     var r = document.createRange();
13     r.setStart(e, 0);
14     r.setEnd(e, 1);
15     e.focus();
16     s.removeAllRanges();
17     s.addRange(r);
19     return document.queryCommandState(decoration);
22 shouldBe('textdecorationState("underline","<u><b><i><span id=e>hello world</span></i></b></u>")', 'true');
23 shouldBe('textdecorationState("underline","<b><i><u><span id=e>hello world</span></u></i></b>")', 'true');
24 shouldBe('textdecorationState("underline","<b><i><span id=e style=\'text-decoration: underline;\'>hello world</span></i></b>")', 'true');
25 shouldBe('textdecorationState("underline","<span style=\'text-decoration: underline;\'><em id=e>hello world</em></span>")', 'true');
26 shouldBe('textdecorationState("underline","<u><b><i><span id=e style=\'text-decoration:none\'>hello world</span></i></b></u>")', 'true');
28 shouldBe('textdecorationState("strikeThrough","<b><i><span id=e>hello world</span></i></b>")', 'false');
29 shouldBe('textdecorationState("strikeThrough","<s><b><i><span id=e>hello world</span></i></b></s>")', 'true');
30 shouldBe('textdecorationState("strikeThrough","<b><i><s><span id=e>hello world</span></s></i></b>")', 'true');
31 shouldBe('textdecorationState("strikeThrough","<b><i><span id=e style=\'text-decoration: line-through;\'>hello world</span></i></b>")', 'true');
32 shouldBe('textdecorationState("strikeThrough","<span style=\'text-decoration: line-through;\'><em id=e>hello world</em></span>")', 'true');
33 shouldBe('textdecorationState("strikeThrough","<s><b><i><span id=e style=\'text-decoration:none\'>hello world</span></i></b></s>")', 'true');
35 document.body.removeChild(testContainer);
37 var successfullyParsed = true;