Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(708)

Side by Side Diff: chrome/browser/extensions/subscribe_page_action_browsertest.cc

Issue 11724002: Move ContentScripts out of Extension (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_browser_action
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_browsertest.h" 5 #include "chrome/browser/extensions/extension_browsertest.h"
6 #include "chrome/browser/ui/browser.h" 6 #include "chrome/browser/ui/browser.h"
7 #include "chrome/browser/ui/tabs/tab_strip_model.h" 7 #include "chrome/browser/ui/tabs/tab_strip_model.h"
8 #include "chrome/common/extensions/api/content_scripts/content_scripts_handler.h "
8 #include "chrome/common/extensions/extension.h" 9 #include "chrome/common/extensions/extension.h"
10 #include "chrome/common/extensions/manifest_handler.h"
9 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
10 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
11 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
12 #include "content/public/test/browser_test_utils.h" 14 #include "content/public/test/browser_test_utils.h"
13 #include "extensions/common/constants.h" 15 #include "extensions/common/constants.h"
14 16
15 using content::WebContents; 17 using content::WebContents;
16 using extensions::Extension;
17 18
19 namespace extensions {
18 namespace { 20 namespace {
19 21
20 const char kSubscribePage[] = "/subscribe.html"; 22 const char kSubscribePage[] = "/subscribe.html";
21 const char kFeedPageMultiRel[] = "files/feeds/feed_multi_rel.html"; 23 const char kFeedPageMultiRel[] = "files/feeds/feed_multi_rel.html";
22 const char kValidFeedNoLinks[] = "files/feeds/feed_nolinks.xml"; 24 const char kValidFeedNoLinks[] = "files/feeds/feed_nolinks.xml";
23 const char kValidFeed0[] = "files/feeds/feed_script.xml"; 25 const char kValidFeed0[] = "files/feeds/feed_script.xml";
24 const char kValidFeed1[] = "files/feeds/feed1.xml"; 26 const char kValidFeed1[] = "files/feeds/feed1.xml";
25 const char kValidFeed2[] = "files/feeds/feed2.xml"; 27 const char kValidFeed2[] = "files/feeds/feed2.xml";
26 const char kValidFeed3[] = "files/feeds/feed3.xml"; 28 const char kValidFeed3[] = "files/feeds/feed3.xml";
27 const char kValidFeed4[] = "files/feeds/feed4.xml"; 29 const char kValidFeed4[] = "files/feeds/feed4.xml";
(...skipping 30 matching lines...) Expand all
58 " document.getElementById('error').textContent : " 60 " document.getElementById('error').textContent : "
59 " \"No error\"" 61 " \"No error\""
60 ");"; 62 ");";
61 63
62 GURL GetFeedUrl(net::TestServer* server, const std::string& feed_page, 64 GURL GetFeedUrl(net::TestServer* server, const std::string& feed_page,
63 bool direct_url, std::string extension_id) { 65 bool direct_url, std::string extension_id) {
64 GURL feed_url = server->GetURL(feed_page); 66 GURL feed_url = server->GetURL(feed_page);
65 if (direct_url) { 67 if (direct_url) {
66 // We navigate directly to the subscribe page for feeds where the feed 68 // We navigate directly to the subscribe page for feeds where the feed
67 // sniffing won't work, in other words, as is the case for malformed feeds. 69 // sniffing won't work, in other words, as is the case for malformed feeds.
68 return GURL(std::string(extensions::kExtensionScheme) + 70 return GURL(std::string(kExtensionScheme) +
69 content::kStandardSchemeSeparator + 71 content::kStandardSchemeSeparator +
70 extension_id + std::string(kSubscribePage) + std::string("?") + 72 extension_id + std::string(kSubscribePage) + std::string("?") +
71 feed_url.spec() + std::string("&synchronous")); 73 feed_url.spec() + std::string("&synchronous"));
72 } else { 74 } else {
73 // Navigate to the feed content (which will cause the extension to try to 75 // Navigate to the feed content (which will cause the extension to try to
74 // sniff the type and display the subscribe page in another tab. 76 // sniff the type and display the subscribe page in another tab.
75 return GURL(feed_url.spec()); 77 return GURL(feed_url.spec());
76 } 78 }
77 } 79 }
78 80
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 "//html/body/div/iframe[1]", 132 "//html/body/div/iframe[1]",
131 kScriptError, 133 kScriptError,
132 expected_error)); 134 expected_error));
133 } 135 }
134 136
135 } // namespace 137 } // namespace
136 138
137 // Makes sure that the RSS detects RSS feed links, even when rel tag contains 139 // Makes sure that the RSS detects RSS feed links, even when rel tag contains
138 // more than just "alternate". 140 // more than just "alternate".
139 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, RSSMultiRelLink) { 141 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, RSSMultiRelLink) {
142 (new ContentScriptsHandler)->Register();
140 ASSERT_TRUE(test_server()->Start()); 143 ASSERT_TRUE(test_server()->Start());
141 144
142 ASSERT_TRUE(LoadExtension( 145 ASSERT_TRUE(LoadExtension(
143 test_data_dir_.AppendASCII("subscribe_page_action"))); 146 test_data_dir_.AppendASCII("subscribe_page_action")));
144 147
145 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(0)); 148 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(0));
146 149
147 // Navigate to the feed page. 150 // Navigate to the feed page.
148 GURL feed_url = test_server()->GetURL(kFeedPageMultiRel); 151 GURL feed_url = test_server()->GetURL(kFeedPageMultiRel);
149 ui_test_utils::NavigateToURL(browser(), feed_url); 152 ui_test_utils::NavigateToURL(browser(), feed_url);
150 // We should now have one page action ready to go in the LocationBar. 153 // We should now have one page action ready to go in the LocationBar.
151 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 154 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
155
156 ManifestHandler::ClearRegistryForTesting();
152 } 157 }
153 158
154 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed1) { 159 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, ParseFeedValidFeed1) {
155 ASSERT_TRUE(test_server()->Start()); 160 ASSERT_TRUE(test_server()->Start());
156 161
157 const Extension* extension = LoadExtension( 162 const Extension* extension = LoadExtension(
158 test_data_dir_.AppendASCII("subscribe_page_action")); 163 test_data_dir_.AppendASCII("subscribe_page_action"));
159 ASSERT_TRUE(extension); 164 ASSERT_TRUE(extension);
160 std::string id = extension->id(); 165 std::string id = extension->id();
161 166
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 std::string id = extension->id(); 345 std::string id = extension->id();
341 346
342 // Valid feed but containing no links. 347 // Valid feed but containing no links.
343 NavigateToFeedAndValidate( 348 NavigateToFeedAndValidate(
344 test_server(), kValidFeedNoLinks, browser(), id, true, 349 test_server(), kValidFeedNoLinks, browser(), id, true,
345 "Feed for MyFeedTitle", 350 "Feed for MyFeedTitle",
346 "Title with no link", 351 "Title with no link",
347 "Desc", 352 "Desc",
348 "No error"); 353 "No error");
349 } 354 }
355
356 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698