Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/webrequest/test_post.js |
| diff --git a/chrome/test/data/extensions/api_test/webrequest/test_post.js b/chrome/test/data/extensions/api_test/webrequest/test_post.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d121e3b8533c28d31a17edab3f1514089bce2ed1 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/webrequest/test_post.js |
| @@ -0,0 +1,157 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +function postData(formFile, includePostData) { |
| + var postData = { |
| + chck: ["option_A"], |
| + pw: ["pw"], |
| + radio: ["Yes"], |
| + select: ["one"], |
| + text1: ["TEST_TEXT_1"], |
| + text2: ["TEST_TEXT_2"], |
| + text3: ["TEST_TEXT_3"], |
| + txtarea: ["Text"] |
| + }; |
| + return function submitForm() { |
| + expect( |
| + [ // events |
| + { label: "a-onBeforeRequest", |
| + event: "onBeforeRequest", |
| + details: { |
| + //frameId: 0, |
|
battre
2012/07/11 12:28:43
nit: space after // (also below)
vabr (Chromium)
2012/07/12 15:13:11
Actually, those comments were there by mistake. Re
|
| + method: "GET", |
| + //parentFrameId: -1, |
| + //tabId: 0, |
| + type: "main_frame", |
| + url: getURL("postData/" + formFile), |
| + frameUrl: getURL("postData/" + formFile) |
| + } |
| + }, |
| + { label: "a-onResponseStarted", |
| + event: "onResponseStarted", |
| + details: { |
| + //frameId: 0, |
| + fromCache: false, |
| + method: "GET", |
| + //parentFrameId: -1, |
| + statusCode: 200, |
| + statusLine: "HTTP/1.1 200 OK", |
| + //tabId: 0, |
| + type: "main_frame", |
| + url: getURL("postData/" + formFile) |
| + } |
| + }, |
| + { label: "a-onCompleted", |
| + event: "onCompleted", |
| + details: { |
| + //frameId: 0, |
| + fromCache: false, |
| + method: "GET", |
| + //parentFrameId: -1, |
| + statusCode: 200, |
| + statusLine: "HTTP/1.1 200 OK", |
| + //tabId: 0, |
| + type: "main_frame", |
| + url: getURL("postData/" + formFile) |
| + } |
| + }, |
| + { label: "s-onBeforeRequest", |
| + event: "onBeforeRequest", |
| + details: { |
| + //frameId: 0, |
| + method: "GET", |
| + //parentFrameId: -1, |
| + //tabId: 0, |
| + type: "script", |
| + url: getURL("postData/submit.js"), |
| + frameUrl: getURL("postData/" + formFile) |
| + } |
| + }, |
| + { label: "s-onResponseStarted", |
| + event: "onResponseStarted", |
| + details: { |
| + //frameId: 0, |
| + fromCache: false, |
| + method: "GET", |
| + //parentFrameId: -1, |
| + statusCode: 200, |
| + statusLine: "HTTP/1.1 200 OK", |
| + //tabId: 0, |
| + type: "script", |
| + url: getURL("postData/submit.js") |
| + } |
| + }, |
| + { label: "s-onCompleted", |
| + event: "onCompleted", |
| + details: { |
| + //frameId: 0, |
| + fromCache: false, |
| + method: "GET", |
| + //parentFrameId: -1, |
| + statusCode: 200, |
| + statusLine: "HTTP/1.1 200 OK", |
| + //tabId: 0, |
| + type: "script", |
| + url: getURL("postData/submit.js") |
| + } |
| + }, |
| + // b-onBeforeRequest with postData included... |
| + (includePostData) ? { label: "b-onBeforeRequest", |
| + event: "onBeforeRequest", |
| + details: { |
| + //frameId: 0, |
| + method: "POST", |
| + //parentFrameId: -1, |
| + //tabId: 0, |
| + type: "main_frame", |
| + url: getURL("postData/nonExistingTarget.html"), |
| + frameUrl: getURL("postData/nonExistingTarget.html"), |
| + postData: postData |
| + } |
| + // or else b-onBeforeRequest without postData. |
| + } : { label: "b-onBeforeRequest", |
| + event: "onBeforeRequest", |
| + details: { |
| + //frameId: 0, |
| + method: "POST", |
| + //parentFrameId: -1, |
| + //tabId: 0, |
| + type: "main_frame", |
| + url: getURL("postData/nonExistingTarget.html"), |
| + frameUrl: getURL("postData/nonExistingTarget.html"), |
| + } |
| + }, |
| + { label: "b-onErrorOccurred", |
| + event: "onErrorOccurred", |
| + details: { |
| + error: "net::ERR_FILE_NOT_FOUND", |
| + //frameId: 0, |
| + fromCache: false, |
| + method: "POST", |
| + //parentFrameId: -1, |
| + //tabId: 0, |
| + type: "main_frame", |
| + url: getURL("postData/nonExistingTarget.html") |
| + } |
| + } |
| + ], |
| + [ // event order |
| + ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted", |
| + "s-onBeforeRequest", "s-onResponseStarted", "s-onCompleted", |
| + "b-onBeforeRequest", "b-onErrorOccurred"] |
| + ], |
| + {urls: ["<all_urls>"]}, // filter |
| + ["requestPostData"]); |
| + navigateAndWait(getURL("postData/" + formFile)); |
| + close(); |
| + } |
| +} |
| + |
| +runTests([ |
| + // Navigates to a page with a form and submits it. |
| + postData('no-enctype.html', true), |
| + postData('urlencoded.html', true), |
| + postData('multipart.html', true), |
| + postData('plaintext.html', false), |
| +]); |