Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(672)

Side by Side Diff: chrome/test/data/extensions/api_test/webrequest/test_post.js

Issue 10694055: Add read-only access to POST data for webRequest's onBeforeRequest (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Corrected the multipart parser + parsedForm->formData Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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) {
battre 2012/08/16 19:18:03 nit: parseableForm should start with a lower case
vabr (Chromium) 2012/08/17 18:29:57 Done.
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 text1: ["TEST_TEXT_1"],
15 text2: ["TEST_TEXT_2"],
16 text3: ["TEST_TEXT_3"],
17 txtarea: ["Text"]
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: [ { byteLength: 127 } ]
battre 2012/08/16 19:18:03 why does this contain only the byteLength? I thoug
vabr (Chromium) 2012/08/17 18:29:57 I pass it as ArrayBuffer. I don't think its value
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));
battre 2012/08/16 19:18:03 this should be navigateAndWait(getURL(...), functi
vabr (Chromium) 2012/08/17 18:29:57 Done. Thanks, I did not know that!
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 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698