Bug 1223688 - Clear mInSupportsConditions when we error out of CSS.supports() upon finding no tokens. r=dholbert

This commit is contained in:
Cameron McCormack 2015-11-16 12:49:22 +11:00
parent 3dbaca5456
commit aba9af032b
3 changed files with 46 additions and 4 deletions

View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script>
function boom() {
CSS.supports('');
var style = document.createElement("style");
var tn = document.createTextNode("* { border: var(--b); }");
style.appendChild(tn);
document.body.appendChild(style);
}
</script>
</head>
<body onload="boom();"></body>
</html>

View File

@ -128,6 +128,7 @@ load 1167782-1.html
load 1186768-1.xhtml
load 1200568-1.html
load 1206105-1.html
load 1223688-1.html
load 1223694-1.html
load border-image-visited-link.html
load font-face-truncated-src.html

View File

@ -441,6 +441,31 @@ protected:
bool mOriginalValue;
};
/**
* RAII class to set aParser->mInSupportsCondition to true and restore it
* to false later.
*/
class MOZ_RAII nsAutoInSupportsCondition
{
public:
explicit nsAutoInSupportsCondition(CSSParserImpl* aParser)
: mParser(aParser)
{
MOZ_ASSERT(!aParser->mInSupportsCondition,
"nsAutoInSupportsCondition is not designed to be used "
"re-entrantly");
mParser->mInSupportsCondition = true;
}
~nsAutoInSupportsCondition()
{
mParser->mInSupportsCondition = false;
}
private:
CSSParserImpl* const mParser;
};
// the caller must hold on to aString until parsing is done
void InitScanner(nsCSSScanner& aScanner,
css::ErrorReporter& aReporter,
@ -4333,7 +4358,7 @@ CSSParserImpl::ParseSupportsRule(RuleAppendFunc aAppendFunc, void* aProcessData)
bool
CSSParserImpl::ParseSupportsCondition(bool& aConditionMet)
{
mInSupportsCondition = true;
nsAutoInSupportsCondition aisc(this);
if (!GetToken(true)) {
REPORT_UNEXPECTED_EOF(PESupportsConditionStartEOF2);
@ -4351,7 +4376,6 @@ CSSParserImpl::ParseSupportsCondition(bool& aConditionMet)
bool result = ParseSupportsConditionInParens(aConditionMet) &&
ParseSupportsConditionTerms(aConditionMet) &&
!mScanner->SeenBadToken();
mInSupportsCondition = false;
return result;
}
@ -4359,12 +4383,10 @@ CSSParserImpl::ParseSupportsCondition(bool& aConditionMet)
mToken.mIdent.LowerCaseEqualsLiteral("not")) {
bool result = ParseSupportsConditionNegation(aConditionMet) &&
!mScanner->SeenBadToken();
mInSupportsCondition = false;
return result;
}
REPORT_UNEXPECTED_TOKEN(PESupportsConditionExpectedStart);
mInSupportsCondition = false;
return false;
}