| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/js-test.js"></script> |
| 4 <script src="resources/scripted-random.js"></script> | 4 <script src="resources/scripted-random.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <p id="description"></p> | 7 <p id="description"></p> |
| 8 <div id="console"></div> | 8 <div id="console"></div> |
| 9 <script> | 9 <script> |
| 10 description("This test fuzzes the color parser with semi-random attribute va
lues and dumps the results of any values that parse successfully."); | 10 description("This test fuzzes the color parser with semi-random attribute va
lues and dumps the results of any values that parse successfully."); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 "e", | 31 "e", |
| 32 "," | 32 "," |
| 33 ]; | 33 ]; |
| 34 | 34 |
| 35 var stopElement = document.createElementNS("http://www.w3.org/2000/svg", "st
op"); | 35 var stopElement = document.createElementNS("http://www.w3.org/2000/svg", "st
op"); |
| 36 function parseRGBColor(string) | 36 function parseRGBColor(string) |
| 37 { | 37 { |
| 38 try { | 38 try { |
| 39 stopElement.style.removeProperty("stop-color"); | 39 stopElement.style.removeProperty("stop-color"); |
| 40 stopElement.style.stopColor = string; | 40 stopElement.style.stopColor = string; |
| 41 var stopColor = stopElement.style.getPropertyCSSValue("stop-color"); | 41 var stopColor = stopElement.style.getPropertyValue("stop-color"); |
| 42 if (!stopColor) { | 42 if (!stopColor) { |
| 43 debug("Failed to parse: " + string); | 43 debug("Failed to parse: " + string); |
| 44 return; | 44 return; |
| 45 } | 45 } |
| 46 var rgbColor = stopColor.rgbColor; | 46 debug("Parsed as " + stopColor + ": " + string); |
| 47 var red = rgbColor.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER); | |
| 48 var green = rgbColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBE
R); | |
| 49 var blue = rgbColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)
; | |
| 50 var rgbColorString = "rgb(" + red + "," + green + "," + blue + ")"; | |
| 51 debug("Parsed as " + rgbColorString + ": " + string); | |
| 52 } catch(e) { | 47 } catch(e) { |
| 53 debug("Threw exception " + e + ": " + string); | 48 debug("Threw exception " + e + ": " + string); |
| 54 } | 49 } |
| 55 } | 50 } |
| 56 | 51 |
| 57 function fuzz() | 52 function fuzz() |
| 58 { | 53 { |
| 59 // Some valid values. | 54 // Some valid values. |
| 60 parseRGBColor("blue"); | 55 parseRGBColor("blue"); |
| 61 parseRGBColor("rgb(0, 255, 0)"); | 56 parseRGBColor("rgb(0, 255, 0)"); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 parseRGBColor("rgb(" + String.fromCharCode(0) + ")"); | 99 parseRGBColor("rgb(" + String.fromCharCode(0) + ")"); |
| 105 | 100 |
| 106 // One more valid value. | 101 // One more valid value. |
| 107 parseRGBColor("#0f0"); | 102 parseRGBColor("#0f0"); |
| 108 } | 103 } |
| 109 | 104 |
| 110 fuzz(); | 105 fuzz(); |
| 111 | 106 |
| 112 </script> | 107 </script> |
| 113 </html> | 108 </html> |
| OLD | NEW |