Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3975)

Unified Diff: chrome/test/data/extensions/activity_log/options.js

Issue 11946028: Record event activity to the extension activity log. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rename ActivityLog::IsLoggingEnabled Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/extensions/activity_log/options.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « chrome/test/data/extensions/activity_log/options.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698