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

Unified Diff: chrome/browser/ui/tab_contents/per_tab_prefs_tab_helper_unittest.cc

Issue 8716004: Add per-tab "JavaScript enabled" preference. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments and fixed fwd declaration Created 9 years, 1 month 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/ui/tab_contents/per_tab_prefs_tab_helper_unittest.cc
diff --git a/chrome/browser/ui/tab_contents/per_tab_prefs_tab_helper_unittest.cc b/chrome/browser/ui/tab_contents/per_tab_prefs_tab_helper_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..36556860c321b51169620dae37ef6dc9089b1a6f
--- /dev/null
+++ b/chrome/browser/ui/tab_contents/per_tab_prefs_tab_helper_unittest.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2011 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/common/pref_names.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/ui/tab_contents/per_tab_prefs_tab_helper.h"
+#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
+#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h"
+#include "content/browser/tab_contents/test_tab_contents.h"
+#include "content/test/test_browser_thread.h"
+
+using content::BrowserThread;
+
+class PerTabPrefsTabHelperTest : public TabContentsWrapperTestHarness {
+ public:
+ PerTabPrefsTabHelperTest()
+ : TabContentsWrapperTestHarness(),
+ ui_thread_(BrowserThread::UI, &message_loop_) {}
+
+ virtual ~PerTabPrefsTabHelperTest() {}
+
+ TabContentsWrapper* contents_wrapper2() {
+ return contents_wrapper2_.get();
+ }
+
+ void SetContents2(TestTabContents* contents) {
+ contents_wrapper2_.reset(
+ contents ? new TabContentsWrapper(contents) : NULL);
+ }
+
+ protected:
+ virtual void SetUp() OVERRIDE {
+ TabContentsWrapperTestHarness::SetUp();
+ SetContents2(CreateTestTabContents());
+ }
+
+ virtual void TearDown() OVERRIDE {
+ contents_wrapper2_.reset();
+ TabContentsWrapperTestHarness::TearDown();
+ }
+
+ private:
+ content::TestBrowserThread ui_thread_;
+ scoped_ptr<TabContentsWrapper> contents_wrapper2_;
+
+ DISALLOW_COPY_AND_ASSIGN(PerTabPrefsTabHelperTest);
+};
+
+TEST_F(PerTabPrefsTabHelperTest, PerTabJavaScriptEnabled) {
+ const char* key = prefs::kWebKitJavascriptEnabled;
+ PrefService* prefs1 = contents_wrapper()->per_tab_prefs_tab_helper()->prefs();
+ PrefService* prefs2 =
+ contents_wrapper2()->per_tab_prefs_tab_helper()->prefs();
+ const bool initial_value = prefs1->GetBoolean(key);
+ EXPECT_EQ(initial_value, prefs2->GetBoolean(key));
+
+ prefs1->SetBoolean(key, !initial_value);
+ EXPECT_EQ(!initial_value, prefs1->GetBoolean(key));
+ EXPECT_EQ(initial_value, prefs2->GetBoolean(key));
+
+ prefs1->SetBoolean(key, initial_value);
+ EXPECT_EQ(initial_value, prefs1->GetBoolean(key));
+ EXPECT_EQ(initial_value, prefs2->GetBoolean(key));
+
+ prefs2->SetBoolean(key, !initial_value);
+ EXPECT_EQ(initial_value, prefs1->GetBoolean(key));
+ EXPECT_EQ(!initial_value, prefs2->GetBoolean(key));
+}
« no previous file with comments | « chrome/browser/ui/tab_contents/per_tab_prefs_tab_helper.cc ('k') | chrome/browser/ui/tab_contents/tab_contents_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698