|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=404320 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for Bug 404320</title> |
|
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
10 </head> |
|
11 <body> |
|
12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=404320">Mozilla Bug 404320</a> |
|
13 <p id="display"></p> |
|
14 <div id="content"> |
|
15 <iframe id="testIframe"></iframe> |
|
16 </div> |
|
17 <pre id="test"> |
|
18 <script class="testbody" type="text/javascript"> |
|
19 |
|
20 /** Test for Bug 404320 **/ |
|
21 |
|
22 SimpleTest.waitForExplicitFinish(); |
|
23 |
|
24 function runTests() { |
|
25 var win = document.getElementById("testIframe").contentWindow; |
|
26 var doc = document.getElementById("testIframe").contentDocument; |
|
27 |
|
28 function testFormatBlock(tag, withAngleBrackets, shouldSucceed) |
|
29 { |
|
30 win.getSelection().selectAllChildren(doc.body.firstChild); |
|
31 doc.execCommand("FormatBlock", false, |
|
32 withAngleBrackets ? tag : "<" + tag + ">"); |
|
33 var resultNode; |
|
34 if (shouldSucceed && (tag == "dd" || tag == "dt")) { |
|
35 is(doc.body.firstChild.tagName, "DL", "tag was changed"); |
|
36 resultNode = doc.body.firstChild.firstChild; |
|
37 } |
|
38 else { |
|
39 resultNode = doc.body.firstChild; |
|
40 } |
|
41 |
|
42 is(resultNode.tagName, shouldSucceed ? tag.toUpperCase() : "P", "tag was changed"); |
|
43 } |
|
44 |
|
45 function formatBlockTests(tags, shouldSucceed) |
|
46 { |
|
47 var html = "<p>Content</p>"; |
|
48 for (var i = 0; i < tags.length; ++i) { |
|
49 var tag = tags[i]; |
|
50 var resultTag = tag.toUpperCase(); |
|
51 |
|
52 doc.body.innerHTML = html; |
|
53 testFormatBlock(tag, false, shouldSucceed); |
|
54 |
|
55 doc.body.innerHTML = html; |
|
56 testFormatBlock(tag, true, shouldSucceed); |
|
57 } |
|
58 } |
|
59 |
|
60 doc.designMode = "on"; |
|
61 |
|
62 var goodTags = [ "address", |
|
63 "blockquote", |
|
64 "dd", |
|
65 "div", |
|
66 "dl", |
|
67 "dt", |
|
68 "h1", |
|
69 "h2", |
|
70 "h3", |
|
71 "h4", |
|
72 "h5", |
|
73 "h6", |
|
74 "p", |
|
75 "pre" ]; |
|
76 var badTags = [ "b", |
|
77 "i", |
|
78 "span", |
|
79 "foo" ]; |
|
80 |
|
81 formatBlockTests(goodTags, true); |
|
82 formatBlockTests(badTags, false); |
|
83 SimpleTest.finish(); |
|
84 } |
|
85 |
|
86 addLoadEvent(runTests); |
|
87 |
|
88 </script> |
|
89 </pre> |
|
90 </body> |
|
91 </html> |