summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/rules/test/browser_rules_cubicbezier-appears-on-swatch-click.js
blob: 8a967e1a8ab8c40ab54dd49379a75999d4796e72 (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
70
71
72
73
74
75
76
77
78
79
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Tests that cubic-bezier pickers appear when clicking on cubic-bezier
// swatches.

const TEST_URI = `
  <style type="text/css">
    div {
      animation: move 3s linear;
      transition: top 4s cubic-bezier(.1, 1.45, 1, -1.2);
    }
    .test {
      animation-timing-function: ease-in-out;
      transition-timing-function: ease-out;
    }
  </style>
  <div class="test">Testing the cubic-bezier tooltip!</div>
`;

add_task(async function () {
  await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI));
  const { inspector, view } = await openRuleView();
  await selectNode("div", inspector);

  const swatches = [];
  swatches.push(
    getRuleViewProperty(view, "div", "animation").valueSpan.querySelector(
      ".ruleview-bezierswatch"
    )
  );
  swatches.push(
    getRuleViewProperty(view, "div", "transition").valueSpan.querySelector(
      ".ruleview-bezierswatch"
    )
  );
  swatches.push(
    getRuleViewProperty(
      view,
      ".test",
      "animation-timing-function"
    ).valueSpan.querySelector(".ruleview-bezierswatch")
  );
  swatches.push(
    getRuleViewProperty(
      view,
      ".test",
      "transition-timing-function"
    ).valueSpan.querySelector(".ruleview-bezierswatch")
  );

  for (const swatch of swatches) {
    info("Testing that the cubic-bezier appears on cubicswatch click");
    await testAppears(view, swatch);
  }
});

async function testAppears(view, swatch) {
  ok(swatch, "The cubic-swatch exists");

  const bezier = view.tooltips.getTooltip("cubicBezier");
  ok(bezier, "The rule-view has the expected cubicBezier property");

  const bezierPanel = bezier.tooltip.panel;
  ok(bezierPanel, "The XUL panel for the cubic-bezier tooltip exists");

  const onBezierWidgetReady = bezier.once("ready");
  swatch.click();
  await onBezierWidgetReady;

  ok(true, "The cubic-bezier tooltip was shown on click of the cibuc swatch");
  ok(
    !inplaceEditor(swatch.parentNode),
    "The inplace editor wasn't shown as a result of the cibuc swatch click"
  );
  await hideTooltipAndWaitForRuleViewChanged(bezier, view);
}