summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_non_content_accessible_pseudos.html
blob: 81493b1a4af7e782e8ad6bb91f502c66d35852a1 (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
59
60
61
62
63
64
65
66
67
68
69
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style id="sheet"></style>
<script>
// Even though some of these no longer exist, we still do want to test that
// they aren't exposed to the web.
const NON_CONTENT_ACCESIBLE_PSEUDOS = [
  "::-moz-complex-control-wrapper",
  "::-moz-number-wrapper",
  "::-moz-number-text",
  "::-moz-number-spin-up",
  "::-moz-number-spin-down",
  "::-moz-number-spin-box",
  "::-moz-search-clear-button",

  ":-moz-native-anonymous",
  ":-moz-table-border-nonzero",
  ":-moz-browser-frame",
  ":-moz-devtools-highlighted",
  ":-moz-styleeditor-transitioning",
  ":-moz-handler-clicktoplay",
  ":-moz-handler-vulnerable-updatable",
  ":-moz-handler-vulnerable-no-update",
  ":-moz-handler-disabled",
  ":-moz-handler-blocked",
  ":-moz-handler-chrased",
  ":-moz-has-dir-attr",
  ":-moz-dir-attr-ltr",
  ":-moz-dir-attr-rtl",
  ":-moz-dir-attr-like-auto",
  ":-moz-autofill-preview",
  ":-moz-lwtheme",
  ":-moz-is-html",
  ":-moz-locale-dir(rtl)",
  ":-moz-locale-dir(ltr)",

  "::-moz-tree-row",
  "::-moz-tree-row(foo)",
];

test(function() {
  sheet.textContent = `div { color: initial }`;
  assert_equals(sheet.sheet.cssRules.length, 1);
}, "sanity");

for (const pseudo of NON_CONTENT_ACCESIBLE_PSEUDOS) {
  test(function() {
    sheet.textContent = `${pseudo} { color: blue; }`;
    assert_equals(sheet.sheet.cssRules.length, 0,
      pseudo + " shouldn't be accessible to content");
    if (pseudo.indexOf("::") === 0) {
      let pseudoStyle;
      try {
        pseudoStyle = getComputedStyle(document.documentElement, pseudo);
      } catch (ex) {
        // We can hit this when layout.css.computed-style.throw-on-invalid-pseudo is true
        assert_true(true, `${pseudo} shouldn't be visible to content`);
        return;
      }
      let elementStyle = getComputedStyle(document.documentElement);
      for (prop of pseudoStyle) {
        assert_equals(pseudoStyle[prop], elementStyle[prop],
                      pseudo + " styles shouldn't be visible from getComputedStyle");
      }
    }
  }, pseudo);
}
</script>