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

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: Adding an example value of formData to the docs Created 8 years, 5 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 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 // b-onBeforeRequest with postData included...
82 (includePostData) ? { label: "b-onBeforeRequest",
Matt Perry 2012/07/23 21:19:01 I think you could make this more succinct like so:
vabr (Chromium) 2012/07/30 16:05:57 I tried that but it did not work. Even if the expe
83 event: "onBeforeRequest",
84 details: {
85 method: "POST",
86 type: "main_frame",
87 url: getURL("postData/nonExistingTarget.html"),
88 frameUrl: getURL("postData/nonExistingTarget.html"),
89 experimentalPostData: {
90 formData: formData
91 }
92 }
93 // or else b-onBeforeRequest without postData.
94 } : { label: "b-onBeforeRequest",
95 event: "onBeforeRequest",
96 details: {
97 method: "POST",
98 type: "main_frame",
99 url: getURL("postData/nonExistingTarget.html"),
100 frameUrl: getURL("postData/nonExistingTarget.html"),
101 }
102 },
103 { label: "b-onErrorOccurred",
104 event: "onErrorOccurred",
105 details: {
106 error: "net::ERR_FILE_NOT_FOUND",
107 fromCache: false,
108 method: "POST",
109 type: "main_frame",
110 url: getURL("postData/nonExistingTarget.html")
111 }
112 }
113 ],
114 [ // event order
115 ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted",
116 "s-onBeforeRequest", "s-onResponseStarted", "s-onCompleted",
117 "b-onBeforeRequest", "b-onErrorOccurred"]
118 ],
119 {urls: ["<all_urls>"]}, // filter
120 ["requestPostData"]);
121 navigateAndWait(getURL("postData/" + formFile));
122 close();
123 }
124 }
125
126 runTests([
127 // Navigates to a page with a form and submits it.
128 postData('no-enctype.html', true),
129 postData('urlencoded.html', true),
130 postData('multipart.html', true),
131 postData('plaintext.html', false),
132 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698