Index: chrome/test/data/extensions/activity_log/options.js |
diff --git a/chrome/test/data/extensions/activity_log/options.js b/chrome/test/data/extensions/activity_log/options.js |
index f47bc370100c2c9886c6a1ff56f23a9b5f0ff173..1d3ab81558746607fe0753ec7d1dca9de39b4a89 100644 |
--- a/chrome/test/data/extensions/activity_log/options.js |
+++ b/chrome/test/data/extensions/activity_log/options.js |
@@ -119,6 +119,41 @@ function doContentScriptXHR() { |
window.open('http://www.google.cn'); |
} |
+// Modifies the headers sent and received in an HTTP request using the |
+// webRequest API. |
+function doWebRequestModifications() { |
+ // Install a webRequest handler that will add an HTTP header to the outgoing |
+ // request for the main page. |
+ function doModifyHeaders(details) { |
+ var headers = details.requestHeaders; |
+ if (headers === undefined) { |
+ headers = []; |
+ } |
+ headers.push({'name': 'X-Test-Activity-Log-Send', |
+ 'value': 'Present'}); |
+ return {'requestHeaders': headers}; |
+ } |
+ chrome.webRequest.onBeforeSendHeaders.addListener( |
+ doModifyHeaders, |
+ {'urls': ['http://*/*'], 'types': ['main_frame']}, |
+ ['blocking', 'requestHeaders']); |
+ |
+ // Open a tab, then close it when it has finished loading--this should give |
+ // the webRequest handler a chance to run. |
+ chrome.tabs.onUpdated.addListener( |
+ function closeTab(tabId, changeInfo, tab) { |
+ if (changeInfo['status'] === "complete" && |
+ tab.url.match(/google\.co\.uk/g)) { |
+ chrome.webRequest.onBeforeSendHeaders.removeListener(doModifyHeaders); |
+ chrome.tabs.onUpdated.removeListener(closeTab); |
+ chrome.tabs.remove(tabId); |
+ setCompleted('doWebRequestModifications'); |
+ } |
+ } |
+ ); |
+ window.open('http://www.google.co.uk'); |
+} |
+ |
// REGISTER YOUR TESTS HERE |
// Attach the tests to buttons. |
function setupEvents() { |
@@ -128,6 +163,7 @@ function setupEvents() { |
$('inject_blob').addEventListener('click', injectScriptBlob); |
$('background_xhr').addEventListener('click', doBackgroundXHR); |
$('cs_xhr').addEventListener('click', doContentScriptXHR); |
+ $('webrequest').addEventListener('click', doWebRequestModifications); |
completed = 0; |
total = document.getElementsByTagName('button').length; |