... |
... |
@@ -9,30 +9,14 @@ const asyncStorage = require("resource://devtools/shared/async-storage.js"); |
9
|
9
|
* Test if content is still persisted after the panel is closed
|
10
|
10
|
*/
|
11
|
11
|
|
12
|
|
-add_task(async function () {
|
13
|
|
- // Turn true the pref
|
14
|
|
- await pushPref("devtools.netmonitor.features.newEditAndResend", true);
|
15
|
|
- // Reset the storage for the persisted custom request
|
16
|
|
- await asyncStorage.removeItem("devtools.netmonitor.customRequest");
|
17
|
|
-
|
18
|
|
- const { monitor } = await initNetMonitor(HTTPS_CUSTOM_GET_URL, {
|
19
|
|
- requestCount: 1,
|
20
|
|
- });
|
21
|
|
- info("Starting test... ");
|
22
|
|
-
|
23
|
|
- const { document, store, windowRequire } = monitor.panelWin;
|
24
|
|
-
|
25
|
|
- // Action should be processed synchronously in tests.
|
26
|
|
- const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
27
|
|
- store.dispatch(Actions.batchEnable(false));
|
28
|
|
-
|
29
|
|
- info("open the left panel");
|
30
|
|
- let waitForPanels = waitForDOM(
|
|
12
|
+async function addCustomRequestTestContent(tab, monitor, document) {
|
|
13
|
+ info("Open the left panel");
|
|
14
|
+ const waitForPanels = waitForDOM(
|
31
|
15
|
document,
|
32
|
16
|
".monitor-panel .network-action-bar"
|
33
|
17
|
);
|
34
|
18
|
|
35
|
|
- let HTTPCustomRequestButton = document.querySelector(
|
|
19
|
+ const HTTPCustomRequestButton = document.querySelector(
|
36
|
20
|
"#netmonitor-toolbar-container .devtools-http-custom-request-icon"
|
37
|
21
|
);
|
38
|
22
|
HTTPCustomRequestButton.click();
|
... |
... |
@@ -59,91 +43,166 @@ add_task(async function () { |
59
|
43
|
"#http-custom-query .map-add-new-inputs .http-custom-input-name"
|
60
|
44
|
);
|
61
|
45
|
newParameterName.focus();
|
62
|
|
- EventUtils.sendString("My-param");
|
|
46
|
+ EventUtils.sendString("My-param", monitor.panelWin);
|
63
|
47
|
|
64
|
48
|
info("Adding new headers");
|
65
|
49
|
const newHeaderName = document.querySelector(
|
66
|
50
|
"#http-custom-headers .map-add-new-inputs .http-custom-input-name"
|
67
|
51
|
);
|
68
|
52
|
newHeaderName.focus();
|
69
|
|
- EventUtils.sendString("My-header");
|
|
53
|
+ EventUtils.sendString("My-header", monitor.panelWin);
|
70
|
54
|
|
71
|
55
|
const newHeaderValue = Array.from(
|
72
|
56
|
document.querySelectorAll(
|
73
|
57
|
"#http-custom-headers .http-custom-input .http-custom-input-value"
|
74
|
58
|
)
|
75
|
|
- ).pop();
|
|
59
|
+ ).at(-1);
|
76
|
60
|
newHeaderValue.focus();
|
77
|
|
- EventUtils.sendString("my-value");
|
|
61
|
+ EventUtils.sendString("my-value", monitor.panelWin);
|
78
|
62
|
|
79
|
63
|
const postValue = document.querySelector("#http-custom-postdata-value");
|
80
|
64
|
postValue.focus();
|
81
|
|
- EventUtils.sendString("{'Name': 'Value'}");
|
|
65
|
+ EventUtils.sendString("{'Name': 'Value'}", monitor.panelWin);
|
82
|
66
|
|
83
|
|
- // Close the panel
|
|
67
|
+ info("Close the panel");
|
84
|
68
|
const closePanel = document.querySelector(
|
85
|
69
|
".network-action-bar .tabs-navigation .sidebar-toggle"
|
86
|
70
|
);
|
87
|
71
|
closePanel.click();
|
|
72
|
+}
|
88
|
73
|
|
89
|
|
- // Open the panel again to see if the content is still there
|
90
|
|
- waitForPanels = waitUntil(
|
|
74
|
+async function runTests(tab, monitor, document, isPrivate = false) {
|
|
75
|
+ info("Open the panel again to see if the content is still there");
|
|
76
|
+ const waitForPanels = waitFor(
|
91
|
77
|
() =>
|
92
|
78
|
document.querySelector(".http-custom-request-panel") &&
|
93
|
79
|
document.querySelector("#http-custom-request-send-button").disabled ===
|
94
|
|
- false
|
|
80
|
+ isPrivate
|
95
|
81
|
);
|
96
|
82
|
|
97
|
|
- HTTPCustomRequestButton = document.querySelector(
|
|
83
|
+ const HTTPCustomRequestButton = document.querySelector(
|
98
|
84
|
"#netmonitor-toolbar-container .devtools-http-custom-request-icon"
|
99
|
85
|
);
|
100
|
86
|
HTTPCustomRequestButton.click();
|
101
|
87
|
await waitForPanels;
|
102
|
88
|
|
103
|
|
- is(
|
104
|
|
- methodValue.value,
|
105
|
|
- "POST",
|
106
|
|
- "The content should still be there after the user close the panel and re-opened"
|
107
|
|
- );
|
108
|
|
-
|
109
|
|
- is(
|
110
|
|
- url.value,
|
111
|
|
- "https://www.example.com?My-param=",
|
112
|
|
- "The url should still be there after the user close the panel and re-opened"
|
113
|
|
- );
|
|
89
|
+ // Wait a few seconds to make sure all the fields have been updated
|
|
90
|
+ await wait(1500);
|
|
91
|
+
|
|
92
|
+ const customMethod = document.querySelector("#http-custom-method-value");
|
|
93
|
+ const customUrl = document.querySelector(".http-custom-url-value");
|
|
94
|
+ const customQuery = document.querySelectorAll(
|
|
95
|
+ "#http-custom-query .tabpanel-summary-container.http-custom-input textarea"
|
|
96
|
+ );
|
|
97
|
+ const customHeaders = document.querySelectorAll(
|
|
98
|
+ "#http-custom-headers .tabpanel-summary-container.http-custom-input textarea"
|
|
99
|
+ );
|
|
100
|
+ const postDataValue = document.querySelector("#http-custom-postdata-value");
|
|
101
|
+
|
|
102
|
+ if (isPrivate) {
|
|
103
|
+ is(
|
|
104
|
+ customMethod.value,
|
|
105
|
+ "GET",
|
|
106
|
+ "The method should not be persisted after the user close the panel and re-opened in PBM"
|
|
107
|
+ );
|
|
108
|
+
|
|
109
|
+ is(
|
|
110
|
+ customUrl.value,
|
|
111
|
+ "",
|
|
112
|
+ "The url should not be there after the user close the panel and re-opened in PBM"
|
|
113
|
+ );
|
|
114
|
+
|
|
115
|
+ is(
|
|
116
|
+ customQuery.length,
|
|
117
|
+ 0,
|
|
118
|
+ "The Parameter should not be there after the user close the panel and re-opened in PBM"
|
|
119
|
+ );
|
|
120
|
+
|
|
121
|
+ is(
|
|
122
|
+ customHeaders.length,
|
|
123
|
+ 0,
|
|
124
|
+ "There should be no custom headers after the user close the panel and re-opened in PBM"
|
|
125
|
+ );
|
|
126
|
+
|
|
127
|
+ is(
|
|
128
|
+ postDataValue.value,
|
|
129
|
+ "",
|
|
130
|
+ "The post data should still be reset after the user close the panel and re-opened in PBM"
|
|
131
|
+ );
|
|
132
|
+ } else {
|
|
133
|
+ is(
|
|
134
|
+ customMethod.value,
|
|
135
|
+ "POST",
|
|
136
|
+ "The method should be persisted after the user close the panel and re-opened"
|
|
137
|
+ );
|
|
138
|
+
|
|
139
|
+ is(
|
|
140
|
+ customUrl.value,
|
|
141
|
+ "https://www.example.com?My-param=",
|
|
142
|
+ "The url should still be there after the user close the panel and re-opened"
|
|
143
|
+ );
|
|
144
|
+
|
|
145
|
+ const [nameParam] = Array.from(customQuery);
|
|
146
|
+ is(
|
|
147
|
+ nameParam.value,
|
|
148
|
+ "My-param",
|
|
149
|
+ "The Parameter name should still be there after the user close the panel and re-opened"
|
|
150
|
+ );
|
|
151
|
+
|
|
152
|
+ const [name, value] = Array.from(customHeaders);
|
|
153
|
+ is(
|
|
154
|
+ name.value,
|
|
155
|
+ "My-header",
|
|
156
|
+ "The header name should still be there after the user close the panel and re-opened"
|
|
157
|
+ );
|
|
158
|
+ is(
|
|
159
|
+ value.value,
|
|
160
|
+ "my-value",
|
|
161
|
+ "The header value should still be there after the user close the panel and re-opened"
|
|
162
|
+ );
|
|
163
|
+
|
|
164
|
+ is(
|
|
165
|
+ postDataValue.value,
|
|
166
|
+ "{'Name': 'Value'}",
|
|
167
|
+ "The content should still be there after the user close the panel and re-opened"
|
|
168
|
+ );
|
|
169
|
+ }
|
|
170
|
+}
|
|
171
|
+
|
|
172
|
+add_task(async function testRequestPanelPersistedContent() {
|
|
173
|
+ // Turn true the pref
|
|
174
|
+ await pushPref("devtools.netmonitor.features.newEditAndResend", true);
|
|
175
|
+ // Reset the storage for the persisted custom request
|
|
176
|
+ await asyncStorage.removeItem("devtools.netmonitor.customRequest");
|
114
|
177
|
|
115
|
|
- const [nameParam] = Array.from(
|
116
|
|
- document.querySelectorAll(
|
117
|
|
- "#http-custom-query .tabpanel-summary-container.http-custom-input textarea"
|
118
|
|
- )
|
119
|
|
- );
|
120
|
|
- is(
|
121
|
|
- nameParam.value,
|
122
|
|
- "My-param",
|
123
|
|
- "The Parameter name should still be there after the user close the panel and re-opened"
|
124
|
|
- );
|
|
178
|
+ const { tab, monitor } = await initNetMonitor(HTTPS_CUSTOM_GET_URL, {
|
|
179
|
+ requestCount: 1,
|
|
180
|
+ });
|
|
181
|
+ const { document, store, windowRequire } = monitor.panelWin;
|
|
182
|
+ const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
|
183
|
+ store.dispatch(Actions.batchEnable(false));
|
125
|
184
|
|
126
|
|
- const [name, value] = Array.from(
|
127
|
|
- document.querySelectorAll(
|
128
|
|
- "#http-custom-headers .tabpanel-summary-container.http-custom-input textarea"
|
129
|
|
- )
|
130
|
|
- );
|
131
|
|
- is(
|
132
|
|
- name.value,
|
133
|
|
- "My-header",
|
134
|
|
- "The header name should still be there after the user close the panel and re-opened"
|
135
|
|
- );
|
136
|
|
- is(
|
137
|
|
- value.value,
|
138
|
|
- "my-value",
|
139
|
|
- "The header value should still be there after the user close the panel and re-opened"
|
140
|
|
- );
|
|
185
|
+ info("Starting test... ");
|
|
186
|
+ info("Add initial custom request test content");
|
|
187
|
+ await addCustomRequestTestContent(tab, monitor, document);
|
|
188
|
+ await runTests(tab, monitor, document);
|
|
189
|
+ await teardown(monitor);
|
|
190
|
+});
|
141
|
191
|
|
142
|
|
- is(
|
143
|
|
- postValue.value,
|
144
|
|
- "{'Name': 'Value'}",
|
145
|
|
- "The content should still be there after the user close the panel and re-opened"
|
|
192
|
+add_task(async function testRequestPanelPersistedContentInPrivateWindow() {
|
|
193
|
+ await pushPref("devtools.netmonitor.features.newEditAndResend", true);
|
|
194
|
+ const { tab, monitor, privateWindow } = await initNetMonitor(
|
|
195
|
+ HTTPS_CUSTOM_GET_URL,
|
|
196
|
+ {
|
|
197
|
+ requestCount: 1,
|
|
198
|
+ openInPrivateWindow: true,
|
|
199
|
+ }
|
146
|
200
|
);
|
|
201
|
+ const { document, store, windowRequire } = monitor.panelWin;
|
|
202
|
+ const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
|
|
203
|
+ store.dispatch(Actions.batchEnable(false));
|
147
|
204
|
|
148
|
|
- await teardown(monitor);
|
|
205
|
+ info("Starting test in private window... ");
|
|
206
|
+ await runTests(tab, monitor, document, true);
|
|
207
|
+ await teardown(monitor, privateWindow);
|
149
|
208
|
}); |