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.
5 // Constants as functions, not to be called until after runTests.
6 function getURLHttpSimpleLoad() {
7 return getServerURL('extensions/api_test/webrequest/simpleLoad/a.html');
10 function getURLHttpSimpleLoadRedirect() {
11 return getServerURL('server-redirect?'+getURLHttpSimpleLoad());
15 // Navigates to a blank page.
16 function simpleLoad() {
19 { label
: "a-onBeforeRequest",
20 event
: "onBeforeRequest",
22 url
: getURL("simpleLoad/a.html"),
23 frameUrl
: getURL("simpleLoad/a.html")
26 { label
: "a-onResponseStarted",
27 event
: "onResponseStarted",
29 url
: getURL("simpleLoad/a.html"),
32 statusLine
: "HTTP/1.1 200 OK",
33 // Request to chrome-extension:// url has no IP.
36 { label
: "a-onCompleted",
39 url
: getURL("simpleLoad/a.html"),
42 statusLine
: "HTTP/1.1 200 OK",
43 // Request to chrome-extension:// url has no IP.
48 ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted"] ]);
49 navigateAndWait(getURL("simpleLoad/a.html"));
52 // Navigates to a blank page via HTTP. Only HTTP requests get the
53 // onBeforeSendHeaders event.
54 function simpleLoadHttp() {
57 { label
: "onBeforeRequest-1",
58 event
: "onBeforeRequest",
60 url
: getURLHttpSimpleLoadRedirect(),
61 frameUrl
: getURLHttpSimpleLoadRedirect()
64 { label
: "onBeforeSendHeaders-1",
65 event
: "onBeforeSendHeaders",
67 url
: getURLHttpSimpleLoadRedirect(),
68 requestHeadersValid
: true
71 { label
: "onSendHeaders-1",
72 event
: "onSendHeaders",
74 url
: getURLHttpSimpleLoadRedirect(),
75 requestHeadersValid
: true
78 { label
: "onHeadersReceived-1",
79 event
: "onHeadersReceived",
81 url
: getURLHttpSimpleLoadRedirect(),
82 responseHeadersExist
: true,
83 statusLine
: "HTTP/1.1 301 Moved Permanently",
87 { label
: "onBeforeRedirect",
88 event
: "onBeforeRedirect",
90 url
: getURLHttpSimpleLoadRedirect(),
91 redirectUrl
: getURLHttpSimpleLoad(),
93 responseHeadersExist
: true,
96 statusLine
: "HTTP/1.1 301 Moved Permanently"
99 { label
: "onBeforeRequest-2",
100 event
: "onBeforeRequest",
102 url
: getURLHttpSimpleLoad(),
103 frameUrl
: getURLHttpSimpleLoad()
106 { label
: "onBeforeSendHeaders-2",
107 event
: "onBeforeSendHeaders",
109 url
: getURLHttpSimpleLoad(),
110 requestHeadersValid
: true
113 { label
: "onSendHeaders-2",
114 event
: "onSendHeaders",
116 url
: getURLHttpSimpleLoad(),
117 requestHeadersValid
: true
120 { label
: "onHeadersReceived-2",
121 event
: "onHeadersReceived",
123 url
: getURLHttpSimpleLoad(),
124 responseHeadersExist
: true,
125 statusLine
: "HTTP/1.1 200 OK",
129 { label
: "onResponseStarted",
130 event
: "onResponseStarted",
132 url
: getURLHttpSimpleLoad(),
134 responseHeadersExist
: true,
137 statusLine
: "HTTP/1.1 200 OK",
140 { label
: "onCompleted",
141 event
: "onCompleted",
143 url
: getURLHttpSimpleLoad(),
147 responseHeadersExist
: true,
148 statusLine
: "HTTP/1.1 200 OK"
153 ["onBeforeRequest-1", "onBeforeSendHeaders-1", "onSendHeaders-1",
154 "onHeadersReceived-1", "onBeforeRedirect",
155 "onBeforeRequest-2", "onBeforeSendHeaders-2", "onSendHeaders-2",
156 "onHeadersReceived-2", "onResponseStarted", "onCompleted"] ],
157 {urls
: ["<all_urls>"]}, // filter
158 ["requestHeaders", "responseHeaders"]);
159 navigateAndWait(getURLHttpSimpleLoadRedirect());
162 // Navigates to a non-existing page.
163 function nonExistingLoad() {
166 { label
: "onBeforeRequest",
167 event
: "onBeforeRequest",
169 url
: getURL("does_not_exist.html"),
170 frameUrl
: getURL("does_not_exist.html")
173 { label
: "onErrorOccurred",
174 event
: "onErrorOccurred",
176 url
: getURL("does_not_exist.html"),
178 error
: "net::ERR_FILE_NOT_FOUND",
179 // Request to chrome-extension:// url has no IP.
184 ["onBeforeRequest", "onErrorOccurred"] ]);
185 navigateAndWait(getURL("does_not_exist.html"));