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

Unified Diff: chrome/browser/extensions/active_script_controller_browsertest.cc

Issue 288053002: Block content scripts from executing until user grants permission (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
Index: chrome/browser/extensions/active_script_controller_browsertest.cc
diff --git a/chrome/browser/extensions/active_script_controller_browsertest.cc b/chrome/browser/extensions/active_script_controller_browsertest.cc
index 6234be632b03aae07a700e022288c18b34e73c83..ded056ec99fc611f79cd3a26fcb7844290301743 100644
--- a/chrome/browser/extensions/active_script_controller_browsertest.cc
+++ b/chrome/browser/extensions/active_script_controller_browsertest.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/ui_test_utils.h"
#include "extensions/common/feature_switch.h"
+#include "extensions/common/switches.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -61,10 +62,9 @@ enum RequiresConsent {
class ActiveScriptControllerBrowserTest : public ExtensionBrowserTest {
public:
- ActiveScriptControllerBrowserTest()
- : feature_override_(FeatureSwitch::scripts_require_action(),
- FeatureSwitch::OVERRIDE_ENABLED) {}
+ ActiveScriptControllerBrowserTest() {}
+ virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
virtual void CleanUpOnMainThread() OVERRIDE;
// Returns an extension with the given |host_type| and |injection_type|. If
@@ -75,11 +75,18 @@ class ActiveScriptControllerBrowserTest : public ExtensionBrowserTest {
InjectionType injection_type);
private:
- FeatureSwitch::ScopedOverride feature_override_;
ScopedVector<TestExtensionDir> test_extension_dirs_;
std::vector<const Extension*> extensions_;
};
+void ActiveScriptControllerBrowserTest::SetUpCommandLine(
+ base::CommandLine* command_line) {
+ // We append the actual switch to the commandline because it needs to be
+ // passed over to the renderer, which a FeatureSwitch::ScopedOverride will
+ // not do.
+ command_line->AppendSwitch(switches::kEnableScriptsRequireAction);
+}
+
void ActiveScriptControllerBrowserTest::CleanUpOnMainThread() {
test_extension_dirs_.clear();
}
@@ -266,10 +273,7 @@ testing::AssertionResult ActiveScriptTester::Verify() {
// Otherwise, we don't have permission, and have to grant it. Ensure the
// script has *not* already executed.
- // Currently, it's okay for content scripts to execute, because we don't
- // block them.
- // TODO(rdevlin.cronin): Fix this.
- if (inject_success_listener_->was_satisfied() && type_ != CONTENT_SCRIPT) {
+ if (inject_success_listener_->was_satisfied()) {
return testing::AssertionFailure() <<
name_ << "'s script ran without permission.";
}

Powered by Google App Engine
This is Rietveld 408576698