| 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. | |
| 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" | |
| 149 // Request to chrome-extension:// url has no IP. | |
| 150 } | 148 } |
| 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", |
| (...skipping 11 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 } | 450 } |
| 453 }, | 451 }, |
| 454 { label: "onHeadersReceived", | 452 { label: "onHeadersReceived", |
| 455 event: "onHeadersReceived", | 453 event: "onHeadersReceived", |
| 456 details: { | 454 details: { |
| 457 url: getURLNonUTF8SetCookie(), | 455 url: getURLNonUTF8SetCookie(), |
| 458 statusLine: "HTTP/1.0 200 OK", | 456 statusLine: "HTTP/1.0 200 OK", |
| 459 responseHeadersExist: true, | 457 responseHeadersExist: true, |
| 460 }, | 458 }, |
| 461 retval_function: function(name, details) { | 459 retval_function: function(name, details) { |
| 462 console.log(JSON.stringify(details)); | |
| 463 responseHeaders = details.responseHeaders; | 460 responseHeaders = details.responseHeaders; |
| 464 var found = false; | 461 var found = false; |
| 465 var expectedValue = [ | 462 var expectedValue = [ |
| 466 "F".charCodeAt(0), | 463 "F".charCodeAt(0), |
| 467 "o".charCodeAt(0), | 464 "o".charCodeAt(0), |
| 468 "o".charCodeAt(0), | 465 "o".charCodeAt(0), |
| 469 0x3D, 0xFE, 0xD1 | 466 0x3D, 0xFE, 0xD1 |
| 470 ]; | 467 ]; |
| 471 | 468 |
| 472 for (var i = 0; i < responseHeaders.length; ++i) { | 469 for (var i = 0; i < responseHeaders.length; ++i) { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 // Check the page content for our modified User-Agent string. | 622 // Check the page content for our modified User-Agent string. |
| 626 navigateAndWait(getURL("simpleLoad/a.html"), function() { | 623 navigateAndWait(getURL("simpleLoad/a.html"), function() { |
| 627 var req = new XMLHttpRequest(); | 624 var req = new XMLHttpRequest(); |
| 628 var asynchronous = false; | 625 var asynchronous = false; |
| 629 req.open("GET", getURLHttpXHRData(), asynchronous); | 626 req.open("GET", getURLHttpXHRData(), asynchronous); |
| 630 req.send(null); | 627 req.send(null); |
| 631 navigateAndWait(getURL("complexLoad/b.jpg")); | 628 navigateAndWait(getURL("complexLoad/b.jpg")); |
| 632 }); | 629 }); |
| 633 }, | 630 }, |
| 634 ]); | 631 ]); |
| OLD | NEW |