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 function postData(formFile, includePostData) { |
| 6 var formData = { |
| 7 check: ["option_A"], |
| 8 password: ["password"], |
| 9 radio: ["Yes"], |
| 10 select: ["one"], |
| 11 text1: ["TEST_TEXT_1"], |
| 12 text2: ["TEST_TEXT_2"], |
| 13 text3: ["TEST_TEXT_3"], |
| 14 txtarea: ["Text"] |
| 15 }; |
| 16 return function submitForm() { |
| 17 expect( |
| 18 [ // events |
| 19 { label: "a-onBeforeRequest", |
| 20 event: "onBeforeRequest", |
| 21 details: { |
| 22 method: "GET", |
| 23 type: "main_frame", |
| 24 url: getURL("postData/" + formFile), |
| 25 frameUrl: getURL("postData/" + formFile) |
| 26 } |
| 27 }, |
| 28 { label: "a-onResponseStarted", |
| 29 event: "onResponseStarted", |
| 30 details: { |
| 31 fromCache: false, |
| 32 method: "GET", |
| 33 statusCode: 200, |
| 34 statusLine: "HTTP/1.1 200 OK", |
| 35 type: "main_frame", |
| 36 url: getURL("postData/" + formFile) |
| 37 } |
| 38 }, |
| 39 { label: "a-onCompleted", |
| 40 event: "onCompleted", |
| 41 details: { |
| 42 fromCache: false, |
| 43 method: "GET", |
| 44 statusCode: 200, |
| 45 statusLine: "HTTP/1.1 200 OK", |
| 46 type: "main_frame", |
| 47 url: getURL("postData/" + formFile) |
| 48 } |
| 49 }, |
| 50 { label: "s-onBeforeRequest", |
| 51 event: "onBeforeRequest", |
| 52 details: { |
| 53 method: "GET", |
| 54 type: "script", |
| 55 url: getURL("postData/submit.js"), |
| 56 frameUrl: getURL("postData/" + formFile) |
| 57 } |
| 58 }, |
| 59 { label: "s-onResponseStarted", |
| 60 event: "onResponseStarted", |
| 61 details: { |
| 62 fromCache: false, |
| 63 method: "GET", |
| 64 statusCode: 200, |
| 65 statusLine: "HTTP/1.1 200 OK", |
| 66 type: "script", |
| 67 url: getURL("postData/submit.js") |
| 68 } |
| 69 }, |
| 70 { label: "s-onCompleted", |
| 71 event: "onCompleted", |
| 72 details: { |
| 73 fromCache: false, |
| 74 method: "GET", |
| 75 statusCode: 200, |
| 76 statusLine: "HTTP/1.1 200 OK", |
| 77 type: "script", |
| 78 url: getURL("postData/submit.js") |
| 79 } |
| 80 }, |
| 81 { label: "b-onBeforeRequest", |
| 82 event: "onBeforeRequest", |
| 83 details: { |
| 84 method: "POST", |
| 85 type: "main_frame", |
| 86 url: getURL("postData/nonExistingTarget.html"), |
| 87 frameUrl: getURL("postData/nonExistingTarget.html"), |
| 88 postData: includePostData ? { |
| 89 formData: formData |
| 90 } : {} |
| 91 } |
| 92 }, |
| 93 { label: "b-onErrorOccurred", |
| 94 event: "onErrorOccurred", |
| 95 details: { |
| 96 error: "net::ERR_FILE_NOT_FOUND", |
| 97 fromCache: false, |
| 98 method: "POST", |
| 99 type: "main_frame", |
| 100 url: getURL("postData/nonExistingTarget.html") |
| 101 } |
| 102 } |
| 103 ], |
| 104 [ // event order |
| 105 ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted", |
| 106 "s-onBeforeRequest", "s-onResponseStarted", "s-onCompleted", |
| 107 "b-onBeforeRequest", "b-onErrorOccurred"] |
| 108 ], |
| 109 {urls: ["<all_urls>"]}, // filter |
| 110 ["postData"]); |
| 111 navigateAndWait(getURL("postData/" + formFile)); |
| 112 close(); |
| 113 } |
| 114 } |
| 115 |
| 116 runTests([ |
| 117 // Navigates to a page with a form and submits it. |
| 118 postData('no-enctype.html', true), |
| 119 postData('urlencoded.html', true), |
| 120 postData('multipart.html', true), |
| 121 postData('plaintext.html', false), |
| 122 ]); |
OLD | NEW |