| 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/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 8 #include "chrome/browser/extensions/extension_action.h" | 8 #include "chrome/browser/extensions/extension_action.h" |
| 9 #include "chrome/browser/extensions/extension_action_manager.h" | 9 #include "chrome/browser/extensions/extension_action_manager.h" |
| 10 #include "chrome/browser/extensions/extension_action_test_util.h" | 10 #include "chrome/browser/extensions/extension_action_test_util.h" |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 ASSERT_TRUE(extension); | 478 ASSERT_TRUE(extension); |
| 479 ASSERT_TRUE(ready.WaitUntilSatisfied()); | 479 ASSERT_TRUE(ready.WaitUntilSatisfied()); |
| 480 | 480 |
| 481 CreateIncognitoBrowser(); | 481 CreateIncognitoBrowser(); |
| 482 ASSERT_TRUE(ready_split.WaitUntilSatisfied()); | 482 ASSERT_TRUE(ready_split.WaitUntilSatisfied()); |
| 483 } | 483 } |
| 484 | 484 |
| 485 // Reloads the extension from PRE_RulesPersistence and checks that the rules | 485 // Reloads the extension from PRE_RulesPersistence and checks that the rules |
| 486 // continue to work as expected after being persisted and reloaded. | 486 // continue to work as expected after being persisted and reloaded. |
| 487 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, RulesPersistence) { | 487 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, RulesPersistence) { |
| 488 ExtensionTestMessageListener ready("second run ready", false); |
| 489 ExtensionTestMessageListener ready_split("second run ready (split)", false); |
| 490 ASSERT_TRUE(ready.WaitUntilSatisfied()); |
| 491 |
| 488 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); | 492 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); |
| 489 const base::FilePath path = test_data_dir_. | |
| 490 AppendASCII("declarative_content").AppendASCII("persistence"); | |
| 491 const Extension* extension = | 493 const Extension* extension = |
| 492 GetExtensionByPath(registry->enabled_extensions(), path); | 494 GetExtensionByPath(registry->enabled_extensions(), |
| 493 | 495 test_data_dir_.AppendASCII("declarative_content") |
| 494 if (!extension) { | 496 .AppendASCII("persistence")); |
| 495 ExtensionTestMessageListener ready("second run ready", false); | |
| 496 ASSERT_TRUE(ready.WaitUntilSatisfied()); | |
| 497 extension = GetExtensionByPath(registry->enabled_extensions(), path); | |
| 498 } | |
| 499 | 497 |
| 500 // Check non-incognito browser. | 498 // Check non-incognito browser. |
| 501 content::WebContents* const tab = | 499 content::WebContents* const tab = |
| 502 browser()->tab_strip_model()->GetWebContentsAt(0); | 500 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 503 const int tab_id = ExtensionTabUtil::GetTabId(tab); | 501 const int tab_id = ExtensionTabUtil::GetTabId(tab); |
| 504 | 502 |
| 505 const ExtensionAction* page_action = | 503 const ExtensionAction* page_action = |
| 506 ExtensionActionManager::Get(browser()->profile())-> | 504 ExtensionActionManager::Get(browser()->profile())-> |
| 507 GetPageAction(*extension); | 505 GetPageAction(*extension); |
| 508 ASSERT_TRUE(page_action); | 506 ASSERT_TRUE(page_action); |
| 509 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); | 507 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); |
| 510 | 508 |
| 511 NavigateInRenderer(tab, GURL("http://test_normal/")); | 509 NavigateInRenderer(tab, GURL("http://test_normal/")); |
| 512 EXPECT_TRUE(page_action->GetIsVisible(tab_id)); | 510 EXPECT_TRUE(page_action->GetIsVisible(tab_id)); |
| 513 | 511 |
| 514 NavigateInRenderer(tab, GURL("http://test_split/")); | 512 NavigateInRenderer(tab, GURL("http://test_split/")); |
| 515 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); | 513 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); |
| 516 | 514 |
| 517 // Check incognito browser. | 515 // Check incognito browser. |
| 518 ExtensionTestMessageListener ready_split("second run ready (split)", false); | |
| 519 Browser* incognito_browser = CreateIncognitoBrowser(); | 516 Browser* incognito_browser = CreateIncognitoBrowser(); |
| 520 ASSERT_TRUE(ready_split.WaitUntilSatisfied()); | 517 ASSERT_TRUE(ready_split.WaitUntilSatisfied()); |
| 521 content::WebContents* const incognito_tab = | 518 content::WebContents* const incognito_tab = |
| 522 incognito_browser->tab_strip_model()->GetWebContentsAt(0); | 519 incognito_browser->tab_strip_model()->GetWebContentsAt(0); |
| 523 const int incognito_tab_id = ExtensionTabUtil::GetTabId(incognito_tab); | 520 const int incognito_tab_id = ExtensionTabUtil::GetTabId(incognito_tab); |
| 524 | 521 |
| 525 const ExtensionAction* incognito_page_action = | 522 const ExtensionAction* incognito_page_action = |
| 526 ExtensionActionManager::Get(incognito_browser->profile())-> | 523 ExtensionActionManager::Get(incognito_browser->profile())-> |
| 527 GetPageAction(*extension); | 524 GetPageAction(*extension); |
| 528 ASSERT_TRUE(incognito_page_action); | 525 ASSERT_TRUE(incognito_page_action); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 // consistent URL state for all conditions. i.e.: if condition1 evaluates to | 805 // consistent URL state for all conditions. i.e.: if condition1 evaluates to |
| 809 // false on url0 and true on url1, and condition2 evaluates to true on url0 and | 806 // false on url0 and true on url1, and condition2 evaluates to true on url0 and |
| 810 // false on url1, navigate from url0 to url1 and validate that no action is | 807 // false on url1, navigate from url0 to url1 and validate that no action is |
| 811 // triggered. Do the same when navigating back to url0. This kind of test is | 808 // triggered. Do the same when navigating back to url0. This kind of test is |
| 812 // unfortunately not feasible with the current implementation and the existing | 809 // unfortunately not feasible with the current implementation and the existing |
| 813 // supported conditions and actions. | 810 // supported conditions and actions. |
| 814 | 811 |
| 815 } // namespace | 812 } // namespace |
| 816 } // namespace extensions | 813 } // namespace extensions |
| 817 | 814 |
| OLD | NEW |