summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/incognito_noscript_apitest.cc
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-23 03:28:51 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-23 03:28:51 +0000
commitc931db6d8adbf334c86e31714e2897bc2e9db08a (patch)
treecf83d11e8e00e45a4733ad62c1a38f0925d8dd8c /chrome/browser/extensions/incognito_noscript_apitest.cc
parentd146b8311c38186872d2be3764e2c2d66827107f (diff)
downloadchromium_src-c931db6d8adbf334c86e31714e2897bc2e9db08a.zip
chromium_src-c931db6d8adbf334c86e31714e2897bc2e9db08a.tar.gz
chromium_src-c931db6d8adbf334c86e31714e2897bc2e9db08a.tar.bz2
Don't inject content scripts into incognito browsers.
This patch prevents content scripts from being injected into incognito profile tabs by only injecting into the same profile in which the extension is running. BUG=21392 TEST=Load chrome/test/data/extensions/api/incognito_no_script and open any url in incognito browser. No page titles should be modified to "modified". Review URL: http://codereview.chromium.org/502079 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35203 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/incognito_noscript_apitest.cc')
-rwxr-xr-xchrome/browser/extensions/incognito_noscript_apitest.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/chrome/browser/extensions/incognito_noscript_apitest.cc b/chrome/browser/extensions/incognito_noscript_apitest.cc
new file mode 100755
index 0000000..69f3876
--- /dev/null
+++ b/chrome/browser/extensions/incognito_noscript_apitest.cc
@@ -0,0 +1,44 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/extensions/extension_browsertest.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/url_constants.h"
+#include "chrome/test/ui_test_utils.h"
+
+IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, IncognitoNoScript) {
+ host_resolver()->AddRule("*", "127.0.0.1");
+ StartHTTPServer();
+
+ // Loads a simple extension which attempts to change the title of every page
+ // that loads to "modified".
+ FilePath extension_path = test_data_dir_.AppendASCII("api_test")
+ .AppendASCII("incognito_no_script");
+ ASSERT_TRUE(LoadExtension(extension_path));
+
+ // Open incognito window and navigate to test page.
+ Browser::OpenURLOffTheRecord(browser()->profile(),
+ GURL("http://www.foo.com:1337/files/extensions/test_file.html"));
+ Profile* off_the_record_profile =
+ browser()->profile()->GetOffTheRecordProfile();
+ Browser* otr_browser = Browser::Create(off_the_record_profile);
+ otr_browser->AddTabWithURL(
+ GURL("http://www.foo.com:1337/files/extensions/test_file.html"),
+ GURL(),
+ PageTransition::LINK,
+ true,
+ -1,
+ false,
+ NULL);
+ otr_browser->window()->Show();
+ ui_test_utils::WaitForNavigationInCurrentTab(otr_browser);
+
+ string16 title;
+ ui_test_utils::GetCurrentTabTitle(otr_browser, &title);
+ ASSERT_EQ("Unmodified", UTF16ToASCII(title));
+}