| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 ASSERT_TRUE(page_action); | 365 ASSERT_TRUE(page_action); |
| 366 | 366 |
| 367 ASSERT_TRUE(ready.WaitUntilSatisfied()); | 367 ASSERT_TRUE(ready.WaitUntilSatisfied()); |
| 368 content::WebContents* const tab = | 368 content::WebContents* const tab = |
| 369 browser()->tab_strip_model()->GetWebContentsAt(0); | 369 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 370 const int tab_id = ExtensionTabUtil::GetTabId(tab); | 370 const int tab_id = ExtensionTabUtil::GetTabId(tab); |
| 371 | 371 |
| 372 // This navigation matches both rules. | 372 // This navigation matches both rules. |
| 373 NavigateInRenderer(tab, GURL("http://test1/")); | 373 NavigateInRenderer(tab, GURL("http://test1/")); |
| 374 | 374 |
| 375 // Because the declarative rules were reusing action instance, addRules will | 375 EXPECT_TRUE(page_action->GetIsVisible(tab_id)); |
| 376 // fail and the page action won't be visible. | |
| 377 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); | |
| 378 } | 376 } |
| 379 | 377 |
| 380 // Tests that the rules are evaluated at the time they are added or removed. | 378 // Tests that the rules are evaluated at the time they are added or removed. |
| 381 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, RulesEvaluatedOnAddRemove) { | 379 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, RulesEvaluatedOnAddRemove) { |
| 382 ext_dir_.WriteManifest(kDeclarativeContentManifest); | 380 ext_dir_.WriteManifest(kDeclarativeContentManifest); |
| 383 ext_dir_.WriteFile(FILE_PATH_LITERAL("background.js"), kBackgroundHelpers); | 381 ext_dir_.WriteFile(FILE_PATH_LITERAL("background.js"), kBackgroundHelpers); |
| 384 const Extension* extension = LoadExtension(ext_dir_.unpacked_path()); | 382 const Extension* extension = LoadExtension(ext_dir_.unpacked_path()); |
| 385 ASSERT_TRUE(extension); | 383 ASSERT_TRUE(extension); |
| 386 const ExtensionAction* page_action = | 384 const ExtensionAction* page_action = |
| 387 ExtensionActionManager::Get(browser()->profile())-> | 385 ExtensionActionManager::Get(browser()->profile())-> |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 984 // action interfaces, add a test that checks that a navigation always evaluates | 982 // action interfaces, add a test that checks that a navigation always evaluates |
| 985 // consistent URL state for all conditions. i.e.: if condition1 evaluates to | 983 // consistent URL state for all conditions. i.e.: if condition1 evaluates to |
| 986 // false on url0 and true on url1, and condition2 evaluates to true on url0 and | 984 // false on url0 and true on url1, and condition2 evaluates to true on url0 and |
| 987 // false on url1, navigate from url0 to url1 and validate that no action is | 985 // false on url1, navigate from url0 to url1 and validate that no action is |
| 988 // triggered. Do the same when navigating back to url0. This kind of test is | 986 // triggered. Do the same when navigating back to url0. This kind of test is |
| 989 // unfortunately not feasible with the current implementation and the existing | 987 // unfortunately not feasible with the current implementation and the existing |
| 990 // supported conditions and actions. | 988 // supported conditions and actions. |
| 991 | 989 |
| 992 } // namespace | 990 } // namespace |
| 993 } // namespace extensions | 991 } // namespace extensions |
| OLD | NEW |