summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/rules/test/browser_rules_variables_04-valid-chars.js
blob: 4e163b1fb75b5a4b33fb09dcdc68b200f6e47005 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* 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_4.html";

add_task(async function () {
  await addTab(TEST_URI);
  const { inspector, view } = await openRuleView();

  await testNumber(inspector, view);
  await testDash(inspector, view);
});

async function testNumber(inspector, view) {
  info(
    "Test support for allowing vars that begin with a number" +
      "Format: --10: 10px;"
  );

  await selectNode("#a", inspector);

  const upperCaseVarEl = getRuleViewProperty(
    view,
    "#a",
    "font-size"
  ).valueSpan.querySelector(".ruleview-variable");

  is(
    upperCaseVarEl.dataset.variable,
    "--10 = 10px",
    "variable that starts with a number is valid"
  );
}

async function testDash(inspector, view) {
  info(
    "Test support for allowing vars that begin with a dash" +
      "Format: ---blue: blue;"
  );

  await selectNode("#b", inspector);

  const upperCaseVarEl = getRuleViewProperty(
    view,
    "#b",
    "color"
  ).valueSpan.querySelector(".ruleview-variable");

  is(
    upperCaseVarEl.dataset.variable,
    "---blue = blue",
    "variable that starts with a dash is valid"
  );
}