| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 onRequest = chrome.experimental.webRequest.onRequest; | 5 var onRequest = chrome.experimental.webRequest.onRequest; |
| 6 var RequestMatcher = chrome.experimental.webRequest.RequestMatcher; | 6 var RequestMatcher = chrome.experimental.webRequest.RequestMatcher; |
| 7 var CancelRequest = chrome.experimental.webRequest.CancelRequest; | 7 var CancelRequest = chrome.experimental.webRequest.CancelRequest; |
| 8 var RedirectRequest = chrome.experimental.webRequest.RedirectRequest; | 8 var RedirectRequest = chrome.experimental.webRequest.RedirectRequest; |
| 9 | 9 |
| 10 runTests([ | 10 runTests([ |
| 11 function testCancelRequest() { | 11 function testCancelRequest() { |
| 12 ignoreUnexpected = true; | 12 ignoreUnexpected = true; |
| 13 expect( | 13 expect( |
| 14 [ | 14 [ |
| 15 { label: "onErrorOccurred", | 15 { label: "onErrorOccurred", |
| 16 event: "onErrorOccurred", | 16 event: "onErrorOccurred", |
| 17 details: { | 17 details: { |
| 18 url: getURL("simpleLoad/a.html"), | 18 url: getURL("simpleLoad/a.html"), |
| 19 fromCache: false, | 19 fromCache: false, |
| 20 error: "net::ERR_BLOCKED_BY_CLIENT" | 20 error: "net::ERR_BLOCKED_BY_CLIENT" |
| 21 } | 21 } |
| 22 }, | 22 }, |
| 23 ], | 23 ], |
| 24 [ ["onCompleted"] ]); | 24 [ ["onCompleted"] ]); |
| 25 | 25 |
| 26 onRequest.addRules( | 26 onRequest.addRules( |
| 27 [ {'conditions': [new RequestMatcher({'path_suffix': ".html"})], | 27 [ {'conditions': [ |
| 28 new RequestMatcher({'path_suffix': ".html", |
| 29 'resourceType': ["main_frame"], |
| 30 'schemes': ["chrome-extension"]})], |
| 28 'actions': [new CancelRequest()]} | 31 'actions': [new CancelRequest()]} |
| 29 ], | 32 ], |
| 30 function() {navigateAndWait(getURL("simpleLoad/a.html"));} | 33 function() {navigateAndWait(getURL("simpleLoad/a.html"));} |
| 31 ); | 34 ); |
| 32 }, | 35 }, |
| 33 | 36 |
| 34 function testRedirectRequest() { | 37 function testRedirectRequest() { |
| 35 ignoreUnexpected = true; | 38 ignoreUnexpected = true; |
| 36 expect( | 39 expect( |
| 37 [ | 40 [ |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 "onCompleted"] ]); | 78 "onCompleted"] ]); |
| 76 | 79 |
| 77 onRequest.addRules( | 80 onRequest.addRules( |
| 78 [ {'conditions': [new RequestMatcher({'path_suffix': ".html"})], | 81 [ {'conditions': [new RequestMatcher({'path_suffix': ".html"})], |
| 79 'actions': [ | 82 'actions': [ |
| 80 new RedirectRequest({'redirectUrl': getURL("simpleLoad/a.html")})]} | 83 new RedirectRequest({'redirectUrl': getURL("simpleLoad/a.html")})]} |
| 81 ], | 84 ], |
| 82 function() {navigateAndWait(getURL("complexLoad/a.html"));} | 85 function() {navigateAndWait(getURL("complexLoad/a.html"));} |
| 83 ); | 86 ); |
| 84 }, | 87 }, |
| 85 ]); | 88 ]); |
| OLD | NEW |