Reviewers: kpreid,

Description:
Adds a test for quoted font names.

https://code.google.com/p/google-caja/issues/detail?id=1748
suggests the bug is in the CSS parser, but I do not think that is the
case.

Please review this at https://codereview.appspot.com/10843044/

Affected files:
  M     tests/com/google/caja/plugin/sanitizecss_test.js


Index: tests/com/google/caja/plugin/sanitizecss_test.js
===================================================================
--- tests/com/google/caja/plugin/sanitizecss_test.js    (revision 5464)
+++ tests/com/google/caja/plugin/sanitizecss_test.js    (working copy)
@@ -14,8 +14,21 @@

 /** @fileoverview testcases for sanitizecss.js */

+function assertSelector(source, prefix, expected) {
+  var tokens = lexCss(source);
+  var sanitized = sanitizeCssSelectors(
+    tokens, prefix, function(el, args) { return { tagName: el }; });
+  assertArrayEquals(expected, sanitized);
+}
+
+function assertProperty(propName, source, expected) {
+  var tokens = lexCss(source);
+  sanitizeCssProperty(propName, cssSchema[propName], tokens);
+  assertEquals(expected, tokens.join(' '));
+}
+
 jsunitRegister('testFontFamily',
-               function testFont() {
+               function testFontFamily() {
   var tokens = ['Arial', ' ', 'Black', ',', 'monospace', ',',
                 'expression(', 'return', ' ', '"pwned"', ')', ',', 'Helvetica',
                 ' ', '#88ff88'];
@@ -34,9 +47,8 @@

 jsunitRegister('testFont',
                function testFont() {
-  var tokens = ['bold', ' ', '2em', ' ', 'monospace'];
-  sanitizeCssProperty('font', cssSchema['font'], tokens);
-  assertEquals('bold 2em monospace', tokens.join(' '));
+  assertProperty('font', 'bold 2em monospace', 'bold 2em monospace');
+  assertProperty('font', '20pt Calibri', '20pt "calibri"');
   jsunit.pass();
 });

@@ -213,10 +225,8 @@
 jsunitRegister('testBorder',
                function testBorder() {
   var source = '1px solid rgb(0,0,0)';
-  var expect = '1px:solid:rgb( 0 , 0 , 0 )';
-  var tokens = lexCss(source);
-  sanitizeCssProperty('border', cssSchema['border'], tokens);
-  assertEquals(expect, tokens.join(':'));
+  var expect = '1px solid rgb( 0 , 0 , 0 )';
+  assertProperty('border', source, expect);
   jsunit.pass();
 });

@@ -233,13 +243,6 @@
   jsunit.pass();
 });

-function assertSelector(source, prefix, expected) {
-  var tokens = lexCss(source);
-  var sanitized = sanitizeCssSelectors(
-    tokens, prefix, function(el, args) { return { tagName: el }; });
-  assertArrayEquals(expected, sanitized);
-}
-
 jsunitRegister('testCssSelectors',
                function testCssSelectors() {
   assertSelector("#foo:visited", "sfx", [[], [".sfx a#foo-sfx:visited"]]);
@@ -301,9 +304,6 @@
                function testGradients() {
   var source = 'linear-gradient(to bottom right, red, rgb(255,0,0))';
var expect = 'linear-gradient( to bottom right , red , rgb( 255 , 0 , 0 ) )';
-  var tokens = lexCss(source);
-  sanitizeCssProperty(
-      'background-image', cssSchema['background-image'], tokens);
-  assertEquals(expect, tokens.join(''));
+  assertProperty('background-image', source, expect);
   jsunit.pass();
 });


--

--- You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to