| 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.h" | 5 #include "chrome/browser/extensions/extension_action.h" |
| 6 #include "chrome/browser/extensions/extension_action_manager.h" | 6 #include "chrome/browser/extensions/extension_action_manager.h" |
| 7 #include "chrome/browser/extensions/extension_action_test_util.h" | 7 #include "chrome/browser/extensions/extension_action_test_util.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_tab_util.h" | 9 #include "chrome/browser/extensions/extension_tab_util.h" |
| 10 #include "chrome/browser/extensions/test_extension_dir.h" | 10 #include "chrome/browser/extensions/test_extension_dir.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 TestExtensionDir ext_dir_; | 111 TestExtensionDir ext_dir_; |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 DISALLOW_COPY_AND_ASSIGN(DeclarativeContentApiTest); | 114 DISALLOW_COPY_AND_ASSIGN(DeclarativeContentApiTest); |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 void DeclarativeContentApiTest::CheckIncognito(IncognitoMode mode, | 117 void DeclarativeContentApiTest::CheckIncognito(IncognitoMode mode, |
| 118 bool is_enabled_in_incognito) { | 118 bool is_enabled_in_incognito) { |
| 119 std::string manifest = kDeclarativeContentManifest; | 119 std::string manifest = kDeclarativeContentManifest; |
| 120 if (mode == SPLIT) { | 120 if (mode == SPLIT) { |
| 121 ReplaceSubstringsAfterOffset(&manifest, 0, "\"incognito\": \"spanning\"", | 121 base::ReplaceSubstringsAfterOffset( |
| 122 "\"incognito\": \"split\""); | 122 &manifest, 0, "\"incognito\": \"spanning\"", |
| 123 "\"incognito\": \"split\""); |
| 123 ASSERT_NE(kDeclarativeContentManifest, manifest); | 124 ASSERT_NE(kDeclarativeContentManifest, manifest); |
| 124 } | 125 } |
| 125 ext_dir_.WriteManifest(manifest); | 126 ext_dir_.WriteManifest(manifest); |
| 126 ext_dir_.WriteFile(FILE_PATH_LITERAL("background.js"), | 127 ext_dir_.WriteFile(FILE_PATH_LITERAL("background.js"), |
| 127 kIncognitoSpecificBackground); | 128 kIncognitoSpecificBackground); |
| 128 | 129 |
| 129 ExtensionTestMessageListener ready("ready", false); | 130 ExtensionTestMessageListener ready("ready", false); |
| 130 ExtensionTestMessageListener ready_incognito("ready (split)", false); | 131 ExtensionTestMessageListener ready_incognito("ready (split)", false); |
| 131 | 132 |
| 132 const Extension* extension = is_enabled_in_incognito ? | 133 const Extension* extension = is_enabled_in_incognito ? |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 extension->id(), | 565 extension->id(), |
| 565 "onPageChanged.removeRules(undefined, function() {\n" | 566 "onPageChanged.removeRules(undefined, function() {\n" |
| 566 " window.domAutomationController.send('removed');\n" | 567 " window.domAutomationController.send('removed');\n" |
| 567 "});\n")); | 568 "});\n")); |
| 568 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); | 569 EXPECT_FALSE(page_action->GetIsVisible(tab_id)); |
| 569 } | 570 } |
| 570 | 571 |
| 571 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, | 572 IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, |
| 572 ShowPageActionWithoutPageAction) { | 573 ShowPageActionWithoutPageAction) { |
| 573 std::string manifest_without_page_action = kDeclarativeContentManifest; | 574 std::string manifest_without_page_action = kDeclarativeContentManifest; |
| 574 ReplaceSubstringsAfterOffset( | 575 base::ReplaceSubstringsAfterOffset( |
| 575 &manifest_without_page_action, 0, "\"page_action\": {},", ""); | 576 &manifest_without_page_action, 0, "\"page_action\": {},", ""); |
| 576 ASSERT_NE(kDeclarativeContentManifest, manifest_without_page_action); | 577 ASSERT_NE(kDeclarativeContentManifest, manifest_without_page_action); |
| 577 ext_dir_.WriteManifest(manifest_without_page_action); | 578 ext_dir_.WriteManifest(manifest_without_page_action); |
| 578 ext_dir_.WriteFile(FILE_PATH_LITERAL("background.js"), kBackgroundHelpers); | 579 ext_dir_.WriteFile(FILE_PATH_LITERAL("background.js"), kBackgroundHelpers); |
| 579 const Extension* extension = LoadExtension(ext_dir_.unpacked_path()); | 580 const Extension* extension = LoadExtension(ext_dir_.unpacked_path()); |
| 580 ASSERT_TRUE(extension); | 581 ASSERT_TRUE(extension); |
| 581 | 582 |
| 582 EXPECT_THAT(ExecuteScriptInBackgroundPage( | 583 EXPECT_THAT(ExecuteScriptInBackgroundPage( |
| 583 extension->id(), | 584 extension->id(), |
| 584 "setRules([{\n" | 585 "setRules([{\n" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 728 // consistent URL state for all conditions. i.e.: if condition1 evaluates to | 729 // consistent URL state for all conditions. i.e.: if condition1 evaluates to |
| 729 // false on url0 and true on url1, and condition2 evaluates to true on url0 and | 730 // false on url0 and true on url1, and condition2 evaluates to true on url0 and |
| 730 // false on url1, navigate from url0 to url1 and validate that no action is | 731 // false on url1, navigate from url0 to url1 and validate that no action is |
| 731 // triggered. Do the same when navigating back to url0. This kind of test is | 732 // triggered. Do the same when navigating back to url0. This kind of test is |
| 732 // unfortunately not feasible with the current implementation and the existing | 733 // unfortunately not feasible with the current implementation and the existing |
| 733 // supported conditions and actions. | 734 // supported conditions and actions. |
| 734 | 735 |
| 735 } // namespace | 736 } // namespace |
| 736 } // namespace extensions | 737 } // namespace extensions |
| 737 | 738 |
| OLD | NEW |