diff --git a/layout/style/nsCSSStyleSheet.cpp b/layout/style/nsCSSStyleSheet.cpp index ad7fce01a02..762325faaee 100644 --- a/layout/style/nsCSSStyleSheet.cpp +++ b/layout/style/nsCSSStyleSheet.cpp @@ -2142,10 +2142,25 @@ nsCSSStyleSheet::InsertRuleIntoGroup(const nsAString & aRule, int32_t counter; css::Rule* rule; for (counter = 0; counter < rulecount; counter++) { - // Only rulesets are allowed in a group as of CSS2 rule = rules.ObjectAt(counter); - if (rule->GetType() != css::Rule::STYLE_RULE) { - return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; + switch (rule->GetType()) { + case css::Rule::STYLE_RULE: + case css::Rule::MEDIA_RULE: + case css::Rule::FONT_FACE_RULE: + case css::Rule::PAGE_RULE: + case css::Rule::KEYFRAMES_RULE: + case css::Rule::DOCUMENT_RULE: + case css::Rule::SUPPORTS_RULE: + // these types are OK to insert into a group + break; + case css::Rule::CHARSET_RULE: + case css::Rule::IMPORT_RULE: + case css::Rule::NAMESPACE_RULE: + // these aren't + return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; + default: + NS_NOTREACHED("unexpected rule type"); + return NS_ERROR_DOM_HIERARCHY_REQUEST_ERR; } } diff --git a/layout/style/test/Makefile.in b/layout/style/test/Makefile.in index dc67fc3fd34..d86d19c9b54 100644 --- a/layout/style/test/Makefile.in +++ b/layout/style/test/Makefile.in @@ -127,6 +127,7 @@ MOCHITEST_FILES = test_acid3_test46.html \ test_priority_preservation.html \ test_property_syntax_errors.html \ test_rem_unit.html \ + test_rule_insertion.html \ test_rule_serialization.html \ test_rules_out_of_sheets.html \ test_selectors.html \ diff --git a/layout/style/test/test_rule_insertion.html b/layout/style/test/test_rule_insertion.html new file mode 100644 index 00000000000..5adc28dc73d --- /dev/null +++ b/layout/style/test/test_rule_insertion.html @@ -0,0 +1,213 @@ + + + + + Test for Bug 816720 + + + + + + +

+
+

.

+

.

+

.

+ + + + + +