| 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 18 matching lines...) Expand all Loading... |
| 29 for (var i = 0; i < str.length; ++i) { | 29 for (var i = 0; i < str.length; ++i) { |
| 30 result[i] = str.charCodeAt(i); | 30 result[i] = str.charCodeAt(i); |
| 31 } | 31 } |
| 32 return result; | 32 return result; |
| 33 } | 33 } |
| 34 | 34 |
| 35 runTests([ | 35 runTests([ |
| 36 // Navigates to a page with subresources, with a blocking handler that | 36 // Navigates to a page with subresources, with a blocking handler that |
| 37 // cancels the page request. The page will not load, and we should not | 37 // cancels the page request. The page will not load, and we should not |
| 38 // see the subresources. | 38 // see the subresources. |
| 39 function complexLoadCancelled() { | |
| 40 expect( | |
| 41 [ // events | |
| 42 { label: "onBeforeRequest", | |
| 43 event: "onBeforeRequest", | |
| 44 details: { | |
| 45 type: "main_frame", | |
| 46 url: getURL("complexLoad/b.html"), | |
| 47 frameUrl: getURL("complexLoad/b.html") | |
| 48 }, | |
| 49 retval: {cancel: true} | |
| 50 }, | |
| 51 // Cancelling is considered an error. | |
| 52 { label: "onErrorOccurred", | |
| 53 event: "onErrorOccurred", | |
| 54 details: { | |
| 55 url: getURL("complexLoad/b.html"), | |
| 56 fromCache: false, | |
| 57 error: "net::ERR_BLOCKED_BY_CLIENT" | |
| 58 // Request to chrome-extension:// url has no IP. | |
| 59 } | |
| 60 }, | |
| 61 ], | |
| 62 [ // event order | |
| 63 ["onBeforeRequest", "onErrorOccurred"] | |
| 64 ], | |
| 65 {urls: ["<all_urls>"]}, // filter | |
| 66 ["blocking"]); | |
| 67 navigateAndWait(getURL("complexLoad/b.html")); | |
| 68 }, | |
| 69 | |
| 70 // Navigates to a page with subresources, with a blocking handler that | |
| 71 // cancels the page request. The page will not load, and we should not | |
| 72 // see the subresources. | |
| 73 function simpleLoadCancelledOnReceiveHeaders() { | 39 function simpleLoadCancelledOnReceiveHeaders() { |
| 74 expect( | 40 expect( |
| 75 [ // events | 41 [ // events |
| 76 { label: "onBeforeRequest", | 42 { label: "onBeforeRequest", |
| 77 event: "onBeforeRequest", | 43 event: "onBeforeRequest", |
| 78 details: { | 44 details: { |
| 79 method: "GET", | 45 method: "GET", |
| 80 type: "main_frame", | 46 type: "main_frame", |
| 81 url: getURLHttpSimpleLoad(), | 47 url: getURLHttpSimpleLoad(), |
| 82 frameUrl: getURLHttpSimpleLoad() | 48 frameUrl: getURLHttpSimpleLoad() |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 ], | 84 ], |
| 119 [ // event order | 85 [ // event order |
| 120 ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders", | 86 ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders", |
| 121 "onHeadersReceived", "onErrorOccurred"] | 87 "onHeadersReceived", "onErrorOccurred"] |
| 122 ], | 88 ], |
| 123 {urls: ["<all_urls>"]}, // filter | 89 {urls: ["<all_urls>"]}, // filter |
| 124 ["blocking"]); | 90 ["blocking"]); |
| 125 navigateAndWait(getURLHttpSimpleLoad()); | 91 navigateAndWait(getURLHttpSimpleLoad()); |
| 126 }, | 92 }, |
| 127 | 93 |
| 94 // Navigates to a page with subresources, with a blocking handler that |
| 95 // cancels the page request. The page will not load, and we should not |
| 96 // see the subresources. |
| 97 // TODO(nasko): This test was reordered in order to accommodate an |
| 98 // unrelated failure (https://crbug.com/700514). Once that failure is fixed, |
| 99 // the reordering should be reverted. |
| 100 function complexLoadCancelled() { |
| 101 expect( |
| 102 [ // events |
| 103 { label: "onBeforeRequest", |
| 104 event: "onBeforeRequest", |
| 105 details: { |
| 106 type: "main_frame", |
| 107 url: getURL("complexLoad/b.html"), |
| 108 frameUrl: getURL("complexLoad/b.html") |
| 109 }, |
| 110 retval: {cancel: true} |
| 111 }, |
| 112 // Cancelling is considered an error. |
| 113 { label: "onErrorOccurred", |
| 114 event: "onErrorOccurred", |
| 115 details: { |
| 116 url: getURL("complexLoad/b.html"), |
| 117 fromCache: false, |
| 118 error: "net::ERR_BLOCKED_BY_CLIENT" |
| 119 // Request to chrome-extension:// url has no IP. |
| 120 } |
| 121 }, |
| 122 ], |
| 123 [ // event order |
| 124 ["onBeforeRequest", "onErrorOccurred"] |
| 125 ], |
| 126 {urls: ["<all_urls>"]}, // filter |
| 127 ["blocking"]); |
| 128 navigateAndWait(getURL("complexLoad/b.html")); |
| 129 }, |
| 130 |
| 128 // Navigates to a page and provides invalid header information. The request | 131 // Navigates to a page and provides invalid header information. The request |
| 129 // should continue as if the headers were not changed. | 132 // should continue as if the headers were not changed. |
| 130 function simpleLoadIgnoreOnBeforeSendHeadersInvalidHeaders() { | 133 function simpleLoadIgnoreOnBeforeSendHeadersInvalidHeaders() { |
| 131 expect( | 134 expect( |
| 132 [ // events | 135 [ // events |
| 133 { label: "onBeforeRequest", | 136 { label: "onBeforeRequest", |
| 134 event: "onBeforeRequest", | 137 event: "onBeforeRequest", |
| 135 details: { | 138 details: { |
| 136 method: "GET", | 139 method: "GET", |
| 137 type: "main_frame", | 140 type: "main_frame", |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 [ // event order | 1137 [ // event order |
| 1135 ["onBeforeRequest-1", "onBeforeRedirect", "onBeforeRequest-2", | 1138 ["onBeforeRequest-1", "onBeforeRedirect", "onBeforeRequest-2", |
| 1136 "onBeforeSendHeaders", "onSendHeaders", "onHeadersReceived", | 1139 "onBeforeSendHeaders", "onSendHeaders", "onHeadersReceived", |
| 1137 "onResponseStarted", "onCompleted", | 1140 "onResponseStarted", "onCompleted", |
| 1138 "onBeforeRequest-3", "onErrorOccurred"], | 1141 "onBeforeRequest-3", "onErrorOccurred"], |
| 1139 ], | 1142 ], |
| 1140 {urls: ["<all_urls>"], types: ['image']}, // filter | 1143 {urls: ["<all_urls>"], types: ['image']}, // filter |
| 1141 ["blocking"]); | 1144 ["blocking"]); |
| 1142 navigateAndWait(frameUrl); | 1145 navigateAndWait(frameUrl); |
| 1143 } | 1146 } |
| OLD | NEW |