| 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 "chrome/browser/extensions/extension_action_manager.h" | 5 #include "chrome/browser/extensions/extension_action_manager.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/extensions/extension_tab_util.h" | 7 #include "chrome/browser/extensions/extension_tab_util.h" |
| 8 #include "chrome/browser/extensions/test_extension_dir.h" | 8 #include "chrome/browser/extensions/test_extension_dir.h" |
| 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 10 #include "chrome/common/extensions/features/feature_channel.h" | 10 #include "chrome/common/extensions/features/feature_channel.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 "}\n" | 64 "}\n" |
| 65 "\n" | 65 "\n" |
| 66 "var testEvent = chrome.declarativeContent.onPageChanged;\n" | 66 "var testEvent = chrome.declarativeContent.onPageChanged;\n" |
| 67 "\n" | 67 "\n" |
| 68 "testEvent.removeRules(undefined, function() {\n" | 68 "testEvent.removeRules(undefined, function() {\n" |
| 69 " testEvent.addRules([rule0], function() {\n" | 69 " testEvent.addRules([rule0], function() {\n" |
| 70 " chrome.test.sendMessage(\"ready\", function(reply) {\n" | 70 " chrome.test.sendMessage(\"ready\", function(reply) {\n" |
| 71 " })\n" | 71 " })\n" |
| 72 " });\n" | 72 " });\n" |
| 73 "});\n"); | 73 "});\n"); |
| 74 ExtensionTestMessageListener ready("ready", true); | 74 ExtensionTestMessageListener ready("ready", false); |
| 75 const Extension* extension = LoadExtension(ext_dir_.unpacked_path()); | 75 const Extension* extension = LoadExtension(ext_dir_.unpacked_path()); |
| 76 ASSERT_TRUE(extension); | 76 ASSERT_TRUE(extension); |
| 77 const ExtensionAction* page_action = | 77 const ExtensionAction* page_action = |
| 78 ExtensionActionManager::Get(browser()->profile())-> | 78 ExtensionActionManager::Get(browser()->profile())-> |
| 79 GetPageAction(*extension); | 79 GetPageAction(*extension); |
| 80 ASSERT_TRUE(page_action); | 80 ASSERT_TRUE(page_action); |
| 81 | 81 |
| 82 ASSERT_TRUE(ready.WaitUntilSatisfied()); | 82 ASSERT_TRUE(ready.WaitUntilSatisfied()); |
| 83 content::WebContents* const tab = | 83 content::WebContents* const tab = |
| 84 browser()->tab_strip_model()->GetWebContentsAt(0); | 84 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 85 const int tab_id = ExtensionTabUtil::GetTabId(tab); | 85 const int tab_id = ExtensionTabUtil::GetTabId(tab); |
| 86 | 86 |
| 87 // There should be no declarative icon until we navigate to a matched page. | 87 // There should be no declarative icon until we navigate to a matched page. |
| 88 EXPECT_TRUE(page_action->GetDeclarativeIcon(tab_id).IsEmpty()); | 88 EXPECT_TRUE(page_action->GetDeclarativeIcon(tab_id).IsEmpty()); |
| 89 NavigateInRenderer(tab, GURL("http://test1/")); | 89 NavigateInRenderer(tab, GURL("http://test1/")); |
| 90 EXPECT_FALSE(page_action->GetDeclarativeIcon(tab_id).IsEmpty()); | 90 EXPECT_FALSE(page_action->GetDeclarativeIcon(tab_id).IsEmpty()); |
| 91 | 91 |
| 92 // Navigating to an unmatched page should reset the icon. | 92 // Navigating to an unmatched page should reset the icon. |
| 93 NavigateInRenderer(tab, GURL("http://test2/")); | 93 NavigateInRenderer(tab, GURL("http://test2/")); |
| 94 EXPECT_TRUE(page_action->GetDeclarativeIcon(tab_id).IsEmpty()); | 94 EXPECT_TRUE(page_action->GetDeclarativeIcon(tab_id).IsEmpty()); |
| 95 } | 95 } |
| 96 } // namespace | 96 } // namespace |
| 97 } // namespace extensions | 97 } // namespace extensions |
| OLD | NEW |