Commit ecbbc938 authored by abecsi@webkit.org's avatar abecsi@webkit.org

2011-04-06 Andras Becsi <abecsi@webkit.org>

        Reviewed by Darin Adler.

        Invalid color #{predefined colorName} is accepted by the CSS parser.
        https://bugs.webkit.org/show_bug.cgi?id=15360

        * editing/execCommand/16049.html: Correct testcase which relies on parsing an invalid color value as valid.
        * fast/css/invalid-predefined-color-expected.txt: Added.
        * fast/css/invalid-predefined-color.html: Added.
        * fast/css/script-tests/invalid-predefined-color.js: Added.
2011-04-06  Andras Becsi  <abecsi@webkit.org>

        Reviewed by Darin Adler.

        Invalid color #{predefined colorName} is accepted by the CSS parser.
        https://bugs.webkit.org/show_bug.cgi?id=15360

        Test: fast/css/invalid-predefined-color.html

        * css/CSSGrammar.y: Remove superfluous hexcolor production.
        * css/tokenizer.flex: A hexadecimal number should consist of [a-fA-F0-9] values ({h}).

git-svn-id: svn://svn.chromium.org/blink/trunk@83046 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e6ff3143
2011-04-06 Andras Becsi <abecsi@webkit.org>
Reviewed by Darin Adler.
Invalid color #{predefined colorName} is accepted by the CSS parser.
https://bugs.webkit.org/show_bug.cgi?id=15360
* editing/execCommand/16049.html: Correct testcase which relies on parsing an invalid color value as valid.
* fast/css/invalid-predefined-color-expected.txt: Added.
* fast/css/invalid-predefined-color.html: Added.
* fast/css/script-tests/invalid-predefined-color.js: Added.
2011-03-30 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Pavel Feldman.
......@@ -10,12 +10,12 @@ if (window.layoutTestController)
edit1 = document.getElementById("edit1");
edit1.focus();
document.execCommand("BackColor", false, "#blue");
document.execCommand("BackColor", false, "#00F");
document.execCommand("InsertText", false, "Blue");
edit2 = document.getElementById("edit2");
edit2.focus();
document.execCommand("ForeColor", false, "#blue");
document.execCommand("ForeColor", false, "#00F");
document.execCommand("InsertText", false, "Black");
if (window.layoutTestController)
......
This test checks hexadecimal color parsing.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS getComputedStyle(div, null).color is red
PASS getComputedStyle(div, null).color is red
PASS getComputedStyle(div, null).color is red
PASS getComputedStyle(div, null).color is red
PASS getComputedStyle(div, null).color is red
PASS getComputedStyle(div, null).color is black
PASS getComputedStyle(div, null).color is black
PASS getComputedStyle(div, null).color is black
PASS getComputedStyle(div, null).color is black
PASS getComputedStyle(div, null).color is black
PASS successfullyParsed is true
TEST COMPLETE
This style is "color: red"
This style is "color: FF0000"
This style is "color: #FF0000"
This style is "color: F00"
This style is "color: #F00"
This style is "color: #red"
This style is "color: #yellow"
This style is "color: #green"
This style is "color: #FFAALL"
This style is "color: #FF000000"
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../js/resources/js-test-style.css">
<script src="../js/resources/js-test-pre.js"></script>
</head>
<body style="color: black">
<p id="description"></p>
<div id="console"></div>
<div id="valid1" style="color: red">This style is "color: red"</div>
<div id="valid2" style="color: FF0000">This style is "color: FF0000"</div>
<div id="valid3" style="color: #FF0000">This style is "color: #FF0000"</div>
<div id="valid4" style="color: F00">This style is "color: F00"</div>
<div id="valid5" style="color: #F00">This style is "color: #F00"</div>
<div id="invalid1" style="color: #red">This style is "color: #red"</div>
<div id="invalid2" style="color: #yellow">This style is "color: #yellow"</div>
<div id="invalid3" style="color: #green">This style is "color: #green"</div>
<div id="invalid4" style="color: #FFAALL">This style is "color: #FFAALL"</div>
<div id="invalid5" style="color: #FF000000">This style is "color: #FF000000"</div>
<script src="script-tests/invalid-predefined-color.js"></script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
description(
"This test checks hexadecimal color parsing."
);
var red = "rgb(255, 0, 0)";
var black = "rgb(0, 0, 0)";
for (var i=1;i<=5;i++)
{
var div = document.getElementById("valid"+i);
shouldBe("getComputedStyle(div, null).color", "red");
}
for (var i=1;i<=5;i++)
{
var div = document.getElementById("invalid"+i);
shouldBe("getComputedStyle(div, null).color", "black");
}
var successfullyParsed = true;
2011-04-06 Andras Becsi <abecsi@webkit.org>
Reviewed by Darin Adler.
Invalid color #{predefined colorName} is accepted by the CSS parser.
https://bugs.webkit.org/show_bug.cgi?id=15360
Test: fast/css/invalid-predefined-color.html
* css/CSSGrammar.y: Remove superfluous hexcolor production.
* css/tokenizer.flex: A hexadecimal number should consist of [a-fA-F0-9] values ({h}).
2011-03-30 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Pavel Feldman.
......@@ -99,7 +99,7 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
%}
%expect 51
%expect 50
%nonassoc LOWEST_PREC
......@@ -222,7 +222,6 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
%type <string> string_or_uri
%type <string> ident_or_string
%type <string> medium
%type <string> hexcolor
%type <marginBox> margin_sym
%type <string> media_feature
......@@ -1402,7 +1401,7 @@ term:
| unary_operator DIMEN maybe_space { $$.id = 0; $$.string = $2; $$.unit = CSSPrimitiveValue::CSS_DIMENSION; }
| URI maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_URI; }
| UNICODERANGE maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_UNICODE_RANGE; }
| hexcolor { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_PARSER_HEXCOLOR; }
| HEX maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_PARSER_HEXCOLOR; }
| '#' maybe_space { $$.id = 0; $$.string = CSSParserString(); $$.unit = CSSPrimitiveValue::CSS_PARSER_HEXCOLOR; } /* Handle error case: "color: #;" */
/* FIXME: according to the specs a function can have a unary_operator in front. I know no case where this makes sense */
| function {
......@@ -1464,16 +1463,6 @@ function:
$$.function = f;
}
;
/*
* There is a constraint on the color that it must
* have either 3 or 6 hex-digits (i.e., [0-9a-fA-F])
* after the "#"; e.g., "#000" is OK, but "#abcd" is not.
*/
hexcolor:
HEX maybe_space { $$ = $1; }
| IDSEL maybe_space { $$ = $1; }
;
/* error handling rules */
......
......@@ -15,7 +15,6 @@ string1 \"([\t !#$%&(-~]|\\{nl}|\'|{nonascii}|{escape})*\"
string2 \'([\t !#$%&(-~]|\\{nl}|\"|{nonascii}|{escape})*\'
ident -?{nmstart}{nmchar}*
name {nmchar}+
num [0-9]+|[0-9]*"."[0-9]+
intnum [0-9]+
string {string1}|{string2}
......@@ -46,8 +45,8 @@ nth [\+-]?{intnum}*n([\t\r\n ]*[\+-][\t\r\n ]*{intnum})?
{ident} {yyTok = IDENT; return yyTok;}
{nth} {yyTok = NTH; return yyTok;}
"#"{h}+ {yyTok = HEX; return yyTok;}
"#"{ident} {yyTok = IDSEL; return yyTok;}
"#"{name} {yyTok = HEX; return yyTok;}
"@import" {BEGIN(mediaquery); yyTok = IMPORT_SYM; return yyTok;}
"@page" {yyTok = PAGE_SYM; return yyTok;}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment