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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 ASSERT_TRUE(page_action); | 366 ASSERT_TRUE(page_action); |
367 | 367 |
368 ASSERT_TRUE(ready.WaitUntilSatisfied()); | 368 ASSERT_TRUE(ready.WaitUntilSatisfied()); |
369 content::WebContents* const tab = | 369 content::WebContents* const tab = |
370 browser()->tab_strip_model()->GetWebContentsAt(0); | 370 browser()->tab_strip_model()->GetWebContentsAt(0); |
371 const int tab_id = ExtensionTabUtil::GetTabId(tab); | 371 const int tab_id = ExtensionTabUtil::GetTabId(tab); |
372 | 372 |
373 // This navigation matches both rules. | 373 // This navigation matches both rules. |
374 NavigateInRenderer(tab, GURL("http://test1/")); | 374 NavigateInRenderer(tab, GURL("http://test1/")); |
375 | 375 |
376 // Because the declarative rules were reusing action instance, addRules will | 376 EXPECT_TRUE(page_action->GetIsVisible(tab_id)); |
377 // fail and the page action won't be visible. | |
378 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); | |
379 } | 377 } |
380 | 378 |
381 // Tests that the rules are evaluated at the time they are added or removed. | 379 // Tests that the rules are evaluated at the time they are added or removed. |
382 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, RulesEvaluatedOnAddRemove) { | 380 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, RulesEvaluatedOnAddRemove) { |
383 ext_dir_.WriteManifest(kDeclarativeContentManifest); | 381 ext_dir_.WriteManifest(kDeclarativeContentManifest); |
384 ext_dir_.WriteFile(FILE_PATH_LITERAL("background.js"), kBackgroundHelpers); | 382 ext_dir_.WriteFile(FILE_PATH_LITERAL("background.js"), kBackgroundHelpers); |
385 const Extension* extension = LoadExtension(ext_dir_.unpacked_path()); | 383 const Extension* extension = LoadExtension(ext_dir_.unpacked_path()); |
386 ASSERT_TRUE(extension); | 384 ASSERT_TRUE(extension); |
387 const ExtensionAction* page_action = | 385 const ExtensionAction* page_action = |
388 ExtensionActionManager::Get(browser()->profile())-> | 386 ExtensionActionManager::Get(browser()->profile())-> |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 // action interfaces, add a test that checks that a navigation always evaluates | 983 // action interfaces, add a test that checks that a navigation always evaluates |
986 // consistent URL state for all conditions. i.e.: if condition1 evaluates to | 984 // consistent URL state for all conditions. i.e.: if condition1 evaluates to |
987 // false on url0 and true on url1, and condition2 evaluates to true on url0 and | 985 // false on url0 and true on url1, and condition2 evaluates to true on url0 and |
988 // false on url1, navigate from url0 to url1 and validate that no action is | 986 // false on url1, navigate from url0 to url1 and validate that no action is |
989 // triggered. Do the same when navigating back to url0. This kind of test is | 987 // triggered. Do the same when navigating back to url0. This kind of test is |
990 // unfortunately not feasible with the current implementation and the existing | 988 // unfortunately not feasible with the current implementation and the existing |
991 // supported conditions and actions. | 989 // supported conditions and actions. |
992 | 990 |
993 } // namespace | 991 } // namespace |
994 } // namespace extensions | 992 } // namespace extensions |
OLD | NEW |