Upstream version 6.35.121.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / curl-command.html
1 <html>
2 <head>
3 <script src="../http/tests/inspector/inspector-test.js"></script>
4 <script type="text/javascript">
5
6 var test = function()
7 {
8     var logView = WebInspector.inspectorView.panel("network")._networkLogView;
9
10     function newRequest(headers, data, opt_url)
11     {
12         var request = new WebInspector.NetworkRequest(0, opt_url || 'http://example.org/path', 0, 0, 0);
13         request.requestMethod = data ? "POST" : "GET";
14         var headerList = [];
15         if (headers) {
16             for (var i in headers)
17                 headerList.push({name: i, value: headers[i]});
18         }
19         if (data) {
20             headerList.push({name: "Content-Length", value: data.length});
21             request.requestFormData = data;
22         }
23         request.setRequestHeaders(headerList);
24         return request;
25     }
26
27     function dumpRequest(headers, data, opt_url)
28     {
29         InspectorTest.addResult(logView._generateCurlCommand(newRequest(headers, data, opt_url)));
30     }
31
32     dumpRequest({})
33     dumpRequest({}, "123");
34     dumpRequest({"Content-Type": "application/x-www-form-urlencoded"}, "1&b");
35     dumpRequest({"Content-Type": "application/json"}, "{\"a\":1}");
36     dumpRequest({"Content-Type": "application/binary"}, "1234\r\n\x30\x30\2\3\4\5\'\"!");  // expected content length: 15
37     dumpRequest({"Content-Type": "application/binary"}, "1234\r\n\1\x30\x30\2\3\4\5\'\"!");  // expected content length: 16
38     dumpRequest({"Content-Type": "application/binary"}, "\x7F\x80\x90\xFF\u0009\u0700");
39     dumpRequest({}, "", "http://labs.ft.com/?querystring=[]{}");  // Character range symbols must be escaped (http://crbug.com/265449).
40     dumpRequest({"Content-Type": "application/binary"}, "%PATH%$PATH");
41     dumpRequest({":host": "h", "version": "v"});
42
43     InspectorTest.completeTest();
44 }
45
46 </script>
47 </head>
48 <body onload="runTest()">
49 <p>Tests curl command generation</p>
50 </body>
51 </html>