| OLD | NEW |
| 1 <script src="framework.js"> | 1 <script src="framework.js"> |
| 2 </script> | 2 </script> |
| 3 <script> | 3 <script> |
| 4 // Constants as functions, not to be called until after runTests. | 4 // Constants as functions, not to be called until after runTests. |
| 5 function getURLEchoUserAgent() { | 5 function getURLEchoUserAgent() { |
| 6 return getServerURL('echoheader?User-Agent'); | 6 return getServerURL('echoheader?User-Agent'); |
| 7 } | 7 } |
| 8 | 8 |
| 9 runTests([ | 9 runTests([ |
| 10 // Navigates to a page with subresources, with a blocking handler that | 10 // Navigates to a page with subresources, with a blocking handler that |
| 11 // cancels the page request. The page will not load, and we should not | 11 // cancels the page request. The page will not load, and we should not |
| 12 // see the subresources. | 12 // see the subresources. |
| 13 function complexLoadCancelled() { | 13 function complexLoadCancelled() { |
| 14 expect( | 14 expect( |
| 15 [ // events | 15 [ // events |
| 16 { label: "onBeforeRequest", | 16 { label: "onBeforeRequest", |
| 17 event: "onBeforeRequest", | 17 event: "onBeforeRequest", |
| 18 details: { | 18 details: { |
| 19 method: "GET", | 19 method: "GET", |
| 20 tabId: tabId, | 20 tabId: tabId, |
| 21 type: "main_frame", | 21 type: "main_frame", |
| 22 url: getURL("complexLoad/a.html"), | 22 url: getURL("complexLoad/b.html"), |
| 23 frameUrl: getURL("complexLoad/a.html") | 23 frameUrl: getURL("complexLoad/b.html") |
| 24 }, | 24 }, |
| 25 retval: {cancel: true} | 25 retval: {cancel: true} |
| 26 }, | 26 }, |
| 27 // Cancelling is considered an error. | 27 // Cancelling is considered an error. |
| 28 { label: "onErrorOccurred", | 28 { label: "onErrorOccurred", |
| 29 event: "onErrorOccurred", | 29 event: "onErrorOccurred", |
| 30 details: { | 30 details: { |
| 31 url: getURL("complexLoad/a.html"), | 31 url: getURL("complexLoad/b.html"), |
| 32 fromCache: false, | 32 fromCache: false, |
| 33 error: "net::ERR_EMPTY_RESPONSE" | 33 error: "net::ERR_EMPTY_RESPONSE" |
| 34 // Request to chrome-extension:// url has no IP. | 34 // Request to chrome-extension:// url has no IP. |
| 35 } | 35 } |
| 36 }, | 36 }, |
| 37 ], | 37 ], |
| 38 [ // event order | 38 [ // event order |
| 39 ["onBeforeRequest", "onErrorOccurred"] | 39 ["onBeforeRequest", "onErrorOccurred"] |
| 40 ], | 40 ], |
| 41 {}, // filter | 41 {}, // filter |
| 42 ["blocking"]); | 42 ["blocking"]); |
| 43 console.log("load canc: navigating to a"); | 43 console.log("load canc: navigating to b"); |
| 44 navigateAndWait(getURL("complexLoad/a.html")); | 44 navigateAndWait(getURL("complexLoad/b.html")); |
| 45 }, | 45 }, |
| 46 | 46 |
| 47 // Navigates to a page with a blocking handler that redirects to a different | 47 // Navigates to a page with a blocking handler that redirects to a different |
| 48 // page. | 48 // page. |
| 49 // TODO(mpcomplete): We should see an onBeforeRedirect as well, but our | 49 // TODO(mpcomplete): We should see an onBeforeRedirect as well, but our |
| 50 // process switching logic cancels the original redirect request and | 50 // process switching logic cancels the original redirect request and |
| 51 // starts a new one instead. See http://crbug.com/79520. | 51 // starts a new one instead. See http://crbug.com/79520. |
| 52 function complexLoadRedirected() { | 52 function complexLoadRedirected() { |
| 53 expect( | 53 expect( |
| 54 [ // events | 54 [ // events |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 console.log("mod headers: 3"); | 176 console.log("mod headers: 3"); |
| 177 chrome.tabs.executeScript(tabId, | 177 chrome.tabs.executeScript(tabId, |
| 178 { | 178 { |
| 179 code: "chrome.extension.sendRequest(" + | 179 code: "chrome.extension.sendRequest(" + |
| 180 "{pass: document.body.innerText.indexOf('FoobarUA') >= 0});" | 180 "{pass: document.body.innerText.indexOf('FoobarUA') >= 0});" |
| 181 }); | 181 }); |
| 182 }); | 182 }); |
| 183 }, | 183 }, |
| 184 ]); | 184 ]); |
| 185 </script> | 185 </script> |
| OLD | NEW |