зеркало из https://github.com/mozilla/gecko-dev.git
Bug 480647 part 5 - Reject invalid values from execCommand("fontSize"); r=ehsan
This commit is contained in:
Родитель
3764f99635
Коммит
7be1137313
|
@ -2948,7 +2948,7 @@ ConvertToMidasInternalCommandInner(const nsAString& inCommandID,
|
|||
}
|
||||
|
||||
// String parameter -- see if we need to convert it (necessary for
|
||||
// cmd_paragraphState)
|
||||
// cmd_paragraphState and cmd_fontSize)
|
||||
if (outCommandID.EqualsLiteral("cmd_paragraphState")) {
|
||||
const PRUnichar* start = inParam.BeginReading();
|
||||
const PRUnichar* end = inParam.EndReading();
|
||||
|
@ -2970,6 +2970,16 @@ ConvertToMidasInternalCommandInner(const nsAString& inCommandID,
|
|||
if (j == ArrayLength(gBlocks)) {
|
||||
outParam.Truncate();
|
||||
}
|
||||
} else if (outCommandID.EqualsLiteral("cmd_fontSize")) {
|
||||
// Per editing spec as of April 23, 2012, we need to reject the value if
|
||||
// it's not a valid floating-point number surrounded by optional whitespace.
|
||||
// Otherwise, we parse it as a legacy font size. For now, we just parse as
|
||||
// a legacy font size regardless (matching WebKit) -- bug 747879.
|
||||
outParam.Truncate();
|
||||
PRInt32 size = nsContentUtils::ParseLegacyFontSize(inParam);
|
||||
if (size) {
|
||||
outParam.AppendInt(size);
|
||||
}
|
||||
} else {
|
||||
CopyUTF16toUTF8(inParam, outParam);
|
||||
}
|
||||
|
@ -3106,7 +3116,8 @@ nsHTMLDocument::ExecCommand(const nsAString & commandID,
|
|||
cmdToDispatch, paramStr, isBool, boolVal))
|
||||
return NS_OK;
|
||||
|
||||
if (cmdToDispatch.EqualsLiteral("cmd_paragraphState") && paramStr.IsEmpty()) {
|
||||
if ((cmdToDispatch.EqualsLiteral("cmd_paragraphState") ||
|
||||
cmdToDispatch.EqualsLiteral("cmd_fontSize")) && paramStr.IsEmpty()) {
|
||||
// Invalid value
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ _TEST_FILES = \
|
|||
test_bug456244.html \
|
||||
test_bug460740.html \
|
||||
test_bug478725.html \
|
||||
test_bug480647.html \
|
||||
test_bug480972.html \
|
||||
test_bug484181.html \
|
||||
test_bug487524.html \
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
*/
|
||||
const knownFailures = {
|
||||
"value": {
|
||||
"A-Proposed-FS:18px_TEXT-1_SI-dM": true,
|
||||
"A-Proposed-FS:18px_TEXT-1_SI-body": true,
|
||||
"A-Proposed-FS:18px_TEXT-1_SI-div": true,
|
||||
"A-Proposed-FS:large_TEXT-1_SI-dM": true,
|
||||
"A-Proposed-FS:large_TEXT-1_SI-body": true,
|
||||
"A-Proposed-FS:large_TEXT-1_SI-div": true,
|
||||
"A-Proposed-CB:name_TEXT-1_SI-dM": true,
|
||||
"A-Proposed-CB:name_TEXT-1_SI-body": true,
|
||||
"A-Proposed-CB:name_TEXT-1_SI-div": true,
|
||||
|
@ -41,6 +47,12 @@ const knownFailures = {
|
|||
"C-Proposed-FS:5_FONTsz:1.s:fs:xs-1_SW-dM": true,
|
||||
"C-Proposed-FS:5_FONTsz:1.s:fs:xs-1_SW-body": true,
|
||||
"C-Proposed-FS:5_FONTsz:1.s:fs:xs-1_SW-div": true,
|
||||
"C-Proposed-FS:larger_FONTsz:4-dM": true,
|
||||
"C-Proposed-FS:larger_FONTsz:4-body": true,
|
||||
"C-Proposed-FS:larger_FONTsz:4-div": true,
|
||||
"C-Proposed-FS:smaller_FONTsz:4-dM": true,
|
||||
"C-Proposed-FS:smaller_FONTsz:4-body": true,
|
||||
"C-Proposed-FS:smaller_FONTsz:4-div": true,
|
||||
"C-Proposed-FB:h1_ADDRESS-FONTsz:4-1_SO-dM": true,
|
||||
"C-Proposed-FB:h1_ADDRESS-FONTsz:4-1_SO-body": true,
|
||||
"C-Proposed-FB:h1_ADDRESS-FONTsz:4-1_SO-div": true,
|
||||
|
@ -74,9 +86,6 @@ const knownFailures = {
|
|||
"CC-Proposed-FS:1_SPANs:fs:l-1_SW-dM": true,
|
||||
"CC-Proposed-FS:1_SPANs:fs:l-1_SW-body": true,
|
||||
"CC-Proposed-FS:1_SPANs:fs:l-1_SW-div": true,
|
||||
"CC-Proposed-FS:large_SPANs:fs:l-1_SW-dM": true,
|
||||
"CC-Proposed-FS:large_SPANs:fs:l-1_SW-body": true,
|
||||
"CC-Proposed-FS:large_SPANs:fs:l-1_SW-div": true,
|
||||
"CC-Proposed-FS:18px_SPANs:fs:l-1_SW-dM": true,
|
||||
"CC-Proposed-FS:18px_SPANs:fs:l-1_SW-body": true,
|
||||
"CC-Proposed-FS:18px_SPANs:fs:l-1_SW-div": true,
|
||||
|
@ -869,9 +878,6 @@ const knownFailures = {
|
|||
"CC-Proposed-FS:1_SPANs:fs:l-1_SW-dM": true,
|
||||
"CC-Proposed-FS:1_SPANs:fs:l-1_SW-body": true,
|
||||
"CC-Proposed-FS:1_SPANs:fs:l-1_SW-div": true,
|
||||
"CC-Proposed-FS:large_SPANs:fs:l-1_SW-dM": true,
|
||||
"CC-Proposed-FS:large_SPANs:fs:l-1_SW-body": true,
|
||||
"CC-Proposed-FS:large_SPANs:fs:l-1_SW-div": true,
|
||||
"CC-Proposed-FS:18px_SPANs:fs:l-1_SW-dM": true,
|
||||
"CC-Proposed-FS:18px_SPANs:fs:l-1_SW-body": true,
|
||||
"CC-Proposed-FS:18px_SPANs:fs:l-1_SW-div": true,
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=480647
|
||||
-->
|
||||
<title>Test for Bug 480647</title>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=480647">Mozilla Bug 480647</a>
|
||||
<div contenteditable></div>
|
||||
<script>
|
||||
/** Test for Bug 480647 **/
|
||||
|
||||
var div = document.querySelector("div");
|
||||
|
||||
function parseFontSize(input, expected) {
|
||||
parseFontSizeInner(input, expected, is);
|
||||
}
|
||||
|
||||
function parseFontSizeTodo(input, expected) {
|
||||
parseFontSizeInner(input, expected, todo_is);
|
||||
}
|
||||
|
||||
function parseFontSizeInner(input, expected, fn) {
|
||||
div.innerHTML = "foo";
|
||||
getSelection().selectAllChildren(div);
|
||||
document.execCommand("fontSize", false, input);
|
||||
if (expected === null) {
|
||||
fn(div.innerHTML, "foo",
|
||||
'execCommand("fontSize", false, "' + input + '") should be no-op');
|
||||
} else {
|
||||
fn(div.innerHTML, '<font size="' + expected + '">foo</font>',
|
||||
'execCommand("fontSize", false, "' + input + '") should parse to ' +
|
||||
expected);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse errors
|
||||
parseFontSize("", null);
|
||||
parseFontSize("abc", null);
|
||||
parseFontSize("larger", null);
|
||||
parseFontSize("smaller", null);
|
||||
parseFontSize("xx-small", null);
|
||||
parseFontSize("x-small", null);
|
||||
parseFontSize("small", null);
|
||||
parseFontSize("medium", null);
|
||||
parseFontSize("large", null);
|
||||
parseFontSize("x-large", null);
|
||||
parseFontSize("xx-large", null);
|
||||
parseFontSize("xxx-large", null);
|
||||
// Bug 747879
|
||||
parseFontSizeTodo("1.2em", null);
|
||||
parseFontSizeTodo("8px", null);
|
||||
parseFontSizeTodo("-1.2em", null);
|
||||
parseFontSizeTodo("-8px", null);
|
||||
parseFontSizeTodo("+1.2em", null);
|
||||
parseFontSizeTodo("+8px", null);
|
||||
|
||||
// Numbers
|
||||
parseFontSize("0", 1);
|
||||
parseFontSize("1", 1);
|
||||
parseFontSize("2", 2);
|
||||
parseFontSize("3", 3);
|
||||
parseFontSize("4", 4);
|
||||
parseFontSize("5", 5);
|
||||
parseFontSize("6", 6);
|
||||
parseFontSize("7", 7);
|
||||
parseFontSize("8", 7);
|
||||
parseFontSize("9", 7);
|
||||
parseFontSize("10", 7);
|
||||
parseFontSize("1000000000000000000000", 7);
|
||||
parseFontSize("2.72", 2);
|
||||
parseFontSize("2.72e9", 2);
|
||||
|
||||
// Minus sign
|
||||
parseFontSize("-0", 3);
|
||||
parseFontSize("-1", 2);
|
||||
parseFontSize("-2", 1);
|
||||
parseFontSize("-3", 1);
|
||||
parseFontSize("-4", 1);
|
||||
parseFontSize("-5", 1);
|
||||
parseFontSize("-6", 1);
|
||||
parseFontSize("-7", 1);
|
||||
parseFontSize("-8", 1);
|
||||
parseFontSize("-9", 1);
|
||||
parseFontSize("-10", 1);
|
||||
parseFontSize("-1000000000000000000000", 1);
|
||||
parseFontSize("-1.72", 2);
|
||||
parseFontSize("-1.72e9", 2);
|
||||
|
||||
// Plus sign
|
||||
parseFontSize("+0", 3);
|
||||
parseFontSize("+1", 4);
|
||||
parseFontSize("+2", 5);
|
||||
parseFontSize("+3", 6);
|
||||
parseFontSize("+4", 7);
|
||||
parseFontSize("+5", 7);
|
||||
parseFontSize("+6", 7);
|
||||
parseFontSize("+7", 7);
|
||||
parseFontSize("+8", 7);
|
||||
parseFontSize("+9", 7);
|
||||
parseFontSize("+10", 7);
|
||||
parseFontSize("+1000000000000000000000", 7);
|
||||
parseFontSize("+1.72", 4);
|
||||
parseFontSize("+1.72e9", 4);
|
||||
|
||||
// Whitespace
|
||||
parseFontSize(" \t\n\r\f5 \t\n\r\f", 5);
|
||||
parseFontSize("\u00a05", null);
|
||||
parseFontSize("\b5", null);
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче