Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: LayoutTests/fast/css/script-tests/image-set-parsing.js

Issue 714693002: Don't require getPropertyCSSValue in fast/css tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 description("Test the parsing of the -webkit-image-set function."); 1 description("Test the parsing of the -webkit-image-set function.");
2 2
3 function jsWrapperClass(node) 3 var result;
4 {
5 if (!node)
6 return "[null]";
7 var string = Object.prototype.toString.apply(node);
8 return string.substr(8, string.length - 9);
9 }
10 4
11 function shouldBeType(expression, className, prototypeName, constructorName) 5 function testImageSetRule(description, property, rule, expectedTexts)
12 {
13 if (!prototypeName)
14 prototypeName = className + "Prototype";
15 if (!constructorName)
16 constructorName = className + "Constructor";
17 shouldBe("jsWrapperClass(" + expression + ")", "'" + className + "'");
18 shouldBe("jsWrapperClass(" + expression + ".__proto__)", "'" + prototypeName + "'");
19 shouldBe("jsWrapperClass(" + expression + ".constructor)", "'" + constructor Name + "'");
20 }
21
22 // These have to be global for the test helpers to see them.
23 var imageSetRule, subRule;
24
25 function testImageSetRule(description, property, rule, expectedLength, expectedT exts)
26 { 6 {
27 debug(""); 7 debug("");
28 debug(description + " : " + rule); 8 debug(description + " : " + rule);
29 9
30 var div = document.createElement("div"); 10 var div = document.createElement("div");
31 div.setAttribute("style", property + ": -webkit-image-set(" + rule + ")"); 11 rule = "-webkit-image-set(" + rule + ")";
12 div.style[property] = rule;
32 document.body.appendChild(div); 13 document.body.appendChild(div);
33 14 result = div.style[property].replace(/url\([^#]*#/g, "url(#");
34 imageSetRule = div.style.getPropertyCSSValue(property); 15 shouldBeEqualToString("result", rule);
35 shouldBeType("imageSetRule", "CSSValueList");
36
37 if (imageSetRule) {
38 if (jsWrapperClass(imageSetRule[0]) == "CSSValueList") {
39 // The content property returns a CSSValueList anyway, so to get to the
40 // imageSet CSS value list, we have to look at the first entry in th e
41 // content value list.
42 imageSetRule = imageSetRule[0];
43 }
44 }
45
46 shouldBe("imageSetRule.length", "" + expectedLength); // shouldBe expects st ring arguments
47
48 if (imageSetRule) {
49 for (var i = 0; i < expectedLength; i++) {
50 string = imageSetRule[i];
51 if (i % 2 == 0) {
52 subRule = string.cssText.split('#')[1];
53 subRule = subRule.split(')')[0];
54 shouldBe("subRule", "'" + expectedTexts[i] + "'");
55 } else {
56 subRule = string;
57 shouldBe("subRule.cssText", "'" + expectedTexts[i] + "'");
58 }
59 }
60 }
61
62 document.body.removeChild(div); 16 document.body.removeChild(div);
63 } 17 }
64 18
65 testImageSetRule("Single value for background-image", 19 testImageSetRule("Single value for background-image",
66 "background-image", 20 "background-image",
67 "url('#a') 1x", 2, 21 "url(#a) 1x");
68 ["a", "1"]);
69 22
70 testImageSetRule("Multiple values for background-image", 23 testImageSetRule("Multiple values for background-image",
71 "background-image", 24 "background-image",
72 "url('#a') 1x, url('#b') 2x", 4, 25 "url(#a) 1x, url(#b) 2x");
73 ["a", "1", "b", "2"]);
74 26
75 testImageSetRule("Multiple values for background-image, out of order", 27 testImageSetRule("Multiple values for background-image, out of order",
76 "background-image", 28 "background-image",
77 "url('#c') 3x, url('#b') 2x, url('#a') 1x", 6, 29 "url(#c) 3x, url(#b) 2x, url(#a) 1x");
78 ["c", "3", "b", "2", "a", "1"]);
79 30
80 testImageSetRule("Single value for content", 31 testImageSetRule("Single value for content",
81 "content", 32 "content",
82 "url('#a') 1x", 2, 33 "url(#a) 1x");
83 ["a", "1"]);
84 34
85 testImageSetRule("Multiple values for content", 35 testImageSetRule("Multiple values for content",
86 "content", 36 "content",
87 "url('#a') 1x, url('#b') 2x", 4, 37 "url(#a) 1x, url(#b) 2x");
88 ["a", "1", "b", "2"]);
89 38
90 testImageSetRule("Single value for border-image", 39 testImageSetRule("Single value for border-image",
91 "-webkit-border-image", 40 "-webkit-border-image",
92 "url('#a') 1x", 2, 41 "url(#a) 1x");
93 ["a", "1"]);
94 42
95 testImageSetRule("Multiple values for border-image", 43 testImageSetRule("Multiple values for border-image",
96 "-webkit-border-image", 44 "-webkit-border-image",
97 "url('#a') 1x, url('#b') 2x", 4, 45 "url(#a) 1x, url(#b) 2x");
98 ["a", "1", "b", "2"]);
99 46
100 testImageSetRule("Single value for -webkit-mask-box-image-source", 47 testImageSetRule("Single value for -webkit-mask-box-image-source",
101 "-webkit-mask-box-image-source", 48 "-webkit-mask-box-image-source",
102 "url('#a') 1x", 2, 49 "url(#a) 1x");
103 ["a", "1"]);
104 50
105 testImageSetRule("Multiple values for -webkit-mask-box-image-source", 51 testImageSetRule("Multiple values for -webkit-mask-box-image-source",
106 "-webkit-mask-box-image-source", 52 "-webkit-mask-box-image-source",
107 "url('#a') 1x, url('#b') 2x", 4, 53 "url(#a) 1x, url(#b) 2x");
108 ["a", "1", "b", "2"]);
109 54
110 successfullyParsed = true; 55 successfullyParsed = true;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698