1 <script src=
"../../resources/dump-as-markup.js"></script>
2 <p>This tests removing style attribute after removing CSS property. Undo should bring back the CSS property we removed.
</p>
3 <div id=
"test" contenteditable
><span style=
"font-weight: 900;">test
</span></div>
6 Markup
.description('This tests removing style attribute after removing CSS property. Undo should bring back the CSS property we removed.');
8 Markup
.dump('test', 'Initially "test" should be bold wrapped with a span');
9 window
.getSelection().selectAllChildren(test
);
10 document
.execCommand('bold', false, null);
11 Markup
.dump('test', 'Unbolding should remove the CSS style and also remove the span');
13 document
.execCommand('undo', false, null);
14 Markup
.dump('test', 'Undo should bring back both the span and style attribute so that "test" is once again bold');
16 document
.execCommand('redo', false, null);
17 Markup
.dump('test', 'Redo should unbold "test" and there should be no span');
19 document
.execCommand('undo', false, null);
20 Markup
.dump('test', 'Undo once more');
22 document
.getElementById('test').innerHTML
= '<span style="font-weight: 900;">test</span>';
23 var span
= document
.getElementById('test').firstChild
;
24 span
.id
= 'test_span';
25 span
.title
= 'hello, world';
26 window
.getSelection().selectAllChildren(test
);
27 Markup
.dump('test', 'Reset, and added id and title');
29 document
.execCommand('bold', false, null);
30 Markup
.dump('test', 'Unbolding should remove the CSS style but shouldn\'t remove the span');
32 document
.execCommand('undo', false, null);
33 Markup
.dump('test', 'Undo should restore the style attribute and "test" should be bold');
35 document
.execCommand('redo', false, null);
36 Markup
.dump('test', 'Redo should remove the style attribute again');
38 document
.getElementById('test').innerHTML
= '<span style="font-weight: 900;">test</span>';
39 var span
= document
.getElementById('test').firstChild
;
40 span
.style
.color
= 'blue';
41 window
.getSelection().selectAllChildren(test
);
42 Markup
.dump('test', 'Reset, and added color:blue');
44 document
.execCommand('bold', false, null);
45 Markup
.dump('test', 'Unbolding should remove the font-weight but shouldn\'t remove the style attribute');
47 document
.execCommand('undo', false, null);
48 Markup
.dump('test', 'Undo should reset the style attribute so that "test" is both bold and blue');
50 document
.execCommand('redo', false, null);
51 Markup
.dump('test', 'Redo should only remove font-weight and leave "test" blue');
53 document
.execCommand('foreColor', false, "#000000");
54 Markup
.dump('test', 'Setting the forecolor to black should remove both the style attribute and the span');
56 document
.execCommand('undo', false, null);
57 Markup
.dump('test', 'Undo should make "test" blue again');