6 var tableRow = document.createElement("tr");
7 table.appendChild(tableRow);
11 function addCellWithNodeContents(tableRow, contents)
13 var tableCell = document.createElement("td");
14 tableCell.appendChild(contents);
15 tableRow.appendChild(tableCell);
19 function addCellWithTextContents(tableRow, contents)
21 return addCellWithNodeContents(tableRow, document.createTextNode(contents));
24 function addHeaderWithTextContents(tableRow, contents)
26 var tableCell = document.createElement("th");
27 tableCell.appendChild(document.createTextNode(contents));
28 tableRow.appendChild(tableCell);
32 function setFontSizeOnContent(size)
34 window.getSelection().selectAllChildren(editableDiv);
35 document.execCommand("FontSize", false, size);
36 return editableDiv.firstChild;
39 function setFontFamilyOnContent(fontFamily)
41 window.getSelection().selectAllChildren(editableDiv);
42 document.execCommand("FontName", false, fontFamily);
43 return editableDiv.firstChild;
46 function reportSizeForSpan(span, comment)
48 var tableRow = addRow(table);
49 addCellWithTextContents(tableRow, comment);
50 addCellWithTextContents(tableRow, span.parentNode.innerHTML); // sill FF has no outerHTML
51 window.getSelection().selectAllChildren(span.parentNode);
52 addCellWithTextContents(tableRow, "" + document.queryCommandValue("FontSize"));
55 function testExecCommandFontSize(size, fontFamily)
57 editableDiv.innerHTML = "test";
58 var sizedContent = setFontSizeOnContent(size);
60 sizedContent = setFontFamilyOnContent(fontFamily);
61 var sizeString = (typeof(size) == "string") ? ("'" + size + "'") : size;
62 reportSizeForSpan(sizedContent, "execCommand('FontSize', " + sizeString + ")");
65 function testManualFontSize(size)
67 editableDiv.innerHTML = "<span style='font-size: " + size + "'>test</span>";
68 reportSizeForSpan(editableDiv.firstChild, "manual CSS font-size: " + size);
71 if (window.layoutTestController)
72 window.layoutTestController.dumpAsText();
74 var editableDiv = document.createElement("div");
75 editableDiv.contentEditable = true;
76 document.body.appendChild(editableDiv);
78 var table = document.createElement("table");
81 document.body.appendChild(table);
83 var tableRow = addRow(table);
84 addHeaderWithTextContents(tableRow, "test");
85 addHeaderWithTextContents(tableRow, "html");
86 addHeaderWithTextContents(tableRow, "queryCommandValue result");
88 for (var size = -2; size < 8; size++) {
89 testExecCommandFontSize(size);
91 testExecCommandFontSize("8px");
92 testExecCommandFontSize("2px");
94 testManualFontSize("3px");
95 testManualFontSize("0.2em");
96 testManualFontSize("17px");
97 testManualFontSize("31px");
98 testManualFontSize("50px");
99 testManualFontSize("5em");
100 testManualFontSize("10px");
102 tableRow = addRow(table);
103 addHeaderWithTextContents(tableRow, "monospace tests to ensure the bug 19161 does not affect queryCommandValue's values");
105 for (var size = -2; size < 8; size++) {
106 testExecCommandFontSize(size, 'monospace');
109 document.body.removeChild(editableDiv);