summaryrefslogtreecommitdiffstats
path: root/devtools/client/commandline/test/browser_cmd_cookie.js
blob: 37a8205cbd9ea33261a955b014fc29c97d04c352 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

// Tests that the cookie commands works as they should

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

function test() {
  helpers.addTabWithToolbar(TEST_URI, function (options) {
    return helpers.audit(options, [
      {
        setup: "cookie",
        check: {
          input:  "cookie",
          hints:        " list",
          markup: "IIIIII",
          status: "ERROR"
        },
      },
      {
        setup: "cookie lis",
        check: {
          input:  "cookie lis",
          hints:            "t",
          markup: "IIIIIIVIII",
          status: "ERROR"
        },
      },
      {
        setup: "cookie list",
        check: {
          input:  "cookie list",
          hints:             "",
          markup: "VVVVVVVVVVV",
          status: "VALID"
        },
      },
      {
        setup: "cookie remove",
        check: {
          input:  "cookie remove",
          hints:               " <name>",
          markup: "VVVVVVVVVVVVV",
          status: "ERROR"
        },
      },
      {
        setup: "cookie set",
        check: {
          input:  "cookie set",
          hints:            " <name> <value> [options]",
          markup: "VVVVVVVVVV",
          status: "ERROR"
        },
      },
      {
        setup: "cookie set fruit",
        check: {
          input:  "cookie set fruit",
          hints:                  " <value> [options]",
          markup: "VVVVVVVVVVVVVVVV",
          status: "ERROR"
        },
      },
      {
        setup: "cookie set fruit ban",
        check: {
          input:  "cookie set fruit ban",
          hints:                      " [options]",
          markup: "VVVVVVVVVVVVVVVVVVVV",
          status: "VALID",
          args: {
            name: { value: "fruit" },
            value: { value: "ban" },
            secure: { value: false },
          }
        },
      },
      {
        setup:    'cookie set fruit ban --path ""',
        check: {
          input:  'cookie set fruit ban --path ""',
          hints:                                " [options]",
          markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
          status: "VALID",
          args: {
            name: { value: "fruit" },
            value: { value: "ban" },
            path: { value: "" },
            secure: { value: false },
          }
        },
      },
      {
        setup: "cookie list",
        exec: {
          output: [ /zap=zep/, /zip=zop/, /Edit/ ]
        }
      },
      {
        setup: "cookie set zup banana",
        check: {
          args: {
            name: { value: "zup" },
            value: { value: "banana" },
          }
        },
        exec: {
          output: ""
        }
      },
      {
        setup: "cookie list",
        exec: {
          output: [ /zap=zep/, /zip=zop/, /zup=banana/, /Edit/ ]
        }
      },
      {
        setup: "cookie remove zip",
        exec: { },
      },
      {
        setup: "cookie list",
        exec: {
          output: [ /zap=zep/, /zup=banana/, /Edit/ ]
        },
        post: function (output, text) {
          ok(!text.includes("zip"), "");
          ok(!text.includes("zop"), "");
        }
      },
      {
        setup: "cookie remove zap",
        exec: { },
      },
      {
        setup: "cookie list",
        exec: {
          output: [ /zup=banana/, /Edit/ ]
        },
        post: function (output, text) {
          ok(!text.includes("zap"), "");
          ok(!text.includes("zep"), "");
          ok(!text.includes("zip"), "");
          ok(!text.includes("zop"), "");
        }
      },
      {
        setup: "cookie remove zup",
        exec: { }
      },
      {
        setup: "cookie list",
        exec: {
          output: "No cookies found for host example.com"
        },
        post: function (output, text) {
          ok(!text.includes("zap"), "");
          ok(!text.includes("zep"), "");
          ok(!text.includes("zip"), "");
          ok(!text.includes("zop"), "");
          ok(!text.includes("zup"), "");
          ok(!text.includes("banana"), "");
          ok(!text.includes("Edit"), "");
        }
      },
    ]);
  }).then(finish, helpers.handleError);
}