MCPcopy Create free account
hub / github.com/nodejs/node / expectColor

Function expectColor

test/fixtures/wpt/resources/SVGAnimationTestCase-testharness.js:20–30  ·  view source on GitHub ↗
(element, red, green, blue, property)

Source from the content-addressed store, hash-verified

18}
19
20function expectColor(element, red, green, blue, property) {
21 if (typeof property != "string")
22 color = getComputedStyle(element).getPropertyValue("color");
23 else
24 color = getComputedStyle(element).getPropertyValue(property);
25 var re = new RegExp("rgba?\\(([^, ]*), ([^, ]*), ([^, ]*)(?:, )?([^, ]*)\\)");
26 rgb = re.exec(color);
27 assert_approx_equals(Number(rgb[1]), red, 2.0);
28 assert_approx_equals(Number(rgb[2]), green, 2.0);
29 assert_approx_equals(Number(rgb[3]), blue, 2.0);
30}
31
32function createSVGElement(type) {
33 return document.createElementNS("http://www.w3.org/2000/svg", type);

Callers

nothing calls this directly

Calls 2

assert_approx_equalsFunction · 0.70
execMethod · 0.45

Tested by

no test coverage detected