<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script>
var testScenarios = [
["Test default context creation parameters: srgb/uint8",
{},
{colorSpace: "srgb", pixelFormat: "uint8"}],
["Test CanvasColorSpace value srgb",
{colorSpace: "srgb"},
{colorSpace: "srgb", pixelFormat: "uint8"}],
["Test CanvasColorSpace value rec2020, no pixel format, falls back to rec2020/uint8",
{colorSpace: "rec2020"},
{colorSpace: "rec2020", pixelFormat: "uint8"}],
["Test CanvasColorSpace value p3, no pixel format, falls back to p3/uint8",
{colorSpace: "display-p3"},
{colorSpace: "display-p3", pixelFormat: "uint8"}],
["Test CanvasPixelFormat value uint8",
{pixelFormat: "uint8"},
{colorSpace: "srgb", pixelFormat: "uint8"}],
["Test CanvasPixelFormat value float16",
{pixelFormat: "float16"},
{colorSpace: "srgb", pixelFormat: "float16"}],
["Test supported color settings srgb/uint8",
{colorSpace: "srgb", pixelFormat: "uint8"},
{colorSpace: "srgb", pixelFormat: "uint8"}],
["Test supported color settings srgb/float16",
{colorSpace: "srgb", pixelFormat: "float16"},
{colorSpace: "srgb", pixelFormat: "float16"}],
["Test supported color settings rec2020/uint8, falls back to srgb/uint8",
{colorSpace: "rec2020", pixelFormat: "uint8"},
{colorSpace: "rec2020", pixelFormat: "uint8"}],
["Test supported color settings rec2020/float16",
{colorSpace: "rec2020", pixelFormat: "float16"},
{colorSpace: "rec2020", pixelFormat: "float16"}],
["Test supported color settings p3/uint8, falls back to srgb/uint8",
{colorSpace: "display-p3", pixelFormat: "uint8"},
{colorSpace: "display-p3", pixelFormat: "uint8"}],
["Test supported color settings p3/float16",
{colorSpace: "display-p3", pixelFormat: "float16"},
{colorSpace: "display-p3", pixelFormat: "float16"}],
];
function runTestScenario(contextCreationParameters, expectedContextAttributes) {
var canvas = document. createElement('canvas');
var ctx = canvas.getContext('2d', contextCreationParameters);
var contextAttributes = ctx.getContextAttributes();
assert_equals(contextAttributes.colorSpace, expectedContextAttributes.colorSpace);
assert_equals(contextAttributes.pixelFormat, expectedContextAttributes.pixelFormat);
}
generate_tests(runTestScenario, testScenarios);
</script>