summaryrefslogtreecommitdiffstats
path: root/devtools/client/commandline/test/browser_cmd_commands.js
blob: 6c69034ec17ea84c3354e385c39a4483faf3e301 (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Test various GCLI commands

const TEST_URI = "data:text/html;charset=utf-8,gcli-commands";
const HUDService = require("devtools/client/webconsole/hudservice");

// Use the old webconsole since pprint isn't working on new one (Bug 1304794)
Services.prefs.setBoolPref("devtools.webconsole.new-frontend-enabled", false);
registerCleanupFunction(function* () {
  Services.prefs.clearUserPref("devtools.webconsole.new-frontend-enabled");
});

function test() {
  return Task.spawn(spawnTest).then(finish, helpers.handleError);
}

function* spawnTest() {
  let options = yield helpers.openTab(TEST_URI);
  yield helpers.openToolbar(options);

  let subjectPromise = helpers.observeOnce("web-console-created");

  helpers.audit(options, [
    {
      setup: "console open",
      exec: { }
    }
  ]);

  let subject = yield subjectPromise;

  subject.QueryInterface(Ci.nsISupportsString);
  let hud = HUDService.getHudReferenceById(subject.data);
  ok(hud, "console open");

  let msg = yield hud.jsterm.execute("pprint(window)");

  ok(msg, "output for pprint(window)");

  yield helpers.audit(options, [
    {
      setup: "console clear",
      exec: { output: "" }
    }
  ]);

  let labels = hud.outputNode.querySelectorAll(".message");
  is(labels.length, 0, "no output in console");

  yield helpers.audit(options, [
    {
      setup: "console close",
      exec: { output: "" }
    }
  ]);

  ok(!HUDService.getHudReferenceById(hud.hudId), "console closed");

  yield helpers.closeToolbar(options);
  yield helpers.closeTab(options);
}