Commit 4f375ddd authored by rune@opera.com's avatar rune@opera.com

Drop empty list :host() and :host-context().

The <compound-selector> argument may not be empty according to spec.

BUG=356578

Review URL: https://codereview.chromium.org/212383002

git-svn-id: svn://svn.chromium.org/blink/trunk@170081 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent ce4d35b1
Test for cssText of ':host-context()' rule.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS document.getElementById('style1').sheet.cssRules.item(0).cssText is ".foo:host-context(div,body.mytheme,p#myid,.bar::before,span:hover) > div { display: block; }"
PASS document.getElementById('style1').sheet.cssRules.item(1).cssText is ":host-context(*) { display: block; }"
PASS document.getElementById('style-invalid').sheet.cssRules.length is 0
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<style id="style1">
.foo:host-context(div, body.mytheme, p#myid, .bar::before, span:hover) > div { display: block; }
:host-context(*) { display: block; }
</style>
<style id="style-invalid">
:host-context(div div) { display: block }
:host-context(div > div) { display: block }
:host-context(div + div) { display: block }
:host-context(div ~ div) { display: block }
:host-context) { display: block }
:host-context() { display: block; }
</style>
</head>
<script>
description("Test for cssText of ':host-context()' rule.");
shouldBeEqualToString("document.getElementById('style1').sheet.cssRules.item(0).cssText", ".foo:host-context(div,body.mytheme,p#myid,.bar::before,span:hover) > div { display: block; }");
shouldBeEqualToString("document.getElementById('style1').sheet.cssRules.item(1).cssText", ":host-context(*) { display: block; }");
shouldBe("document.getElementById('style-invalid').sheet.cssRules.length", "0");
</script>
</html>
...@@ -5,8 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -5,8 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS document.getElementById('style1').sheet.cssRules.item(0).cssText is ".foo:host(div,body.mytheme,p#myid,.bar::before,span:hover) > div { display: block; }" PASS document.getElementById('style1').sheet.cssRules.item(0).cssText is ".foo:host(div,body.mytheme,p#myid,.bar::before,span:hover) > div { display: block; }"
PASS document.getElementById('style1').sheet.cssRules.item(1).cssText is ":host { display: block; }" PASS document.getElementById('style1').sheet.cssRules.item(1).cssText is ":host { display: block; }"
PASS document.getElementById('style1').sheet.cssRules.item(2).cssText is ":host { display: block; }" PASS document.getElementById('style1').sheet.cssRules.item(2).cssText is ":host(*) { display: block; }"
PASS document.getElementById('style1').sheet.cssRules.item(3).cssText is ":host(*) { display: block; }"
PASS document.getElementById('style-invalid').sheet.cssRules.length is 0 PASS document.getElementById('style-invalid').sheet.cssRules.length is 0
PASS successfullyParsed is true PASS successfullyParsed is true
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
<style id="style1"> <style id="style1">
.foo:host(div, body.mytheme, p#myid, .bar::before, span:hover) > div { display: block; } .foo:host(div, body.mytheme, p#myid, .bar::before, span:hover) > div { display: block; }
:host { display: block; } :host { display: block; }
:host() { display: block; }
:host(*) { display: block; } :host(*) { display: block; }
</style> </style>
<style id="style-invalid"> <style id="style-invalid">
...@@ -14,14 +13,14 @@ ...@@ -14,14 +13,14 @@
:host(div + div) { display: block } :host(div + div) { display: block }
:host(div ~ div) { display: block } :host(div ~ div) { display: block }
:host) { display: block } :host) { display: block }
:host() { display: block; }
</style> </style>
</head> </head>
<script> <script>
description("Test for cssText of ':host()' rule."); description("Test for cssText of ':host()' rule.");
shouldBeEqualToString("document.getElementById('style1').sheet.cssRules.item(0).cssText", ".foo:host(div,body.mytheme,p#myid,.bar::before,span:hover) > div { display: block; }"); shouldBeEqualToString("document.getElementById('style1').sheet.cssRules.item(0).cssText", ".foo:host(div,body.mytheme,p#myid,.bar::before,span:hover) > div { display: block; }");
shouldBeEqualToString("document.getElementById('style1').sheet.cssRules.item(1).cssText", ":host { display: block; }"); shouldBeEqualToString("document.getElementById('style1').sheet.cssRules.item(1).cssText", ":host { display: block; }");
shouldBeEqualToString("document.getElementById('style1').sheet.cssRules.item(2).cssText", ":host { display: block; }"); shouldBeEqualToString("document.getElementById('style1').sheet.cssRules.item(2).cssText", ":host(*) { display: block; }");
shouldBeEqualToString("document.getElementById('style1').sheet.cssRules.item(3).cssText", ":host(*) { display: block; }");
shouldBe("document.getElementById('style-invalid').sheet.cssRules.length", "0"); shouldBe("document.getElementById('style-invalid').sheet.cssRules.length", "0");
</script> </script>
</html> </html>
...@@ -1469,16 +1469,6 @@ pseudo: ...@@ -1469,16 +1469,6 @@ pseudo:
if (type != CSSSelector::PseudoHost) if (type != CSSSelector::PseudoHost)
YYERROR; YYERROR;
} }
// used by :host()
| ':' HOSTFUNCTION maybe_space closing_parenthesis {
$$ = parser->createFloatingSelector();
$$->setMatch(CSSSelector::PseudoClass);
parser->tokenToLowerCase($2);
$$->setValue($2.atomicSubstring(0, $2.length() - 1));
CSSSelector::PseudoType type = $$->pseudoType();
if (type != CSSSelector::PseudoHost)
YYERROR;
}
| ':' HOSTFUNCTION selector_recovery closing_parenthesis { | ':' HOSTFUNCTION selector_recovery closing_parenthesis {
YYERROR; YYERROR;
} }
...@@ -1493,15 +1483,6 @@ pseudo: ...@@ -1493,15 +1483,6 @@ pseudo:
if (type != CSSSelector::PseudoHostContext) if (type != CSSSelector::PseudoHostContext)
YYERROR; YYERROR;
} }
| ':' HOSTCONTEXTFUNCTION maybe_space closing_parenthesis {
$$ = parser->createFloatingSelector();
$$->setMatch(CSSSelector::PseudoClass);
parser->tokenToLowerCase($2);
$$->setValue($2.atomicSubstring(0, $2.length() - 1));
CSSSelector::PseudoType type = $$->pseudoType();
if (type != CSSSelector::PseudoHostContext)
YYERROR;
}
| ':' HOSTCONTEXTFUNCTION selector_recovery closing_parenthesis { | ':' HOSTCONTEXTFUNCTION selector_recovery closing_parenthesis {
YYERROR; YYERROR;
} }
......
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