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

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: Comments addressed, unit tests split 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) 2011 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 postData = {
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",
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 postData: postData
90 }
91 // or else b-onBeforeRequest without postData.
92 } : { label: "b-onBeforeRequest",
93 event: "onBeforeRequest",
94 details: {
95 method: "POST",
96 type: "main_frame",
97 url: getURL("postData/nonExistingTarget.html"),
98 frameUrl: getURL("postData/nonExistingTarget.html"),
99 }
100 },
101 { label: "b-onErrorOccurred",
102 event: "onErrorOccurred",
103 details: {
104 error: "net::ERR_FILE_NOT_FOUND",
105 fromCache: false,
106 method: "POST",
107 type: "main_frame",
108 url: getURL("postData/nonExistingTarget.html")
109 }
110 }
111 ],
112 [ // event order
113 ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted",
114 "s-onBeforeRequest", "s-onResponseStarted", "s-onCompleted",
115 "b-onBeforeRequest", "b-onErrorOccurred"]
116 ],
117 {urls: ["<all_urls>"]}, // filter
118 ["requestPostData"]);
119 navigateAndWait(getURL("postData/" + formFile));
120 close();
121 }
122 }
123
124 runTests([
125 // Navigates to a page with a form and submits it.
126 postData('no-enctype.html', true),
127 postData('urlencoded.html', true),
128 postData('multipart.html', true),
129 postData('plaintext.html', false),
130 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698