Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var pass = chrome.test.callbackPass; | 5 var pass = chrome.test.callbackPass; |
| 6 | 6 |
| 7 // Constants as functions, not to be called until after runTests. | 7 // Constants as functions, not to be called until after runTests. |
| 8 function getURLEchoUserAgent() { | 8 function getURLEchoUserAgent() { |
| 9 return getServerURL('echoheader?User-Agent'); | 9 return getServerURL('echoheader?User-Agent'); |
| 10 } | 10 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders", | 119 ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders", |
| 120 "onHeadersReceived", "onErrorOccurred"] | 120 "onHeadersReceived", "onErrorOccurred"] |
| 121 ], | 121 ], |
| 122 {}, // filter | 122 {}, // filter |
| 123 ["blocking"]); | 123 ["blocking"]); |
| 124 navigateAndWait(getURLHttpSimpleLoad()); | 124 navigateAndWait(getURLHttpSimpleLoad()); |
| 125 }, | 125 }, |
| 126 | 126 |
| 127 // Navigates to a page with a blocking handler that redirects to a different | 127 // Navigates to a page with a blocking handler that redirects to a different |
| 128 // page. | 128 // page. |
| 129 // TODO(mpcomplete): We should see an onBeforeRedirect as well, but our | |
| 130 // process switching logic cancels the original redirect request and | |
| 131 // starts a new one instead. See http://crbug.com/79520. | |
|
Matt Perry
2011/12/03 00:30:22
Regarding new tests, come to think of it, this is
Charlie Reis
2011/12/03 01:39:56
This does help as a high-level regression test. I
| |
| 132 function complexLoadRedirected() { | 129 function complexLoadRedirected() { |
| 133 expect( | 130 expect( |
| 134 [ // events | 131 [ // events |
| 135 { label: "onBeforeRequest-1", | 132 { label: "onBeforeRequest-1", |
| 136 event: "onBeforeRequest", | 133 event: "onBeforeRequest", |
| 137 details: { | 134 details: { |
| 138 url: getURL("complexLoad/a.html"), | 135 url: getURL("complexLoad/a.html"), |
| 139 frameUrl: getURL("complexLoad/a.html") | 136 frameUrl: getURL("complexLoad/a.html") |
| 140 }, | 137 }, |
| 141 retval: {redirectUrl: getURL("simpleLoad/a.html")} | 138 retval: {redirectUrl: getURL("simpleLoad/a.html")} |
| 142 }, | 139 }, |
| 143 { label: "onErrorOccurred-1", | 140 { label: "onBeforeRedirect", |
| 144 event: "onErrorOccurred", | 141 event: "onBeforeRedirect", |
| 145 details: { | 142 details: { |
| 146 url: getURL("complexLoad/a.html"), | 143 url: getURL("complexLoad/a.html"), |
| 144 redirectUrl: getURL("simpleLoad/a.html"), | |
| 145 statusLine: "", | |
| 146 statusCode: -1, | |
| 147 fromCache: false, | 147 fromCache: false, |
| 148 error: "net::ERR_ABORTED" | 148 }, |
| 149 // Request to chrome-extension:// url has no IP. | |
| 150 } | |
| 151 }, | 149 }, |
| 152 { label: "onBeforeRequest-2", | 150 { label: "onBeforeRequest-2", |
| 153 event: "onBeforeRequest", | 151 event: "onBeforeRequest", |
| 154 details: { | 152 details: { |
| 155 url: getURL("simpleLoad/a.html"), | 153 url: getURL("simpleLoad/a.html"), |
| 156 frameUrl: getURL("simpleLoad/a.html"), | 154 frameUrl: getURL("simpleLoad/a.html"), |
| 157 }, | 155 }, |
| 158 }, | 156 }, |
| 159 { label: "onResponseStarted", | 157 { label: "onResponseStarted", |
| 160 event: "onResponseStarted", | 158 event: "onResponseStarted", |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 171 details: { | 169 details: { |
| 172 url: getURL("simpleLoad/a.html"), | 170 url: getURL("simpleLoad/a.html"), |
| 173 fromCache: false, | 171 fromCache: false, |
| 174 statusCode: 200, | 172 statusCode: 200, |
| 175 statusLine: "HTTP/1.1 200 OK", | 173 statusLine: "HTTP/1.1 200 OK", |
| 176 // Request to chrome-extension:// url has no IP. | 174 // Request to chrome-extension:// url has no IP. |
| 177 } | 175 } |
| 178 }, | 176 }, |
| 179 ], | 177 ], |
| 180 [ // event order | 178 [ // event order |
| 181 ["onBeforeRequest-1", "onErrorOccurred-1", "onBeforeRequest-2", | 179 ["onBeforeRequest-1", "onBeforeRedirect", "onBeforeRequest-2", |
| 182 "onResponseStarted", "onCompleted"], | 180 "onResponseStarted", "onCompleted"], |
| 183 ], | 181 ], |
| 184 {}, // filter | 182 {}, // filter |
| 185 ["blocking"]); | 183 ["blocking"]); |
| 186 navigateAndWait(getURL("complexLoad/a.html")); | 184 navigateAndWait(getURL("complexLoad/a.html")); |
| 187 }, | 185 }, |
| 188 | 186 |
| 189 // Loads a testserver page that echoes the User-Agent header that was | 187 // Loads a testserver page that echoes the User-Agent header that was |
| 190 // sent to fetch it. We modify the outgoing User-Agent in | 188 // sent to fetch it. We modify the outgoing User-Agent in |
| 191 // onBeforeSendHeaders, so we should see that modified version. | 189 // onBeforeSendHeaders, so we should see that modified version. |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 // Check the page content for our modified User-Agent string. | 623 // Check the page content for our modified User-Agent string. |
| 626 navigateAndWait(getURL("simpleLoad/a.html"), function() { | 624 navigateAndWait(getURL("simpleLoad/a.html"), function() { |
| 627 var req = new XMLHttpRequest(); | 625 var req = new XMLHttpRequest(); |
| 628 var asynchronous = false; | 626 var asynchronous = false; |
| 629 req.open("GET", getURLHttpXHRData(), asynchronous); | 627 req.open("GET", getURLHttpXHRData(), asynchronous); |
| 630 req.send(null); | 628 req.send(null); |
| 631 navigateAndWait(getURL("complexLoad/b.jpg")); | 629 navigateAndWait(getURL("complexLoad/b.jpg")); |
| 632 }); | 630 }); |
| 633 }, | 631 }, |
| 634 ]); | 632 ]); |
| OLD | NEW |