Change log level: info -> debug
[framework/web/webkit-efl.git] / LayoutTests / editing / pasteboard / paste-and-sanitize.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../fast/js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <p id="description">This test checks that the paste operation trims the pasted fragment to reduce the verbosity of the markup without affecting the style. </p>
8 <div id="console"></div>
9 <script>
10
11 var sel = document.getSelection();
12 var root = document.createElement("root");
13 document.body.appendChild(root);
14
15
16 function createEditable(tagName, markup) {
17     var node = document.createElement(tagName);
18     node.contentEditable = true;
19     node.innerHTML = markup;
20     return node;
21 }
22
23 function testPaste(tagName, originalMarkup, expected) {
24     var node = createEditable(tagName, originalMarkup);
25     root.appendChild(node);
26
27     node.focus();
28     document.execCommand("SelectAll", false);
29     document.execCommand("Copy", false);
30     document.execCommand("Paste", false);
31
32     confirmedMarkup = node.innerHTML;
33
34     shouldBe("confirmedMarkup", "'" + expected + "'");
35 }
36
37 testPaste("div", "Hello", "Hello");
38 testPaste("div", "<b><i>Hello</i></b>", "<b><i>Hello</i></b>");
39 testPaste("div", "<div><b><i><span style=\"font-weight: normal\"><b><i>Hello</i></b></span></i></b></div>", "<b><i>Hello</i></b>");
40 testPaste("div", "<div><div><div>Hello</div></div></div>", "Hello");
41 testPaste("div", "<div><b><div><i>Hello</i></div></b></div>", "<b><i>Hello</i></b>");
42 testPaste("div", "<div><div style=\"text-align: center;\"><b>Hello</b></div></div>", "<div style=\"text-align: center;\"><b>Hello</b></div>");
43 testPaste("div", "<div><b><i><span style=\"font-weight: normal\"><b><i>hello</i></b></span></i></b></div><div><b><i><span style=\"font-weight: normal\"><b><i>world</i></b></span></i></b></div>", 
44           "<div><b><i>hello</i></b></div><div><b><i>world</i></b></div>");
45 testPaste("div", "<div><b><i><span style=\"font-weight: normal; \"><b><i>hello1</i></b><b><i> hello2</i></b></span></i></b></div>", "<b><i><span style=\"font-weight: normal; \"><b><i>hello1</i></b><b><i>&nbsp;hello2</i></b></span></i></b>");
46 testPaste("div", "<i style=\"margin: 10px;\"><b><i style=\"margin: 10px;\">hello</i></b></i>",
47           "<i style=\"margin: 10px; \">hello</i></b></i>");
48 testPaste("div", "<div><b><i><span style=\"font-weight: normal\"><b><i>Hello <!-- comment -->world</i></b></span></i></b></div>", "<b><i>Hello&nbsp;world</i></b>");
49 testPaste("div", "<div><b><i><span style=\"font-weight: normal\">plain text<b><i>bold italic text</i></b></span></i></b></div>", "<b><i><span style=\"font-weight: normal; \">plain text<b><i>bold italic text</i></b></span></i></b>");
50
51 root.style.display = "none";
52
53 </script>
54 <script src="../../fast/js/resources/js-test-post.js"></script>
55 </body>
56 </html>