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_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/browser_tabstrip.h" | 7 #include "chrome/browser/ui/browser_tabstrip.h" |
8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 extension_id + std::string(kSubscribePage) + std::string("?") + | 70 extension_id + std::string(kSubscribePage) + std::string("?") + |
71 feed_url.spec() + std::string("&synchronous")); | 71 feed_url.spec() + std::string("&synchronous")); |
72 } else { | 72 } else { |
73 // Navigate to the feed content (which will cause the extension to try to | 73 // 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. | 74 // sniff the type and display the subscribe page in another tab. |
75 return GURL(feed_url.spec()); | 75 return GURL(feed_url.spec()); |
76 } | 76 } |
77 } | 77 } |
78 | 78 |
79 bool ValidatePageElement(WebContents* tab, | 79 bool ValidatePageElement(WebContents* tab, |
80 const std::string& frame, | 80 const std::string& frame_xpath, |
81 const std::string& javascript, | 81 const std::string& javascript, |
82 const std::string& expected_value) { | 82 const std::string& expected_value) { |
83 std::string returned_value; | 83 std::string returned_value; |
84 std::string error; | 84 std::string error; |
85 | 85 |
86 if (!content::ExecuteJavaScriptAndExtractString( | 86 if (!content::ExecuteScriptInFrameAndExtractString(tab, frame_xpath, |
87 tab->GetRenderViewHost(), | 87 javascript, |
88 frame, | 88 &returned_value)) |
89 javascript, | |
90 &returned_value)) | |
91 return false; | 89 return false; |
92 | 90 |
93 EXPECT_STREQ(expected_value.c_str(), returned_value.c_str()); | 91 EXPECT_STREQ(expected_value.c_str(), returned_value.c_str()); |
94 return expected_value == returned_value; | 92 return expected_value == returned_value; |
95 } | 93 } |
96 | 94 |
97 // Navigates to a feed page and, if |sniff_xml_type| is set, wait for the | 95 // Navigates to a feed page and, if |sniff_xml_type| is set, wait for the |
98 // extension to kick in, detect the feed and redirect to a feed preview page. | 96 // extension to kick in, detect the feed and redirect to a feed preview page. |
99 // |sniff_xml_type| is generally set to true if the feed is sniffable and false | 97 // |sniff_xml_type| is generally set to true if the feed is sniffable and false |
100 // for invalid feeds. | 98 // for invalid feeds. |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 std::string id = extension->id(); | 340 std::string id = extension->id(); |
343 | 341 |
344 // Valid feed but containing no links. | 342 // Valid feed but containing no links. |
345 NavigateToFeedAndValidate( | 343 NavigateToFeedAndValidate( |
346 test_server(), kValidFeedNoLinks, browser(), id, true, | 344 test_server(), kValidFeedNoLinks, browser(), id, true, |
347 "Feed for MyFeedTitle", | 345 "Feed for MyFeedTitle", |
348 "Title with no link", | 346 "Title with no link", |
349 "Desc", | 347 "Desc", |
350 "No error"); | 348 "No error"); |
351 } | 349 } |
OLD | NEW |