File: test_css-properties.html

package info (click to toggle)
firefox 147.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,324 kB
  • sloc: cpp: 7,607,156; javascript: 6,532,492; ansic: 3,775,158; python: 1,415,368; xml: 634,556; asm: 438,949; java: 186,241; sh: 62,751; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (87 lines) | stat: -rw-r--r-- 3,426 bytes parent folder | download | duplicates (11)
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE HTML>
<html>
<!--
Bug 1265798 - Replace inIDOMUtils.cssPropertyIsShorthand
-->
<head>
  <meta charset="utf-8">
  <title>Test CSS Properties Actor</title>
  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
  <script type="application/javascript" src="inspector-helpers.js"></script>
  <script type="application/javascript">
"use strict";

window.onload = function() {
  function toSortedString(array) {
    return JSON.stringify(array.sort());
  }

  const runCssPropertiesTests = async function(url) {
    info(`Opening tab with CssPropertiesActor support.`);
    // Open a new tab. The only property we are interested in is `target`.
    const { target } = await attachURL(url);
    const { cssProperties } = await target.getFront("cssProperties");

    ok(cssProperties.isKnown("border"),
      "The `border` shorthand property is known.");
    ok(cssProperties.isKnown("display"),
      "The `display` property is known.");
    ok(!cssProperties.isKnown("foobar"),
      "A fake property is not known.");
    ok(cssProperties.isKnown("--foobar"),
      "A CSS variable properly evaluates.");
    ok(cssProperties.isKnown("--foob\\{ar"),
      "A CSS variable with escaped character properly evaluates.");
    ok(cssProperties.isKnown("--fübar"),
      "A CSS variable unicode properly evaluates.");
    ok(!cssProperties.isKnown("--foo bar"),
      "A CSS variable with spaces fails");

    const marginProps = ["auto", "inherit", "initial", "unset", "revert", "revert-layer"];
    if(SpecialPowers.getBoolPref("layout.css.anchor-positioning.enabled")) {
      marginProps.push("anchor-size");
    }
    is(toSortedString(cssProperties.getValues("margin")),
       toSortedString(marginProps),
       "Can get values for the CSS margin.");
    is(cssProperties.getValues("foobar").length, 0,
      "Unknown values return an empty array.");

    const bgColorValues = cssProperties.getValues("background-color");
    ok(bgColorValues.includes("blanchedalmond"),
      "A property with color values includes blanchedalmond.");
    ok(bgColorValues.includes("papayawhip"),
      "A property with color values includes papayawhip.");
    ok(bgColorValues.includes("rgb"),
      "A property with color values includes non-colors.");

    // Check that the "special" shorthands for white-space are exposed.
    const whiteSpaceValues = cssProperties.getValues("white-space");
    ok(whiteSpaceValues.includes("normal"),
       "Values for the white-space shorthand include normal.");
    ok(whiteSpaceValues.includes("pre"),
       "Values for the white-space shorthand include pre.");
    ok(whiteSpaceValues.includes("pre-line"),
       "Values for the white-space shorthand include pre-line.");
    ok(whiteSpaceValues.includes("pre-wrap"),
       "Values for the white-space shorthand include pre-wrap.");
  };

  addAsyncTest(async function setup() {
    const url = document.getElementById("cssProperties").href;
    await runCssPropertiesTests(url);

    runNextTest();
  });

  SimpleTest.waitForExplicitFinish();
  runNextTest();
};
  </script>
</head>
<body>
  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1265798">Mozilla Bug 1265798</a>
  <a id="cssProperties" target="_blank" href="inspector_css-properties.html">Test Document</a>
</body>
</html>