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