summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/rules/test/browser_rules_shapes-toggle_04.js
blob: 0add21381f69d8abffbfe8253c138f243f6e8351 (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
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test toggling the shapes highlighter in the rule view and modifying the 'clip-path'
// declaration.

const TEST_URI = `
  <style type='text/css'>
    #shape {
      width: 800px;
      height: 800px;
      clip-path: circle(25%);
    }
  </style>
  <div id="shape"></div>
`;

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

  info("Select a node with a shape value");
  await selectNode("#shape", inspector);
  const container = getRuleViewProperty(view, "#shape", "clip-path").valueSpan;
  let shapeToggle = container.querySelector(".ruleview-shapeswatch");

  info("Toggling ON the CSS shape highlighter from the rule-view.");
  const onHighlighterShown = highlighters.once("shapes-highlighter-shown");
  shapeToggle.click();
  await onHighlighterShown;

  info("Edit the clip-path property to ellipse.");
  const editor = await focusEditableField(view, container, 30);
  const onDone = view.once("ruleview-changed");
  editor.input.value = "ellipse(30% 20%);";
  EventUtils.synthesizeKey("VK_RETURN", {}, view.styleWindow);
  await onDone;

  info(
    "Check the shape highlighter and shape toggle button are still visible."
  );
  shapeToggle = container.querySelector(".ruleview-shapeswatch");
  ok(shapeToggle, "Shape highlighter toggle is visible.");
  ok(highlighters.shapesHighlighterShown, "CSS shape highlighter is shown.");
});