Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 var dirName = "requestBody/"; | |
| 6 | |
| 7 function sendPost(formFile, parseableForm) { | |
| 8 // The following variables must be updated when files in |dirName| change. | |
| 9 var formData = { | |
| 10 "check": ["option_A"], | |
| 11 "password": ["password"], | |
| 12 "radio": ["Yes"], | |
| 13 "select": ["one"], | |
| 14 "text\"1\u011B\u0161\u00FD\u4EBA\r\n \r\n": ["TEST_TEXT_1"], | |
|
vabr (Chromium)
2012/09/03 09:55:30
Added control and non-ASCII characters to test aga
| |
| 15 "text2": ["TEST_TEXT_2"], | |
| 16 "text3": ["TEST_TEXT_3"], | |
| 17 "txtarea": ["text\"1\u011B\u0161\u00FD\u4EBA\r\n \r\n"] | |
| 18 }; | |
| 19 return function submitForm() { | |
| 20 expect( | |
| 21 [ // events | |
| 22 { label: "a-onBeforeRequest", | |
| 23 event: "onBeforeRequest", | |
| 24 details: { | |
| 25 method: "GET", | |
| 26 type: "main_frame", | |
| 27 url: getURL(dirName + formFile), | |
| 28 frameUrl: getURL(dirName + formFile) | |
| 29 } | |
| 30 }, | |
| 31 { label: "a-onResponseStarted", | |
| 32 event: "onResponseStarted", | |
| 33 details: { | |
| 34 fromCache: false, | |
| 35 method: "GET", | |
| 36 statusCode: 200, | |
| 37 statusLine: "HTTP/1.1 200 OK", | |
| 38 type: "main_frame", | |
| 39 url: getURL(dirName + formFile) | |
| 40 } | |
| 41 }, | |
| 42 { label: "a-onCompleted", | |
| 43 event: "onCompleted", | |
| 44 details: { | |
| 45 fromCache: false, | |
| 46 method: "GET", | |
| 47 statusCode: 200, | |
| 48 statusLine: "HTTP/1.1 200 OK", | |
| 49 type: "main_frame", | |
| 50 url: getURL(dirName + formFile) | |
| 51 } | |
| 52 }, | |
| 53 { label: "s-onBeforeRequest", | |
| 54 event: "onBeforeRequest", | |
| 55 details: { | |
| 56 method: "GET", | |
| 57 type: "script", | |
| 58 url: getURL("requestBody/submit.js"), | |
| 59 frameUrl: getURL(dirName + formFile) | |
| 60 } | |
| 61 }, | |
| 62 { label: "s-onResponseStarted", | |
| 63 event: "onResponseStarted", | |
| 64 details: { | |
| 65 fromCache: false, | |
| 66 method: "GET", | |
| 67 statusCode: 200, | |
| 68 statusLine: "HTTP/1.1 200 OK", | |
| 69 type: "script", | |
| 70 url: getURL("requestBody/submit.js") | |
| 71 } | |
| 72 }, | |
| 73 { label: "s-onCompleted", | |
| 74 event: "onCompleted", | |
| 75 details: { | |
| 76 fromCache: false, | |
| 77 method: "GET", | |
| 78 statusCode: 200, | |
| 79 statusLine: "HTTP/1.1 200 OK", | |
| 80 type: "script", | |
| 81 url: getURL("requestBody/submit.js") | |
| 82 } | |
| 83 }, | |
| 84 { label: "b-onBeforeRequest", | |
| 85 event: "onBeforeRequest", | |
| 86 details: { | |
| 87 method: "POST", | |
| 88 type: "main_frame", | |
| 89 url: getURL("requestBody/nonExistingTarget.html"), | |
| 90 frameUrl: getURL("requestBody/nonExistingTarget.html"), | |
| 91 requestBody: parseableForm ? { | |
| 92 formData: formData | |
| 93 } : { | |
| 94 raw: [{bytes: {byteLength: 158}}] | |
| 95 } | |
| 96 } | |
| 97 }, | |
| 98 { label: "b-onErrorOccurred", | |
| 99 event: "onErrorOccurred", | |
| 100 details: { | |
| 101 error: "net::ERR_FILE_NOT_FOUND", | |
| 102 fromCache: false, | |
| 103 method: "POST", | |
| 104 type: "main_frame", | |
| 105 url: getURL("requestBody/nonExistingTarget.html") | |
| 106 } | |
| 107 } | |
| 108 ], | |
| 109 [ // event order | |
| 110 ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted", | |
| 111 "s-onBeforeRequest", "s-onResponseStarted", "s-onCompleted", | |
| 112 "b-onBeforeRequest", "b-onErrorOccurred"] | |
| 113 ], | |
| 114 {urls: ["<all_urls>"]}, // filter | |
| 115 ["requestBody"]); | |
| 116 navigateAndWait(getURL(dirName + formFile), function() {close();}); | |
| 117 close(); | |
| 118 } | |
| 119 } | |
| 120 | |
| 121 runTests([ | |
| 122 // Navigates to a page with a form and submits it, generating a POST request. | |
| 123 // First two result in url-encoded form. | |
| 124 sendPost('no-enctype.html', true), | |
| 125 sendPost('urlencoded.html', true), | |
| 126 // Third results in multipart-encoded form. | |
| 127 sendPost('multipart.html', true), | |
| 128 // Fourth results in unparseable form, and thus raw data string. | |
| 129 sendPost('plaintext.html', false), | |
| 130 ]); | |
| OLD | NEW |