OLD | NEW |
1 description('Testing the parsing of the -webkit-shape-inside property.'); | 1 description('Testing the parsing of the -webkit-shape-inside property.'); |
2 | 2 |
3 if (window.internals) | 3 if (window.internals) |
4 window.internals.settings.setCSSExclusionsEnabled(true); | 4 window.internals.settings.setCSSExclusionsEnabled(true); |
5 | 5 |
6 function testCSSText(declaration, expected) | 6 function testCSSText(declaration, expected) |
7 { | 7 { |
8 var element = document.createElement("div"); | 8 var element = document.createElement("div"); |
9 element.style.cssText = "-webkit-shape-inside: " + declaration; | 9 element.style.cssText = "-webkit-shape-inside: " + declaration; |
10 return element.style.webkitShapeInside; | 10 return element.style.webkitShapeInside; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 return "parent: " + parentActual + ", child: " + childActual; | 43 return "parent: " + parentActual + ", child: " + childActual; |
44 } | 44 } |
45 | 45 |
46 function test(value, expected) { | 46 function test(value, expected) { |
47 var unevaledString = '"' + value.replace(/\\/g, "\\\\").replace(/"/g, "\"").
replace(/\n/g, "\\n").replace(/\r/g, "\\r") + '"'; | 47 var unevaledString = '"' + value.replace(/\\/g, "\\\\").replace(/"/g, "\"").
replace(/\n/g, "\\n").replace(/\r/g, "\\r") + '"'; |
48 shouldBeEqualToString('testCSSText(' + unevaledString + ')', expected); | 48 shouldBeEqualToString('testCSSText(' + unevaledString + ')', expected); |
49 shouldBeEqualToString('testComputedStyle(' + unevaledString + ')', expected)
; | 49 shouldBeEqualToString('testComputedStyle(' + unevaledString + ')', expected)
; |
50 } | 50 } |
51 | 51 |
| 52 // Need to remove the base URL to avoid having local paths in the expected resul
ts. |
| 53 function removeBaseURL(src) { |
| 54 var urlRegexp = /url\(([^\)]*)\)/g; |
| 55 return src.replace(urlRegexp, function(match, url) { |
| 56 return "url(" + url.substr(url.lastIndexOf("/") + 1) + ")"; |
| 57 }); |
| 58 } |
| 59 |
| 60 function testLocalURL(value, expected) { |
| 61 var unevaledString = '"' + value.replace(/\\/g, "\\\\").replace(/"/g, "\"").
replace(/\n/g, "\\n").replace(/\r/g, "\\r") + '"'; |
| 62 shouldBeEqualToString('removeBaseURL(testCSSText(' + unevaledString + '))',
expected); |
| 63 shouldBeEqualToString('removeBaseURL(testComputedStyle(' + unevaledString +
'))', expected); |
| 64 } |
| 65 |
52 function negative_test(value) { | 66 function negative_test(value) { |
53 var unevaledString = '"' + value.replace(/\\/g, "\\\\").replace(/"/g, "\"").
replace(/\n/g, "\\n").replace(/\r/g, "\\r") + '"'; | 67 var unevaledString = '"' + value.replace(/\\/g, "\\\\").replace(/"/g, "\"").
replace(/\n/g, "\\n").replace(/\r/g, "\\r") + '"'; |
54 shouldBeEqualToString('testCSSText(' + unevaledString + ')', ''); | 68 shouldBeEqualToString('testCSSText(' + unevaledString + ')', ''); |
55 shouldBeEqualToString('testComputedStyle(' + unevaledString + ')', 'outside-
shape'); | 69 shouldBeEqualToString('testComputedStyle(' + unevaledString + ')', 'outside-
shape'); |
56 } | 70 } |
57 | 71 |
58 // positive tests | 72 // positive tests |
59 | 73 |
60 test("auto", "auto"); | 74 test("auto", "auto"); |
61 test("outside-shape", "outside-shape"); | 75 test("outside-shape", "outside-shape"); |
62 test("rectangle(10px, 20px, 30px, 40px)", "rectangle(10px, 20px, 30px, 40px)"); | 76 test("rectangle(10px, 20px, 30px, 40px)", "rectangle(10px, 20px, 30px, 40px)"); |
63 test("rectangle(10px, 20px, 30px, 40px, 5px)", "rectangle(10px, 20px, 30px, 40px
, 5px)"); | 77 test("rectangle(10px, 20px, 30px, 40px, 5px)", "rectangle(10px, 20px, 30px, 40px
, 5px)"); |
64 test("rectangle(10px, 20px, 30px, 40px, 5px, 10px)", "rectangle(10px, 20px, 30px
, 40px, 5px, 10px)"); | 78 test("rectangle(10px, 20px, 30px, 40px, 5px, 10px)", "rectangle(10px, 20px, 30px
, 40px, 5px, 10px)"); |
65 | 79 |
66 test("circle(10px, 20px, 30px)", "circle(10px, 20px, 30px)"); | 80 test("circle(10px, 20px, 30px)", "circle(10px, 20px, 30px)"); |
67 | 81 |
68 test("ellipse(10px, 20px, 30px, 40px)", "ellipse(10px, 20px, 30px, 40px)"); | 82 test("ellipse(10px, 20px, 30px, 40px)", "ellipse(10px, 20px, 30px, 40px)"); |
69 | 83 |
70 test("polygon(10px 20px, 30px 40px, 40px 50px)", "polygon(nonzero, 10px 20px, 30
px 40px, 40px 50px)"); | 84 test("polygon(10px 20px, 30px 40px, 40px 50px)", "polygon(nonzero, 10px 20px, 30
px 40px, 40px 50px)"); |
71 test("polygon(evenodd, 10px 20px, 30px 40px, 40px 50px)", "polygon(evenodd, 10px
20px, 30px 40px, 40px 50px)"); | 85 test("polygon(evenodd, 10px 20px, 30px 40px, 40px 50px)", "polygon(evenodd, 10px
20px, 30px 40px, 40px 50px)"); |
72 test("polygon(nonzero, 10px 20px, 30px 40px, 40px 50px)", "polygon(nonzero, 10px
20px, 30px 40px, 40px 50px)"); | 86 test("polygon(nonzero, 10px 20px, 30px 40px, 40px 50px)", "polygon(nonzero, 10px
20px, 30px 40px, 40px 50px)"); |
73 | 87 |
| 88 testLocalURL("url(\'image\')", "url(image)"); |
| 89 |
74 shouldBeEqualToString('testNotInherited("auto", "rectangle(10px, 20px, 30px, 40p
x)")', "parent: auto, child: rectangle(10px, 20px, 30px, 40px)"); | 90 shouldBeEqualToString('testNotInherited("auto", "rectangle(10px, 20px, 30px, 40p
x)")', "parent: auto, child: rectangle(10px, 20px, 30px, 40px)"); |
75 shouldBeEqualToString('testNotInherited("outside-shape", "rectangle(10px, 20px,
30px, 40px)")', "parent: outside-shape, child: rectangle(10px, 20px, 30px, 40px)
"); | 91 shouldBeEqualToString('testNotInherited("outside-shape", "rectangle(10px, 20px,
30px, 40px)")', "parent: outside-shape, child: rectangle(10px, 20px, 30px, 40px)
"); |
76 shouldBeEqualToString('testNotInherited("rectangle(10px, 20px, 30px, 40px)", "in
itial")', "parent: rectangle(10px, 20px, 30px, 40px), child: outside-shape"); | 92 shouldBeEqualToString('testNotInherited("rectangle(10px, 20px, 30px, 40px)", "in
itial")', "parent: rectangle(10px, 20px, 30px, 40px), child: outside-shape"); |
77 shouldBeEqualToString('testNotInherited("rectangle(10px, 20px, 30px, 40px)", "")
', "parent: rectangle(10px, 20px, 30px, 40px), child: outside-shape"); | 93 shouldBeEqualToString('testNotInherited("rectangle(10px, 20px, 30px, 40px)", "")
', "parent: rectangle(10px, 20px, 30px, 40px), child: outside-shape"); |
78 shouldBeEqualToString('testNotInherited("rectangle(10px, 20px, 30px, 40px)", "in
herit")', "parent: rectangle(10px, 20px, 30px, 40px), child: rectangle(10px, 20p
x, 30px, 40px)"); | 94 shouldBeEqualToString('testNotInherited("rectangle(10px, 20px, 30px, 40px)", "in
herit")', "parent: rectangle(10px, 20px, 30px, 40px), child: rectangle(10px, 20p
x, 30px, 40px)"); |
79 shouldBeEqualToString('testNotInherited("", "inherit")', "parent: outside-shape,
child: outside-shape"); | 95 shouldBeEqualToString('testNotInherited("", "inherit")', "parent: outside-shape,
child: outside-shape"); |
80 shouldBeEqualToString('testNotInherited("auto", "inherit")', "parent: auto, chil
d: auto"); | 96 shouldBeEqualToString('testNotInherited("auto", "inherit")', "parent: auto, chil
d: auto"); |
81 | 97 |
82 // negative tests | 98 // negative tests |
83 | 99 |
(...skipping 21 matching lines...) Expand all Loading... |
105 | 121 |
106 negative_test("polygon()"); | 122 negative_test("polygon()"); |
107 negative_test("polygon(evenodd 10px 20px, 30px 40px, 40px 50px)"); | 123 negative_test("polygon(evenodd 10px 20px, 30px 40px, 40px 50px)"); |
108 negative_test("polygon(nonzero 10px 20px, 30px 40px, 40px 50px)"); | 124 negative_test("polygon(nonzero 10px 20px, 30px 40px, 40px 50px)"); |
109 negative_test("polygon(nonzero)"); | 125 negative_test("polygon(nonzero)"); |
110 negative_test("polygon(evenodd)"); | 126 negative_test("polygon(evenodd)"); |
111 negative_test("polygon(10px)"); | 127 negative_test("polygon(10px)"); |
112 negative_test("polygon(nonzero,10px)"); | 128 negative_test("polygon(nonzero,10px)"); |
113 negative_test("polygon(evenodd,12px)"); | 129 negative_test("polygon(evenodd,12px)"); |
114 negative_test("polygon(10px, 20px, 30px, 40px, 40px, 50px)"); | 130 negative_test("polygon(10px, 20px, 30px, 40px, 40px, 50px)"); |
OLD | NEW |