Revision: 5467
Author:   [email protected]
Date:     Tue Jul  2 11:46:12 2013
Log:      Issue 1748: CSS font property with unquoted font name
https://codereview.appspot.com/10843044

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.

R=kpreid

http://code.google.com/p/google-caja/source/detail?r=5467

Modified:
 /trunk/tests/com/google/caja/plugin/sanitizecss_test.js

=======================================
--- /trunk/tests/com/google/caja/plugin/sanitizecss_test.js Mon Jul 1 09:53:11 2013 +++ /trunk/tests/com/google/caja/plugin/sanitizecss_test.js Tue Jul 2 11:46:12 2013
@@ -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