summaryrefslogtreecommitdiffstats
path: root/devtools/client/commandline/test/browser_cmd_listen.js
blob: 91746c2aad1900da63a9db1c4d8b7b0138f5c4f2 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

// Tests that the listen/unlisten commands work as they should.

const TEST_URI = "http://example.com/browser/devtools/client/commandline/" +
                 "test/browser_cmd_cookie.html";

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

var tests = {
  testInput: function (options) {
    return helpers.audit(options, [
      {
        setup:    "listen",
        check: {
          input:  "listen",
          markup: "VVVVVV",
          status: "VALID"
        },
      },
      {
        setup:    "unlisten",
        check: {
          input:  "unlisten",
          markup: "VVVVVVVV",
          status: "VALID"
        },
        exec: {
          output: "All TCP ports closed"
        }
      },
      {
        setup: function () {
          return helpers.setInput(options, "listen");
        },
        check: {
          input:  "listen",
          hints:        " [port] [protocol]",
          markup: "VVVVVV",
          status: "VALID"
        },
        exec: {
          output: "Listening on port " + Services.prefs
          .getIntPref("devtools.debugger.remote-port")
        }
      },
      {
        setup: function () {
          return helpers.setInput(options, "listen 8000");
        },
        exec: {
          output: "Listening on port 8000"
        }
      },
      {
        setup: function () {
          return helpers.setInput(options, "unlisten");
        },
        exec: {
          output: "All TCP ports closed"
        }
      }
    ]);
  },
};

function* testTask() {
  Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
  let options = yield helpers.openTab(TEST_URI);
  yield helpers.openToolbar(options);

  yield helpers.runTests(options, tests);

  yield helpers.closeToolbar(options);
  yield helpers.closeTab(options);
  Services.prefs.clearUserPref("devtools.debugger.remote-enabled");
}