/* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; // Test for variables in rule view. const TEST_URI = URL_ROOT + "doc_variables_1.html"; add_task(async function () { await addTab(TEST_URI); const { inspector, view } = await openRuleView(); await selectNode("#target", inspector); info( "Tests basic support for CSS Variables for both single variable " + "and double variable. Formats tested: var(x, constant), var(x, var(y))" ); const unsetColor = getRuleViewProperty( view, "div", "color" ).valueSpan.querySelector(".inspector-unmatched"); is(unsetColor.textContent, " red", "red is unmatched in color"); await assertVariableTooltipForProperty(view, "div", "color", { header: // prettier-ignore '' + '' + '' + 'chartreuse' + '', // Computed value isn't displayed when it's the same as we put in the header computed: null, }); await assertVariableTooltipForProperty(view, "div", "background-color", { index: 0, header: "--not-set is not set", headerClasses: [], isMatched: false, }); await assertVariableTooltipForProperty(view, "div", "background-color", { index: 1, header: // prettier-ignore '' + '' + '' + 'seagreen' + '', // Computed value isn't displayed when it's the same as we put in the header computed: null, }); await assertVariableTooltipForProperty(view, "div", "outline-color", { header: // prettier-ignore '' + '' + '' + '' + 'var(' + '--color' + ')' + '' + '', computed: // prettier-ignore `` + `` + `` + `chartreuse` + ``, }); await assertVariableTooltipForProperty(view, "div", "border-color", { header: // prettier-ignore '' + 'var(' + '' + '--theme-color' + '' + ')' + '', computed: // prettier-ignore `light-dark(` + `` + `` + `` + `chartreuse` + `, ` + `` + `` + `` + `seagreen` + `` + `)`, }); await assertVariableTooltipForProperty(view, "div", "background", { header: // prettier-ignore '' + 'var(' + '' + '--empty' + '' + ')' + '', computed: "<empty>", computedClasses: ["empty-css-variable"], }); await assertVariableTooltipForProperty(view, "*", "--nested-with-empty", { header: "<empty>", headerClasses: ["empty-css-variable"], }); });