OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Attempt to block loading of references_remote_js on site different than |
| 6 // origin. The policy will prevent the block and the JS will load declaring |
| 7 // a success. |
| 8 chrome.webRequest.onBeforeRequest.addListener(function(details) { |
| 9 if(details.url.indexOf("ref_remote_js.js") != -1) { |
| 10 chrome.test.sendMessage("protected_origin"); |
| 11 } |
| 12 if(details.url.indexOf("protected_url.html") != -1) { |
| 13 chrome.test.sendMessage("protected_url"); |
| 14 } |
| 15 }, {urls: ["<all_urls>"]}, ["blocking"]); |
| 16 |
| 17 chrome.webRequest.onBeforeSendHeaders.addListener(function(details) { |
| 18 if(details.url.indexOf("direct_ip.html") != -1) { |
| 19 for(var i = 0; i < details.requestHeaders.length; i++) { |
| 20 if (details.requestHeaders[i]['name'] == 'Host'){ |
| 21 console.log("direct ip"); |
| 22 details.requestHeaders[i].value = 'efxample.com'; |
| 23 } |
| 24 } |
| 25 console.log('direct ip push'); |
| 26 details.requestHeaders.push({ |
| 27 name: 'Host', |
| 28 value: 'efxample.com' |
| 29 }); |
| 30 return {requestHeaders: details.requestHeaders}; |
| 31 } |
| 32 }, |
| 33 {urls: ["<all_urls>"]}, |
| 34 ["requestHeaders"]); |
OLD | NEW |