blob: 39736a2c513bacf5381e9b807f186c78b5f02662 [file] [log] [blame]
function isGtk()
{
// Set in Tools/WebKitTestRunner/gtk/TestControllerGTK.cpp.
return navigator.userAgent.includes("WebKitTestRunnerGTK");
}
function isWPE()
{
// Set in Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp.
return navigator.userAgent.includes("WebKitTestRunnerWPE");
}
function videoCanvasPixelComparisonTolerance()
{
if (isGtk())
return 6;
return 2;
}
function checkPixelColorWithTolerance(pixel, r, g, b, a)
{
const tolerance = videoCanvasPixelComparisonTolerance();
return Math.abs(pixel[0] - r) <= tolerance
&& Math.abs(pixel[1] - g) <= tolerance
&& Math.abs(pixel[2] - b) <= tolerance
&& Math.abs(pixel[3] - a) <= tolerance;
}
function isPixelBlack(pixel)
{
return checkPixelColorWithTolerance(pixel, 0, 0, 0, 255);
}
function isPixelTransparent(pixel)
{
return checkPixelColorWithTolerance(pixel, 0, 0, 0, 0);
}
function isPixelWhite(pixel)
{
return checkPixelColorWithTolerance(pixel, 255, 255, 255, 255);
}
function isPixelGray(pixel)
{
return checkPixelColorWithTolerance(pixel, 128, 128, 128, 255);
}