blob: 85bbab35d7626a441e40dbb15a4e99da2c7299a9 [file] [log] [blame]
<!DOCTYPE html>
<title>Test whitespace parsing on canvas attributes that invoke the CSS parser</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
var ctx;
function whiteSpaceTest(attribute, input, output) {
var canvas = document.createElement('canvas');
ctx = canvas.getContext('2d');
eval('ctx.' + attribute + ' = "' + input + '"');
assert_equals(eval('ctx.' + attribute), output);
}
generate_tests(whiteSpaceTest, [
['', 'fillStyle', ' red', '#ff0000'],
['', 'fillStyle', 'red ', '#ff0000'],
['', 'fillStyle', '\tred', '#ff0000'],
['', 'fillStyle', 'red\t', '#ff0000'],
['', 'fillStyle', ' #f00', '#ff0000'],
['', 'fillStyle', '#f00 ', '#ff0000'],
['', 'fillStyle', '\t#f00', '#ff0000'],
['', 'fillStyle', '#f00\t', '#ff0000'],
['', 'fillStyle', ' rgb(255, 0, 0)', '#ff0000'],
['', 'fillStyle', 'rgb(255,0,0) ', '#ff0000'],
['', 'fillStyle', 'invalid', '#000000'], // Sanity check
['', 'strokeStyle', ' red', '#ff0000'],
['', 'strokeStyle', 'red ', '#ff0000'],
['', 'strokeStyle', '\tred', '#ff0000'],
['', 'strokeStyle', 'red\t', '#ff0000'],
['', 'strokeStyle', 'invalid', '#000000'], // Sanity check
// The filter attribute is different: it does not get re-serialized
['', 'filter', ' blur(5px)', ' blur(5px)'],
['', 'filter', 'blur(5px) ', 'blur(5px) '],
['', 'filter', 'blur( 5px)', 'blur( 5px)'],
['', 'filter', '\tblur(5px)', '\tblur(5px)'],
['', 'filter', 'blur(5px)\t', 'blur(5px)\t'],
['', 'filter', 'invalid', 'none'], // Sanity check
]);
</script>