Skip to content

Commit

Permalink
Bug 1154356 - Escape variable name in Declaration::AppendVariableAndV…
Browse files Browse the repository at this point in the history
…alueToString. r=heycam
  • Loading branch information
Tom Tromey committed Apr 24, 2015
1 parent 82018bd commit 9757a28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions layout/style/Declaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,8 +1171,10 @@ void
Declaration::AppendVariableAndValueToString(const nsAString& aName,
nsAString& aResult) const
{
aResult.AppendLiteral("--");
aResult.Append(aName);
nsAutoString localName;
localName.AppendLiteral("--");
localName.Append(aName);
nsStyleUtil::AppendEscapedCSSIdent(localName, aResult);
CSSVariableDeclarations::Type type;
nsString value;
bool important;
Expand Down
12 changes: 12 additions & 0 deletions layout/style/test/test_variables.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
<style id="test6">
</style>

<style id="test7">
</style>

<script>
var tests = [
function() {
Expand Down Expand Up @@ -91,6 +94,15 @@
test6.style.color = "white";
is(declaration.getPropertyValue("-x-system-font"), " var(--var6) hangul mongolian");
},

function() {
// https://bugzilla.mozilla.org/show_bug.cgi?id=1154356
var test7 = document.getElementById("test7");
test7.textContent = "p { --weird\\;name: green; }";
is(test7.sheet.cssRules[0].style.cssText, "--weird\\;name: green;");
test7.textContent = "p { --0: green; }";
is(test7.sheet.cssRules[0].style.cssText, "--0: green;");
},
];

function prepareTest() {
Expand Down

0 comments on commit 9757a28

Please sign in to comment.