summaryrefslogtreecommitdiffstats
path: root/devtools/client/inspector/markup/test/browser_markup_dragdrop_escapeKeyPress.js
blob: 075d143521e7682adc3d42ff3d67cc97d782de1e (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
/* 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";

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

const TEST_URL = URL_ROOT + "doc_markup_dragdrop.html";

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

  info("Get a test container");
  yield selectNode("#test", inspector);
  let container = yield getContainerForSelector("#test", inspector);

  info("Simulate a drag/drop on this container");
  yield 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");
});