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

Unified Diff: chrome/test/data/extensions/api_test/active_tab/background.js

Issue 2871533002: [Test] Added a test for activeTab URL filtering (Closed)
Patch Set: Comments, nits, ScopedTestPublicSessionLoginState Created 3 years, 7 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/browser/extensions/active_tab_apitest.cc ('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/api_test/active_tab/background.js
diff --git a/chrome/test/data/extensions/api_test/active_tab/background.js b/chrome/test/data/extensions/api_test/active_tab/background.js
index 7ccd11832dac9ca9f863f5a5fff8fddaaabf4e20..e22016631f8bb590ec79905341334a33a23dded4 100644
--- a/chrome/test/data/extensions/api_test/active_tab/background.js
+++ b/chrome/test/data/extensions/api_test/active_tab/background.js
@@ -42,7 +42,27 @@ var injectIframe =
'iframe.src = "' + iframeUrl + '";\n' +
'document.body.appendChild(iframe);\n';
+var runCount = 0;
+
chrome.browserAction.onClicked.addListener(function(tab) {
+ runCount++;
+ if (runCount == 1) {
+ // First pass is done without granting activeTab permission, the extension
+ // shouldn't have access to tab.url here.
+ assertFalse(!!tab.url);
+ chrome.test.succeed();
+ return;
+ } else if (runCount == 3) {
+ // Third pass is done in a public session, and activeTab permission is
+ // granted to the extension. URL should be scrubbed down to the origin here
+ // (tested at the C++ side).
+ chrome.test.sendMessage(tab.url);
+ chrome.test.succeed();
+ return;
+ }
+ // Second pass is done with granting activeTab permission, the extension
+ // should have full access to the page (and also to tab.url).
+
iframeDone = chrome.test.callbackAdded();
cachedUrl = tab.url;
chrome.tabs.executeScript({ code: injectIframe }, callbackPass());
« no previous file with comments | « chrome/browser/extensions/active_tab_apitest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698