Remove handling of comments inside CSS url() tokens. (Bug 473914) r+sr=bzbarsky
authorL. David Baron <dbaron@dbaron.org>
Fri, 16 Jan 2009 19:44:20 -0800
changeset 23843 e2c5c612df4697fe3cf2d88d48ed15f51b4ba575
parent 23842 90cded872e97643771a761086a03e861cd4044e0
child 23844 fefdf894b7ecec6b3c38058ef5adf49a632a4f1f
push id4756
push userdbaron@mozilla.com
push dateSat, 17 Jan 2009 03:44:45 +0000
treeherdermozilla-central@723ea3c0719f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs473914
milestone1.9.2a1pre
Remove handling of comments inside CSS url() tokens. (Bug 473914) r+sr=bzbarsky
layout/style/nsCSSScanner.cpp
layout/style/test/Makefile.in
layout/style/test/test_parse_url.html
--- a/layout/style/nsCSSScanner.cpp
+++ b/layout/style/nsCSSScanner.cpp
@@ -848,33 +848,16 @@ nsCSSScanner::NextURL(nsCSSToken& aToken
 
   // WS
   if (IsWhitespace(ch)) {
     aToken.mType = eCSSToken_WhiteSpace;
     aToken.mIdent.Assign(PRUnichar(ch));
     (void) EatWhiteSpace();
     return PR_TRUE;
   }
-  if (ch == '/') {
-    PRInt32 nextChar = Peek();
-    if (nextChar == '*') {
-      (void) Read();
-#if 0
-      // If we change our storage data structures such that comments are
-      // stored (for Editor), we should reenable this code, condition it
-      // on being in editor mode, and apply glazou's patch from bug
-      // 60290.
-      aToken.mIdent.SetCapacity(2);
-      aToken.mIdent.Assign(PRUnichar(ch));
-      aToken.mIdent.Append(PRUnichar(nextChar));
-      return ParseCComment(aToken);
-#endif
-      return SkipCComment() && Next(aToken);
-    }
-  }
 
   // Process a url lexical token. A CSS1 url token can contain
   // characters beyond identifier characters (e.g. '/', ':', etc.)
   // Because of this the normal rules for tokenizing the input don't
   // apply very well. To simplify the parser and relax some of the
   // requirements on the scanner we parse url's here. If we find a
   // malformed URL then we emit a token of type "InvalidURL" so that
   // the CSS1 parser can ignore the invalid input. We attempt to eat
--- a/layout/style/test/Makefile.in
+++ b/layout/style/test/Makefile.in
@@ -110,16 +110,17 @@ GARBAGE += css_properties.js
 		test_initial_computation.html \
 		test_initial_storage.html \
 		test_media_queries.html \
 		test_media_queries_dynamic.html \
 		test_media_queries_dynamic_xbl.html \
 		test_namespace_rule.html \
 		test_of_type_selectors.xhtml \
 		test_parse_rule.html \
+		test_parse_url.html \
 		test_property_database.html \
 		test_property_syntax_errors.html \
 		test_selectors.html \
 		test_selectors_on_anonymous_content.html \
 		test_shorthand_property_getters.html \
 		test_style_struct_copy_constructors.html \
 		test_value_computation.html \
 		test_value_storage.html \
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_parse_url.html
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=473914
+-->
+<head>
+  <title>Test for Bug 473914</title>
+  <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=473914">Mozilla Bug 473914</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 473914 **/
+
+var div = document.getElementById("content");
+
+// This test relies on normalization (removal of quote marks) that we're not
+// really guaranteed to continue doing in the future (and we should probably
+// actually change to add the quote marks).
+div.style.listStyleImage = 'url(http://example.org/**/)';
+is(div.style.listStyleImage, 'url(http://example.org/**/)',
+   "not treated as comment");
+div.style.listStyleImage = 'url("http://example.org/**/")';
+is(div.style.listStyleImage, 'url(http://example.org/**/)',
+   "not treated as comment");
+div.style.listStyleImage = 'url(/**/foo)';
+is(div.style.listStyleImage, 'url(/**/foo)',
+   "not treated as comment");
+div.style.listStyleImage = 'url("/**/foo")';
+is(div.style.listStyleImage, 'url(/**/foo)',
+   "not treated as comment");
+div.style.listStyleImage = 'url(/**/)';
+is(div.style.listStyleImage, 'url(/**/)',
+   "not treated as comment");
+div.style.listStyleImage = 'url("/**/")';
+is(div.style.listStyleImage, 'url(/**/)',
+   "not treated as comment");
+
+</script>
+</pre>
+</body>
+</html>