There's a very similar function in sdk/tests/conformance/resources/webgl-test-utils.js -- checkCanvasRect. The difference is that the color is expressed as an array instead of four floats. It works against both WebGL-rendered canvases as well as canvases rendered with CanvasRenderingContext2D. It also supports an error range. Could you please refactor this test to use that comparison function?