diff --git a/test/spec/Extn-CSSColorPreview-integ-test.js b/test/spec/Extn-CSSColorPreview-integ-test.js index 206915d6b..764921258 100644 --- a/test/spec/Extn-CSSColorPreview-integ-test.js +++ b/test/spec/Extn-CSSColorPreview-integ-test.js @@ -63,6 +63,38 @@ define(function (require, exports, module) { await __PR.closeFile(); }); + function parseColorToRGB(color) { + // Create a temporary element to leverage the browser’s color parsing + const temp = document.createElement("div"); + temp.style.color = color; + document.body.appendChild(temp); + + // Compute the color set by the browser + const parsedColor = window.getComputedStyle(temp).color; // returns in rgb(...) format + document.body.removeChild(temp); + + return parsedColor; + } + + function areColorsEqual($element, color) { + const elem = $element instanceof $ ? $element[0] : $element; + const computedStyle = window.getComputedStyle(elem); + + const elementColor = computedStyle.backgroundColor; // typically returns "rgb(r, g, b)" + const normalizedGivenColor = parseColorToRGB(color); // convert given color to "rgb(r, g, b)" + + return elementColor === normalizedGivenColor; + } + + function validateMultipleColors(editor, lineNumber, colors) { + const gutterMarker = $(editor.getGutterMarker(lineNumber, GUTTER_NAME)).find(".color-box"); + let numColors = gutterMarker.length; + __PR.validateEqual(numColors, colors.length); + for(let i=0; i