Changeset 222055 in webkit
- Timestamp:
- Sep 14, 2017 3:01:25 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r222054 r222055 1 2017-09-14 Matt Baker <mattbaker@apple.com> 2 3 Web Inspector: Color created from an RGB/HSL triplet returns bad component arrays 4 https://bugs.webkit.org/show_bug.cgi?id=176811 5 <rdar://problem/34397529> 6 7 Reviewed by Joseph Pecoraro. 8 9 Add tests for Colors constructed from a format and component array. 10 11 * inspector/model/color-expected.txt: 12 * inspector/model/color.html: 13 Drive-by cleanup: use InspectorTest.expectShallowEqual. 14 1 15 2017-09-14 Ryan Haddad <ryanhaddad@apple.com> 2 16 -
trunk/LayoutTests/inspector/model/color-expected.txt
r220119 r222055 104 104 PASS: '#11223345' should not be serializable as a short Hex 105 105 106 -- Running test case: WI.Color from components 107 Check components for color 'rgb(255, 0, 0)'. 108 PASS: Should have rgb of [255,0,0]. 109 PASS: Should have rgba of [255,0,0,1]. 110 PASS: Should have hsl of [0,100,50]. 111 PASS: Should have hsla of [0,100,50,1]. 112 Check components for color 'rgba(128, 128, 128, 0.5)'. 113 PASS: Should have rgb of [128,128,128]. 114 PASS: Should have rgba of [128,128,128,0.5]. 115 PASS: Should have hsl of [0,0,50]. 116 PASS: Should have hsla of [0,0,50,0.5]. 117 Check components for color 'hsl(0, 0%, 50%)'. 118 PASS: Should have rgb of [128,128,128]. 119 PASS: Should have rgba of [128,128,128,1]. 120 PASS: Should have hsl of [0,0,50]. 121 PASS: Should have hsla of [0,0,50,1]. 122 Check components for color 'hsla(0, 0%, 50%, 0.5)'. 123 PASS: Should have rgb of [128,128,128]. 124 PASS: Should have rgba of [128,128,128,0.5]. 125 PASS: Should have hsl of [0,0,50]. 126 PASS: Should have hsla of [0,0,50,0.5]. 127 106 128 -- Running test case: WI.Color.prototype.nextFormat 107 129 PASS: All format phases of 'transparent' should be as expected. -
trunk/LayoutTests/inspector/model/color.html
r220119 r222055 116 116 description: "Test different color properties.", 117 117 test(resolve, reject) { 118 function shallowEqual(arr1, arr2) {119 if (arr1.length !== arr2.length)120 return false;121 122 for (let i = 0; i < arr1.length; ++i) {123 if (arr1[i] !== arr2[i])124 return false;125 }126 127 return true;128 }129 130 118 let color; 131 119 … … 134 122 InspectorTest.expectThat(color.simple === true, "'red' should be simple."); 135 123 InspectorTest.expectThat(color.isKeyword() === true, "'red' should be a keyword."); 136 InspectorTest.expect That(shallowEqual(color.rgb, [255, 0, 0]), "'red' has rgb of [255, 0, 0].");137 InspectorTest.expect That(shallowEqual(color.rgba, [255, 0, 0, 1]), "'red' has rgba of [255, 0, 0, 1].");138 InspectorTest.expect That(shallowEqual(color.hsl, [0, 100, 50]), "'red' has hsl of [0, 100, 50].");139 InspectorTest.expect That(shallowEqual(color.hsla, [0, 100, 50, 1]), "'red' has hsla of [0, 100, 50, 1].");124 InspectorTest.expectShallowEqual(color.rgb, [255, 0, 0], "'red' has rgb of [255, 0, 0]."); 125 InspectorTest.expectShallowEqual(color.rgba, [255, 0, 0, 1], "'red' has rgba of [255, 0, 0, 1]."); 126 InspectorTest.expectShallowEqual(color.hsl, [0, 100, 50], "'red' has hsl of [0, 100, 50]."); 127 InspectorTest.expectShallowEqual(color.hsla, [0, 100, 50, 1], "'red' has hsla of [0, 100, 50, 1]."); 140 128 InspectorTest.expectThat(color.canBeSerializedAsShortHEX() === true, "'red' should be serializable as a short Hex"); 141 129 … … 144 132 InspectorTest.expectThat(color.simple === false, "'transparent' should not be simple."); 145 133 InspectorTest.expectThat(color.isKeyword() === true, "'transparent' should be a keyword."); 146 InspectorTest.expect That(shallowEqual(color.rgb, [0, 0, 0]), "'transparent' has rgb of [0, 0, 0].");147 InspectorTest.expect That(shallowEqual(color.rgba, [0, 0, 0, 0]), "'transparent' has rgba of [0, 0, 0, 0].");148 InspectorTest.expect That(shallowEqual(color.hsl, [0, 0, 0]), "'transparent' has hsl of [0, 0, 0].");149 InspectorTest.expect That(shallowEqual(color.hsla, [0, 0, 0, 0]), "'transparent' has hsla of [0, 0, 0, 0].");134 InspectorTest.expectShallowEqual(color.rgb, [0, 0, 0], "'transparent' has rgb of [0, 0, 0]."); 135 InspectorTest.expectShallowEqual(color.rgba, [0, 0, 0, 0], "'transparent' has rgba of [0, 0, 0, 0]."); 136 InspectorTest.expectShallowEqual(color.hsl, [0, 0, 0], "'transparent' has hsl of [0, 0, 0]."); 137 InspectorTest.expectShallowEqual(color.hsla, [0, 0, 0, 0], "'transparent' has hsla of [0, 0, 0, 0]."); 150 138 InspectorTest.expectThat(color.canBeSerializedAsShortHEX() === true, "'transparent' should be serializable as a short Hex"); 151 139 … … 154 142 InspectorTest.expectThat(color.simple === false, "'#11122233' should be not be simple."); 155 143 InspectorTest.expectThat(color.isKeyword() === false, "'#11122233' should not be a keyword."); 156 InspectorTest.expect That(shallowEqual(color.rgba, [17, 18, 34, 0.2]), "'#11122233' has rgba of [17, 18, 34, 0.2].");157 InspectorTest.expect That(shallowEqual(color.hsla, [236, 33, 10, 0.2]), "'#11122233' has hsla of [236, 33, 10, 0.2].");144 InspectorTest.expectShallowEqual(color.rgba, [17, 18, 34, 0.2], "'#11122233' has rgba of [17, 18, 34, 0.2]."); 145 InspectorTest.expectShallowEqual(color.hsla, [236, 33, 10, 0.2], "'#11122233' has hsla of [236, 33, 10, 0.2]."); 158 146 InspectorTest.expectThat(color.canBeSerializedAsShortHEX() === false, "'#11122233' should not be serializable as a short Hex"); 159 147 … … 163 151 color = WI.Color.fromString("#11223345"); 164 152 InspectorTest.expectThat(color.canBeSerializedAsShortHEX() === false, "'#11223345' should not be serializable as a short Hex"); 153 154 resolve(); 155 } 156 }); 157 158 suite.addTestCase({ 159 name: "WI.Color from components", 160 description: "Test different three- and four-component colors.", 161 test(resolve, reject) { 162 function test(color, components) { 163 InspectorTest.log(`Check components for color '${color.toString()}'.`); 164 for (let key in components) { 165 let value = components[key]; 166 InspectorTest.expectShallowEqual(color[key], value, `Should have ${key} of ${JSON.stringify(value)}.`); 167 } 168 } 169 170 test(new WI.Color(WI.Color.Format.RGB, [255, 0, 0]), { 171 rgb: [255, 0, 0], 172 rgba: [255, 0, 0, 1], 173 hsl: [0, 100, 50], 174 hsla: [0, 100, 50, 1], 175 }); 176 177 test(new WI.Color(WI.Color.Format.RGBA, [128, 128, 128, 0.5]), { 178 rgb: [128, 128, 128], 179 rgba: [128, 128, 128, 0.5], 180 hsl: [0, 0, 50], 181 hsla: [0, 0, 50, 0.5], 182 }); 183 184 test(new WI.Color(WI.Color.Format.HSL, [0, 0, 50]), { 185 rgb: [128, 128, 128], 186 rgba: [128, 128, 128, 1], 187 hsl: [0, 0, 50], 188 hsla: [0, 0, 50, 1], 189 }); 190 191 test(new WI.Color(WI.Color.Format.HSLA, [0, 0, 50, 0.5]), { 192 rgb: [128, 128, 128], 193 rgba: [128, 128, 128, 0.5], 194 hsl: [0, 0, 50], 195 hsla: [0, 0, 50, 0.5], 196 }); 165 197 166 198 resolve(); -
trunk/Source/WebInspectorUI/ChangeLog
r222052 r222055 1 2017-09-14 Matt Baker <mattbaker@apple.com> 2 3 Web Inspector: Color created from an RGB/HSL triplet returns bad component arrays 4 https://bugs.webkit.org/show_bug.cgi?id=176811 5 <rdar://problem/34397529> 6 7 Reviewed by Joseph Pecoraro. 8 9 A Color constructed from a format and RGB/HSL triplet should set its 10 alpha component to 1 instead of leaving it undefined. Color properties 11 and member functions expect the components array to have a length of four. 12 13 * UserInterface/Models/Color.js: 14 (WI.Color): 15 1 16 2017-09-14 Joseph Pecoraro <pecoraro@apple.com> 2 17 -
trunk/Source/WebInspectorUI/UserInterface/Models/Color.js
r220119 r222055 33 33 { 34 34 this.format = format; 35 36 if (components.length === 3) 37 components.push(1); 35 38 36 39 if (format === WI.Color.Format.HSL || format === WI.Color.Format.HSLA)
Note: See TracChangeset
for help on using the changeset viewer.