summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/markup/test/browser_markup_tag_edit_04-delete.js
blob: 1446eba30434eac3314e48f7f8b281eaf606e41e (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
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Tests that a node can be deleted from the markup-view with the delete key.
// Also checks that after deletion the correct element is highlighted.
// The next sibling is preferred, but the parent is a fallback.

const HTML = `<style type="text/css">
                #pseudo::before { content: 'before'; }
                #pseudo::after { content: 'after'; }
              </style>
              <div id="parent">
                <div id="first"></div>
                <div id="second"></div>
                <div id="third"></div>
              </div>
              <div id="only-child">
                <div id="fourth"></div>
              </div>
              <div id="pseudo">
                <div id="fifth"></div>
              </div>`;
const TEST_URL = "data:text/html;charset=utf-8," + encodeURIComponent(HTML);

// List of all the test cases. Each item is an object with the following props:
// - selector: the css selector of the node that should be selected
// - focusedSelector: the css selector of the node we expect to be selected as
//   a result of the deletion
// - pseudo: (optional) if the focused node is actually supposed to be a pseudo element
//   of the specified selector.
// Note that after each test case, undo is called.
const TEST_DATA = [{
  selector: "#first",
  focusedSelector: "#second"
}, {
  selector: "#second",
  focusedSelector: "#third"
}, {
  selector: "#third",
  focusedSelector: "#second"
}, {
  selector: "#fourth",
  focusedSelector: "#only-child"
}, {
  selector: "#fifth",
  focusedSelector: "#pseudo",
  pseudo: "after"
}];

add_task(function* () {
  let {inspector} = yield openInspectorForURL(TEST_URL);

  for (let data of TEST_DATA) {
    yield checkDeleteAndSelection(inspector, "delete", data);
  }
});