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

"use strict";

// Test whether ESCAPE keypress cancels dragging of an element.

const TEST_URL = URL_ROOT + "doc_markup_dragdrop.html";

add_task(async function () {
  const { inspector } = await openInspectorForURL(TEST_URL);
  const { markup } = inspector;

  info("Get a test container");
  await selectNode("#test", inspector);
  const container = await getContainerForSelector("#test", inspector);

  info("Simulate a drag/drop on this container");
  await simulateNodeDrag(inspector, "#test");

  ok(
    container.isDragging && markup.isDragging,
    "The container is being dragged"
  );
  ok(
    markup.doc.body.classList.contains("dragging"),
    "The dragging css class was added"
  );

  info("Simulate ESCAPE keypress");
  EventUtils.sendKey("escape", inspector.panelWin);

  ok(!container.isDragging && !markup.isDragging, "The dragging has stopped");
  ok(
    !markup.doc.body.classList.contains("dragging"),
    "The dragging css class was removed"
  );
});