Index: LayoutTests/fast/css/script-tests/image-set-parsing.js |
diff --git a/LayoutTests/fast/css/script-tests/image-set-parsing.js b/LayoutTests/fast/css/script-tests/image-set-parsing.js |
index 0b5de693cdabada9842225e59a96034071a7bf06..1a655ab42c6125ccb6297c471c931762f928479c 100644 |
--- a/LayoutTests/fast/css/script-tests/image-set-parsing.js |
+++ b/LayoutTests/fast/css/script-tests/image-set-parsing.js |
@@ -1,110 +1,55 @@ |
description("Test the parsing of the -webkit-image-set function."); |
-function jsWrapperClass(node) |
-{ |
- if (!node) |
- return "[null]"; |
- var string = Object.prototype.toString.apply(node); |
- return string.substr(8, string.length - 9); |
-} |
- |
-function shouldBeType(expression, className, prototypeName, constructorName) |
-{ |
- if (!prototypeName) |
- prototypeName = className + "Prototype"; |
- if (!constructorName) |
- constructorName = className + "Constructor"; |
- shouldBe("jsWrapperClass(" + expression + ")", "'" + className + "'"); |
- shouldBe("jsWrapperClass(" + expression + ".__proto__)", "'" + prototypeName + "'"); |
- shouldBe("jsWrapperClass(" + expression + ".constructor)", "'" + constructorName + "'"); |
-} |
- |
-// These have to be global for the test helpers to see them. |
-var imageSetRule, subRule; |
+var result; |
-function testImageSetRule(description, property, rule, expectedLength, expectedTexts) |
+function testImageSetRule(description, property, rule, expectedTexts) |
{ |
debug(""); |
debug(description + " : " + rule); |
var div = document.createElement("div"); |
- div.setAttribute("style", property + ": -webkit-image-set(" + rule + ")"); |
+ rule = "-webkit-image-set(" + rule + ")"; |
+ div.style[property] = rule; |
document.body.appendChild(div); |
- |
- imageSetRule = div.style.getPropertyCSSValue(property); |
- shouldBeType("imageSetRule", "CSSValueList"); |
- |
- if (imageSetRule) { |
- if (jsWrapperClass(imageSetRule[0]) == "CSSValueList") { |
- // The content property returns a CSSValueList anyway, so to get to the |
- // imageSet CSS value list, we have to look at the first entry in the |
- // content value list. |
- imageSetRule = imageSetRule[0]; |
- } |
- } |
- |
- shouldBe("imageSetRule.length", "" + expectedLength); // shouldBe expects string arguments |
- |
- if (imageSetRule) { |
- for (var i = 0; i < expectedLength; i++) { |
- string = imageSetRule[i]; |
- if (i % 2 == 0) { |
- subRule = string.cssText.split('#')[1]; |
- subRule = subRule.split(')')[0]; |
- shouldBe("subRule", "'" + expectedTexts[i] + "'"); |
- } else { |
- subRule = string; |
- shouldBe("subRule.cssText", "'" + expectedTexts[i] + "'"); |
- } |
- } |
- } |
- |
+ result = div.style[property].replace(/url\([^#]*#/g, "url(#"); |
+ shouldBeEqualToString("result", rule); |
document.body.removeChild(div); |
} |
testImageSetRule("Single value for background-image", |
"background-image", |
- "url('#a') 1x", 2, |
- ["a", "1"]); |
+ "url(#a) 1x"); |
testImageSetRule("Multiple values for background-image", |
"background-image", |
- "url('#a') 1x, url('#b') 2x", 4, |
- ["a", "1", "b", "2"]); |
+ "url(#a) 1x, url(#b) 2x"); |
testImageSetRule("Multiple values for background-image, out of order", |
"background-image", |
- "url('#c') 3x, url('#b') 2x, url('#a') 1x", 6, |
- ["c", "3", "b", "2", "a", "1"]); |
+ "url(#c) 3x, url(#b) 2x, url(#a) 1x"); |
testImageSetRule("Single value for content", |
"content", |
- "url('#a') 1x", 2, |
- ["a", "1"]); |
+ "url(#a) 1x"); |
testImageSetRule("Multiple values for content", |
"content", |
- "url('#a') 1x, url('#b') 2x", 4, |
- ["a", "1", "b", "2"]); |
+ "url(#a) 1x, url(#b) 2x"); |
testImageSetRule("Single value for border-image", |
"-webkit-border-image", |
- "url('#a') 1x", 2, |
- ["a", "1"]); |
+ "url(#a) 1x"); |
testImageSetRule("Multiple values for border-image", |
"-webkit-border-image", |
- "url('#a') 1x, url('#b') 2x", 4, |
- ["a", "1", "b", "2"]); |
+ "url(#a) 1x, url(#b) 2x"); |
testImageSetRule("Single value for -webkit-mask-box-image-source", |
"-webkit-mask-box-image-source", |
- "url('#a') 1x", 2, |
- ["a", "1"]); |
+ "url(#a) 1x"); |
testImageSetRule("Multiple values for -webkit-mask-box-image-source", |
"-webkit-mask-box-image-source", |
- "url('#a') 1x, url('#b') 2x", 4, |
- ["a", "1", "b", "2"]); |
+ "url(#a) 1x, url(#b) 2x"); |
successfullyParsed = true; |