1 if (wysihtml5.browser.supported()) {
2 module("wysihtml5.quirks.cleanPastedHTML", {
4 this.refNode = document.createElement("div");
5 this.refNode.style.fontSize = "24px";
6 this.refNode.style.color = "rgba(0,0,0)";
7 this.uneditableClass = "wysihtml5-uneditable-container";
10 teardown: function() {
16 test("Basic test", function(assert) {
35 "referenceNode": this.refNode,
36 "rules": [{"set":rules}],
37 "uneditableClass": this.uneditableClass
41 wysihtml5.quirks.cleanPastedHTML("<u>See: </u><a href=\"http://www.google.com\"><u><b>best search engine</b></u></a>", options),
42 "<u>See: </u><a href=\"http://www.google.com\"><b>best search engine</b></a>",
43 "Correctly removed <u> within <a>"
47 test("Non-breakable space test", function(assert) {
49 "referenceNode": this.refNode,
50 "rules": [{"set": {}}],
51 "uneditableClass": this.uneditableClass
55 wysihtml5.quirks.cleanPastedHTML("test ", options),
56 "test ",
57 "Correctly split nonbreakable spaces"
61 test("Ruleset picking tests", function(assert) {
63 "referenceNode": this.refNode,
66 "condition": /class="?Mso/i,
83 "uneditableClass": this.uneditableClass
87 wysihtml5.quirks.cleanPastedHTML('<p class="MsoNormal">test</p>', options),
89 "Picked correctly to first ruleset"
92 wysihtml5.quirks.cleanPastedHTML('<p class="MsoNormal">test<!-- secret comment here --></p>', options),
94 "First ruleset removes comments correctly"
99 wysihtml5.quirks.cleanPastedHTML('<p class="SomeOtherClass">test</p>', options),
100 '<p class="SomeOtherClass">test</p>',
101 "Picked correctly to second ruleset"
104 wysihtml5.quirks.cleanPastedHTML('<p class="SomeOtherClass">test<!-- secret comment here --></p>', options),
105 '<p class="SomeOtherClass">test<!-- secret comment here --></p>',
106 "Second ruleset keeps comments correctly"
110 test("Root color and font-size removal tests", function(assert) {
112 "referenceNode": this.refNode,
123 "uneditableClass": this.uneditableClass
127 wysihtml5.quirks.cleanPastedHTML('<span style="color:rgba(0,0,0);font-size:24px;">test</span>', options),
129 "Correctly removed defult styles"
133 wysihtml5.quirks.cleanPastedHTML('<span style="color:rgb(1,2,3);">test</span>', options),
134 '<span style="color:rgb(1,2,3);">test</span>',
135 "Correctly kept different style"
139 wysihtml5.quirks.cleanPastedHTML('<span style="color:rgb(1,2,3); font-size: 24px;">test</span>', options),
140 '<span style="color:rgb(1,2,3);">test</span>',
141 "Correctly moved one and kept another"
145 wysihtml5.quirks.cleanPastedHTML('<span style="color:rgb(1,2,3); font-size: 35px;">test</span>', options),
146 '<span style="color:rgb(1,2,3); font-size: 35px;">test</span>',
147 "Correctly kept all styles"