summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/user_script_master_unittest.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/user_script_master_unittest.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/user_script_master_unittest.cc')
-rw-r--r--chrome/browser/extensions/user_script_master_unittest.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/chrome/browser/extensions/user_script_master_unittest.cc b/chrome/browser/extensions/user_script_master_unittest.cc
index 6c01939..562f4cf 100644
--- a/chrome/browser/extensions/user_script_master_unittest.cc
+++ b/chrome/browser/extensions/user_script_master_unittest.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/chrome_thread.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_service.h"
+#include "chrome/test/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
// Test bringing up a master on a specific directory, putting a script
@@ -80,7 +81,9 @@ class UserScriptMasterTest : public testing::Test,
// Test that we get notified even when there are no scripts.
TEST_F(UserScriptMasterTest, NoScripts) {
- scoped_refptr<UserScriptMaster> master(new UserScriptMaster(script_dir_));
+ TestingProfile profile;
+ scoped_refptr<UserScriptMaster> master(new UserScriptMaster(script_dir_,
+ &profile));
master->StartScan();
message_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask);
message_loop_.Run();
@@ -92,7 +95,9 @@ TEST_F(UserScriptMasterTest, NoScripts) {
#if defined(OS_WIN) || defined(OS_MACOSX)
// Test that we get notified about new scripts after they're added.
TEST_F(UserScriptMasterTest, NewScripts) {
- scoped_refptr<UserScriptMaster> master(new UserScriptMaster(script_dir_));
+ TestingProfile profile;
+ scoped_refptr<UserScriptMaster> master(new UserScriptMaster(script_dir_,
+ &profile));
FilePath path = script_dir_.AppendASCII("script.user.js");
@@ -112,13 +117,15 @@ TEST_F(UserScriptMasterTest, NewScripts) {
// Test that we get notified about scripts if they're already in the test dir.
TEST_F(UserScriptMasterTest, ExistingScripts) {
+ TestingProfile profile;
FilePath path = script_dir_.AppendASCII("script.user.js");
const char content[] = "some content";
size_t written = file_util::WriteFile(path, content, sizeof(content));
ASSERT_EQ(written, sizeof(content));
- scoped_refptr<UserScriptMaster> master(new UserScriptMaster(script_dir_));
+ scoped_refptr<UserScriptMaster> master(new UserScriptMaster(script_dir_,
+ &profile));
master->StartScan();
message_loop_.PostTask(FROM_HERE, new MessageLoop::QuitTask);