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

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

Issue 8775046: Convert another batch of extension tests to manifest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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 | Annotate | Revision Log
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 // Constants as functions, not to be called until after runTests.
6 function getURLHttpSimpleLoad() {
7 return getServerURL('files/extensions/api_test/webrequest/simpleLoad/a.html');
8 }
9
10 function getURLHttpSimpleLoadRedirect() {
11 return getServerURL('server-redirect?'+getURLHttpSimpleLoad());
12 }
13
14 // A URL from b.com, which we don't have permission to access.
15 function getURLNotVisible() {
16 return getServerURL('files/extensions/api_test/webrequest/simpleLoad/b.html',
17 'b.com');
18 }
19
20 runTests([
21 // Navigates to a blank page.
22 function simpleLoad() {
23 expect(
24 [ // events
25 { label: "a-onBeforeRequest",
26 event: "onBeforeRequest",
27 details: {
28 url: getURL("simpleLoad/a.html"),
29 frameUrl: getURL("simpleLoad/a.html")
30 }
31 },
32 { label: "a-onResponseStarted",
33 event: "onResponseStarted",
34 details: {
35 url: getURL("simpleLoad/a.html"),
36 statusCode: 200,
37 fromCache: false,
38 statusLine: "HTTP/1.1 200 OK",
39 // Request to chrome-extension:// url has no IP.
40 }
41 },
42 { label: "a-onCompleted",
43 event: "onCompleted",
44 details: {
45 url: getURL("simpleLoad/a.html"),
46 statusCode: 200,
47 fromCache: false,
48 statusLine: "HTTP/1.1 200 OK",
49 // Request to chrome-extension:// url has no IP.
50 }
51 },
52 ],
53 [ // event order
54 ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted"] ]);
55 navigateAndWait(getURL("simpleLoad/a.html"));
56 },
57
58 // Navigates to a blank page via HTTP. Only HTTP requests get the
59 // onBeforeSendHeaders event.
60 function simpleLoadHttp() {
61 expect(
62 [ // events
63 { label: "onBeforeRequest-1",
64 event: "onBeforeRequest",
65 details: {
66 url: getURLHttpSimpleLoadRedirect(),
67 frameUrl: getURLHttpSimpleLoadRedirect()
68 }
69 },
70 { label: "onBeforeSendHeaders-1",
71 event: "onBeforeSendHeaders",
72 details: {
73 url: getURLHttpSimpleLoadRedirect(),
74 requestHeadersValid: true
75 }
76 },
77 { label: "onSendHeaders-1",
78 event: "onSendHeaders",
79 details: {
80 url: getURLHttpSimpleLoadRedirect(),
81 requestHeadersValid: true
82 }
83 },
84 { label: "onHeadersReceived-1",
85 event: "onHeadersReceived",
86 details: {
87 url: getURLHttpSimpleLoadRedirect(),
88 responseHeadersExist: true,
89 statusLine: "HTTP/1.0 301 Moved Permanently"
90 }
91 },
92 { label: "onBeforeRedirect",
93 event: "onBeforeRedirect",
94 details: {
95 url: getURLHttpSimpleLoadRedirect(),
96 redirectUrl: getURLHttpSimpleLoad(),
97 statusCode: 301,
98 responseHeadersExist: true,
99 ip: "127.0.0.1",
100 fromCache: false,
101 statusLine: "HTTP/1.0 301 Moved Permanently"
102 }
103 },
104 { label: "onBeforeRequest-2",
105 event: "onBeforeRequest",
106 details: {
107 url: getURLHttpSimpleLoad(),
108 frameUrl: getURLHttpSimpleLoad()
109 }
110 },
111 { label: "onBeforeSendHeaders-2",
112 event: "onBeforeSendHeaders",
113 details: {
114 url: getURLHttpSimpleLoad(),
115 requestHeadersValid: true
116 }
117 },
118 { label: "onSendHeaders-2",
119 event: "onSendHeaders",
120 details: {
121 url: getURLHttpSimpleLoad(),
122 requestHeadersValid: true
123 }
124 },
125 { label: "onHeadersReceived-2",
126 event: "onHeadersReceived",
127 details: {
128 url: getURLHttpSimpleLoad(),
129 responseHeadersExist: true,
130 statusLine: "HTTP/1.0 200 OK",
131 }
132 },
133 { label: "onResponseStarted",
134 event: "onResponseStarted",
135 details: {
136 url: getURLHttpSimpleLoad(),
137 statusCode: 200,
138 responseHeadersExist: true,
139 ip: "127.0.0.1",
140 fromCache: false,
141 statusLine: "HTTP/1.0 200 OK",
142 }
143 },
144 { label: "onCompleted",
145 event: "onCompleted",
146 details: {
147 url: getURLHttpSimpleLoad(),
148 statusCode: 200,
149 ip: "127.0.0.1",
150 fromCache: false,
151 responseHeadersExist: true,
152 statusLine: "HTTP/1.0 200 OK"
153 }
154 }
155 ],
156 [ // event order
157 ["onBeforeRequest-1", "onBeforeSendHeaders-1", "onSendHeaders-1",
158 "onHeadersReceived-1", "onBeforeRedirect",
159 "onBeforeRequest-2", "onBeforeSendHeaders-2", "onSendHeaders-2",
160 "onHeadersReceived-2", "onResponseStarted", "onCompleted"] ],
161 {}, // filter
162 ["requestHeaders", "responseHeaders"]);
163 navigateAndWait(getURLHttpSimpleLoadRedirect());
164 },
165
166 // Navigates to a non-existing page.
167 function nonExistingLoad() {
168 expect(
169 [ // events
170 { label: "onBeforeRequest",
171 event: "onBeforeRequest",
172 details: {
173 url: getURL("does_not_exist.html"),
174 frameUrl: getURL("does_not_exist.html")
175 }
176 },
177 { label: "onErrorOccurred",
178 event: "onErrorOccurred",
179 details: {
180 url: getURL("does_not_exist.html"),
181 fromCache: false,
182 error: "net::ERR_FILE_NOT_FOUND",
183 // Request to chrome-extension:// url has no IP.
184 }
185 },
186 ],
187 [ // event order
188 ["onBeforeRequest", "onErrorOccurred"] ]);
189 navigateAndWait(getURL("does_not_exist.html"));
190 },
191
192 // Navigates to a page that we don't have access to, then a blank page.
193 // We should not see the first navigation.
194 function simpleLoadNonVisible() {
195 expect(
196 [ // events
197 { label: "a-onBeforeRequest",
198 event: "onBeforeRequest",
199 details: {
200 url: getURL("simpleLoad/a.html"),
201 frameUrl: getURL("simpleLoad/a.html")
202 }
203 },
204 { label: "a-onResponseStarted",
205 event: "onResponseStarted",
206 details: {
207 url: getURL("simpleLoad/a.html"),
208 statusCode: 200,
209 fromCache: false,
210 statusLine: "HTTP/1.1 200 OK",
211 // Request to chrome-extension:// url has no IP.
212 }
213 },
214 { label: "a-onCompleted",
215 event: "onCompleted",
216 details: {
217 url: getURL("simpleLoad/a.html"),
218 statusCode: 200,
219 fromCache: false,
220 statusLine: "HTTP/1.1 200 OK",
221 // Request to chrome-extension:// url has no IP.
222 }
223 },
224 ],
225 [ // event order
226 ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted"] ]);
227 navigateAndWait(getURLNotVisible(), function() {
228 navigateAndWait(getURL("simpleLoad/a.html"));
229 });
230 },
231 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698