Commit a75202e1 authored by ddkilzer@apple.com's avatar ddkilzer@apple.com

WebCore:

        Dynamically inserting CSS rule with @media query fails with DOM Exception 12
        <http://bugs.webkit.org/show_bug.cgi?id=15986>

        Reviewed by Darin.

        Allow any valid rule (@font-face, @import, @media, @page or style) to be
        parsed when using CSSStyleSheet.insertRule().  Previously only import and
        style rules were allowed.  Note that @page rules always throw an exception
        because they're not implemented yet, so no test case was added for them.

        Tests: fast/css/insertRule-font-face.html
               fast/css/insertRule-media.html

        * css/CSSGrammar.y: Extracted 'valid_rule' out of 'rule'.  Renamed
        'ruleset_or_import' to 'valid_rule_or_import' and changed its definition.

LayoutTests:

        Dynamically inserting CSS rule with @media query fails with DOM Exception 12
        <http://bugs.webkit.org/show_bug.cgi?id=15986>

        Reviewed by Darin.

        * fast/css/insertRule-font-face.html: Added.
        * fast/css/insertRule-media.html: Added.
        * fast/css/resources/insertRule-font-face.js: Added.
        * fast/css/resources/insertRule-media.js: Added.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1408e7d8
2008-03-03 David D. Kilzer <ddkilzer@webkit.org>
Dynamically inserting CSS rule with @media query fails with DOM Exception 12
<http://bugs.webkit.org/show_bug.cgi?id=15986>
Reviewed by Darin.
* fast/css/insertRule-font-face.html: Added.
* fast/css/insertRule-media.html: Added.
* fast/css/resources/insertRule-font-face.js: Added.
* fast/css/resources/insertRule-media.js: Added.
2008-03-03 Oliver Hunt <oliver@apple.com>
Reviewed by Mark Rowe.
Test parsing of @font-face rule using insertRule(). http://bugs.webkit.org/show_bug.cgi?id=15986
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.styleSheets[0].insertRule(rule, 0) is 0
PASS document.styleSheets[0].rules[0].cssText is rule
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<style type="text/css"></style>
<link rel="stylesheet" href="../js/resources/js-test-style.css">
<script src="../js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="resources/insertRule-font-face.js"></script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
Test parsing of @media rule using insertRule(). http://bugs.webkit.org/show_bug.cgi?id=15986
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.styleSheets[0].insertRule(rule, 0) is 0
PASS document.styleSheets[0].rules[0].cssText is rule
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<style type="text/css"></style>
<link rel="stylesheet" href="../js/resources/js-test-style.css">
<script src="../js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="resources/insertRule-media.js"></script>
<script src="../js/resources/js-test-post.js"></script>
</body>
</html>
description(
'Test parsing of @font-face rule using insertRule(). <a href="http://bugs.webkit.org/show_bug.cgi?id=15986">http://bugs.webkit.org/show_bug.cgi?id=15986</a>'
);
var rule = "@font-face { }";
shouldBe("document.styleSheets[0].insertRule(rule, 0)", "0");
shouldBe("document.styleSheets[0].rules[0].cssText", "rule");
var successfullyParsed = true;
description(
'Test parsing of @media rule using insertRule(). <a href="http://bugs.webkit.org/show_bug.cgi?id=15986">http://bugs.webkit.org/show_bug.cgi?id=15986</a>'
);
var rule = "@media all and (min-width: 0px) { \n #greenid { color: green; }\n}";
shouldBe("document.styleSheets[0].insertRule(rule, 0)", "0");
shouldBe("document.styleSheets[0].rules[0].cssText", "rule");
var successfullyParsed = true;
2008-03-03 David D. Kilzer <ddkilzer@webkit.org>
Dynamically inserting CSS rule with @media query fails with DOM Exception 12
<http://bugs.webkit.org/show_bug.cgi?id=15986>
Reviewed by Darin.
Allow any valid rule (@font-face, @import, @media, @page or style) to be
parsed when using CSSStyleSheet.insertRule(). Previously only import and
style rules were allowed. Note that @page rules always throw an exception
because they're not implemented yet, so no test case was added for them.
Tests: fast/css/insertRule-font-face.html
fast/css/insertRule-media.html
* css/CSSGrammar.y: Extracted 'valid_rule' out of 'rule'. Renamed
'ruleset_or_import' to 'valid_rule_or_import' and changed its definition.
2008-03-03 Anders Carlsson <andersca@apple.com>
Reviewed by Sam.
......@@ -148,7 +148,7 @@ static int cssyylex(YYSTYPE* yylval) { return CSSParser::current()->lex(yylval);
%type <rule> charset
%type <rule> ruleset
%type <rule> ruleset_or_import
%type <rule> valid_rule_or_import
%type <rule> media
%type <rule> import
%type <rule> page
......@@ -157,6 +157,7 @@ static int cssyylex(YYSTYPE* yylval) { return CSSParser::current()->lex(yylval);
%type <rule> invalid_at
%type <rule> invalid_import
%type <rule> rule
%type <rule> valid_rule
%type <string> maybe_ns_prefix
......@@ -219,13 +220,13 @@ stylesheet:
| webkit_mediaquery maybe_space
;
ruleset_or_import:
ruleset |
import
;
valid_rule_or_import:
valid_rule
| import
;
webkit_rule:
WEBKIT_RULE_SYM '{' maybe_space ruleset_or_import maybe_space '}' {
WEBKIT_RULE_SYM '{' maybe_space valid_rule_or_import maybe_space '}' {
static_cast<CSSParser*>(parser)->rule = $4;
}
;
......@@ -310,15 +311,19 @@ rule_list:
}
;
rule:
valid_rule:
ruleset
| media
| page
| font_face
;
rule:
valid_rule
| invalid_rule
| invalid_at
| invalid_import
;
;
import:
IMPORT_SYM maybe_space string_or_uri maybe_space maybe_media_list ';' {
......
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