summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/manual-tests/inspector/display-form-data.html
blob: 48cd817e2c6c76326642b8e22856ffab097ef4ca (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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<html>
<head>
<title>Tests for Bug 22920</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
</head>

<body>
<p>Tests for 
<ul>    
<li><p><a href="https://bugs.webkit.org/show_bug.cgi?id=22920">Bug 22920: Inspector Request Headers Should Show Data/Variables/Parameters Sent With Request</a>
<li><p><a href="https://bugs.webkit.org/show_bug.cgi?id=28970">Bug 28970: content-type parameters not taken into account when building form-data</a>
</ul>

<p>To test, open the Inspector on this page, go to the Resources panel,
and select the various resources created by this page in the left column of the
Resources panel.  Note that for test-4 ...
test-11, the -sync and -async versions should show the same Form Data,
Request Payload and/or Query String Parameter values.

<ul>

<li><p><b>test-1</b>:
<br>no Form Data, Request Payload or Query String Parameters

<li><p><b>test-2</b>:
<br>Query String Parameters (1): "parm1: abc"

<li><p><b>test-3</b>:
<br>Query String Parameters (2): "parm1: def" and "parm2: g h i";
Hovering over either parm should yield a tooltip:
<i>"Double-Click to toggle between URL encoded and decoded formats"</i>.
Double-clicking on either parm should toggle between encoded and decoded
versions of the string.  The decoded form is initially displayed.
The encoded form of parm2 is "g%20h+i".

<li><p><b>test-4</b>:
<br>no Form Data, Request Payload or Query String Parameters

<li><p><b>test-5</b>:
<br>Query String Parameters (1): "parm1: abc"

<li><p><b>test-6</b>:
<br>Query String Parameters (3): "parm1: def" and "parm2: g h i" and "parm3: jj kk ll"

<li><p><b>test-7</b>:
<br>Request Payload: 3 lines of text data with a very long 2nd line which should wrap

<li><p><b>test-8</b>:
<br>Request Payload: 3 lines of text data with a very long 2nd line which should wrap

<li><p><b>test-9</b>:
<br>Request Payload: 3 lines of text data with a very long 2nd line of binary data which should wrap

<li><p><b>test-10</b>:
<br>Form Data (1): "parm1: abc"

<li><p><b>test-11</b>:
<br>Form Data (2): "parm1: def" and "parm2: g h i"

<li><p><b>test-12</b>:
<br>Query String Parameters (2): "parm1: abc" and "parm2: d e f"
<br>Form Data (2): "parm1: ghi" and "parm2: j k l"

<li><p><b>test-13</b>:
<br>Query String Parameters (2): "parm1: &auml;bc" and "parm2: d &#x11B; f"
<br>Form Data (2): "parm1: ghi" and "parm2: j k l"
<p>Note that you should view the encoded values of the query string parameters
by double-clicking on one of the parameters.  The values should be:
<pre>
parm1: %C3%A4bc
parm2: d%20%C4%9B+f
</pre>

<li><p><b>test-14</b>:
<br>Same results as for test-13, a slightly different but compatible Content-Type
is used for the form data.

<li><p><b>test-15</b>:
<br>Query String Parameters (2): "parm1: % (unable to decode value)" and "parm2: % (unable to decode value)",
with the parenthesized part in red.
<br>Form Data (2): "parm1: % (unable to decode value)" and "parm2: % (unable to decode value)",
with the parenthesized part in red.
<p>Note that you should view the encoded values of the query string parameters
by double-clicking on one of the parameters.  The values for all four parameters should be "%".

<li><p><b>test-form</b>:
<br>For this test, invoke the form at the bottom of the page
by pressing the submit button.  The Resources panel should have a "test-form"
resource, with the following data:
<p>Form Data (2): "field1: value &auml;;b;c" and "field2:value d;&#x11B;;f"
<p>Note that you should view the encoded values of the query string parameters
by double-clicking on one of the parameters.  The values should be:
<pre>
field1: value+%C3%A4%3Bb%3Bc
field2: value+d%3B%C4%9B%3Bf</pre>
</ul>

<p><b>test-form</b>
<form id="form" action="http://example.org/test-form" method="post" enctype="application/x-www-form-urlencoded">
<span style="font-size:200%">field1:</span> <input style="font-size:200%" type="text" name="field1" value="value &auml;;b;c"><br>
<span style="font-size:200%">field2:</span> <input style="font-size:200%" type="text" name="field2" value="value d;&#x11B;;f"><br>
<input type="submit">
</form>

<div style="display:none">

<img src="http://example.org/test-1">
<img src="http://example.org/test-2?parm1=abc">
<img src="http://example.org/test-3?parm1=def&amp;parm2=g%20h+i">

</div>

<hr>

<p><b>NLS sample info</b>

<pre>
<span style="font-size:300%">&auml;</span> - LATIN SMALL LETTER A WITH DIAERESIS
Unicode: 0x00E4 == 228    
UTF8:    C3 A4 
HTML:    &amp;auml;

<span style="font-size:300%">&#x11B;</span> - LATIN SMALL LETTER E WITH CARON
Unicode: 0x011B == 283    
UTF8:    C4 9B
HTML:    &amp;#x11B;
</pre>
    
<script>

function getReadyState(num) {
    switch(num) {
        case 0: return "uninitialized";
        case 1: return "loading";
        case 2: return "loaded";
        case 3: return "interactive";
        case 4: return "complete";
        default: return "unknown: " + num;
    }
}

function getProcessXHR(request) {
    return function() {
        if (true) return;
        var rs = getReadyState(request.readyState);
        console.log("ready state change for " + request.url);
        console.log("   ready state:   " + rs);
        console.log("   response text: " + request.responseText);
        if (request.readyState == 4) {
            console.log("   status:        " + request.status);
            console.log("   status text:   " + request.statusText);
        }
    }
}

function sendXHR(url, method, headers, body) {
    if (!method) method = "GET";
    if (!headers) headers = [];
    if (!body) body="";

    // copy headers
    var headersNew = [];
    for (var i=0; i<headers.length; i++) {
        headersNew.push(headers[i]);
    }
    headers = headersNew;

    if (body != "") {
        headers.push(["Content-Length", body.length.toString()]);
    }

    // sync
    var req = new XMLHttpRequest();

    req.url = url.replace("^","-sync");
    req.onreadystatechange = getProcessXHR(req);
    req.open(method, req.url, false);

    for (var i=0; i<headers.length; i++) {
        req.setRequestHeader(headers[i][0], headers[i][1]);
    }

    req.send(body);

    // async
    var req = new XMLHttpRequest();

    req.url = url.replace("^","-async");
    req.onreadystatechange = getProcessXHR(req);
    req.open(method, req.url, true);

    for (var i=0; i<headers.length; i++) {
        req.setRequestHeader(headers[i][0], headers[i][1]);
    }

    req.send(body);
}

var headersPlain = [
    ["Content-Type", "text/plain"]
];

var headersForm = [
    ["Content-Type", "application/x-www-form-urlencoded"]
];

var headersFormExtra1 = [
    ["Content-Type", "application/x-www-form-urlencoded;something-else=here"]
];

var headersFormExtra2 = [
    ["Content-Type", "application/x-www-form-urlencoded ; something-else=here"]
];

var headersBinary = [
    ["Content-Type", "application/octet-stream"]
];

var longText = "some text with a \n";
for (var i=0; i<40; i++) {
    longText += "very-";
}
longText += "long\nline in it";

var binaryData = "some text with binary data\n";
for (var i=0; i<256; i++) {
    binaryData += String.fromCharCode(i);
}
binaryData += "\nin the middle of it";


sendXHR("http://example.org/test-4^");
sendXHR("http://example.org/test-5^?parm1=abc");
sendXHR("http://example.org/test-6^?parm1=def&parm2=g%20h+i&parm3=jj++kk%20%20ll");

sendXHR("http://example.org/test-7^", "POST", null, longText);
sendXHR("http://example.org/test-8^", "POST", headersPlain, longText);
sendXHR("http://example.org/test-9^", "POST", headersBinary, binaryData);
sendXHR("http://example.org/test-10^", "POST", headersForm, "parm1=abc");
sendXHR("http://example.org/test-11^", "POST", headersForm, "parm1=def&parm2=g%20h+i");
sendXHR("http://example.org/test-12^?parm1=abc&parm2=d%20e+f", "POST", headersForm, "parm1=ghi&parm2=j%20k+l");
sendXHR("http://example.org/test-13^?parm1=%C3%A4bc&parm2=d%20%C4%9B+f", "POST", headersFormExtra1, "parm1=ghi&parm2=j%20k+l");
sendXHR("http://example.org/test-14^?parm1=%C3%A4bc&parm2=d%20%C4%9B+f", "POST", headersFormExtra2, "parm1=ghi&parm2=j%20k+l");
sendXHR("http://example.org/test-15^?parm1=%&parm2=%", "POST", headersForm, "parm1=%&parm2=%");

</script>

</body>
</html>