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

Side by Side Diff: chrome/browser/dom_distiller/dom_distiller_viewer_source_browsertest.cc

Issue 1015463004: Consistent content placement method for dom-distiller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix IOS version of code Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <string.h> 5 #include <string.h>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/guid.h" 8 #include "base/guid.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" 10 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
(...skipping 14 matching lines...) Expand all
25 #include "components/dom_distiller/core/fake_distiller_page.h" 25 #include "components/dom_distiller/core/fake_distiller_page.h"
26 #include "components/dom_distiller/core/task_tracker.h" 26 #include "components/dom_distiller/core/task_tracker.h"
27 #include "components/dom_distiller/core/url_constants.h" 27 #include "components/dom_distiller/core/url_constants.h"
28 #include "components/dom_distiller/core/url_utils.h" 28 #include "components/dom_distiller/core/url_utils.h"
29 #include "components/leveldb_proto/testing/fake_db.h" 29 #include "components/leveldb_proto/testing/fake_db.h"
30 #include "content/public/browser/render_view_host.h" 30 #include "content/public/browser/render_view_host.h"
31 #include "content/public/browser/url_data_source.h" 31 #include "content/public/browser/url_data_source.h"
32 #include "content/public/browser/web_contents.h" 32 #include "content/public/browser/web_contents.h"
33 #include "content/public/browser/web_contents_observer.h" 33 #include "content/public/browser/web_contents_observer.h"
34 #include "content/public/test/browser_test_utils.h" 34 #include "content/public/test/browser_test_utils.h"
35 #include "grit/components_strings.h"
35 #include "testing/gmock/include/gmock/gmock.h" 36 #include "testing/gmock/include/gmock/gmock.h"
36 #include "testing/gtest/include/gtest/gtest.h" 37 #include "testing/gtest/include/gtest/gtest.h"
38 #include "ui/base/l10n/l10n_util.h"
37 39
38 namespace dom_distiller { 40 namespace dom_distiller {
39 41
40 using leveldb_proto::test::FakeDB; 42 using leveldb_proto::test::FakeDB;
41 using test::FakeDistiller; 43 using test::FakeDistiller;
42 using test::MockDistillerPage; 44 using test::MockDistillerPage;
43 using test::MockDistillerFactory; 45 using test::MockDistillerFactory;
44 using test::MockDistillerPageFactory; 46 using test::MockDistillerPageFactory;
45 using test::util::CreateStoreWithFakeDB; 47 using test::util::CreateStoreWithFakeDB;
46 using testing::HasSubstr; 48 using testing::HasSubstr;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 content::WebContents* contents_after_nav = 195 content::WebContents* contents_after_nav =
194 browser()->tab_strip_model()->GetActiveWebContents(); 196 browser()->tab_strip_model()->GetActiveWebContents();
195 ASSERT_TRUE(contents_after_nav != NULL); 197 ASSERT_TRUE(contents_after_nav != NULL);
196 EXPECT_EQ(url, contents_after_nav->GetLastCommittedURL()); 198 EXPECT_EQ(url, contents_after_nav->GetLastCommittedURL());
197 const content::RenderViewHost* render_view_host = 199 const content::RenderViewHost* render_view_host =
198 contents_after_nav->GetRenderViewHost(); 200 contents_after_nav->GetRenderViewHost();
199 EXPECT_EQ(0, render_view_host->GetEnabledBindings()); 201 EXPECT_EQ(0, render_view_host->GetEnabledBindings());
200 EXPECT_EQ(expected_mime_type, contents_after_nav->GetContentsMimeType()); 202 EXPECT_EQ(expected_mime_type, contents_after_nav->GetContentsMimeType());
201 } 203 }
202 204
205 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest,
206 TestBadUrlErrorPage) {
207 GURL url("chrome-distiller://bad");
208
209 // Navigate to a distiller URL.
210 ui_test_utils::NavigateToURL(browser(), url);
211 content::WebContents* contents =
212 browser()->tab_strip_model()->GetActiveWebContents();
213
214 // Wait for the page load to complete as the first page completes the root
215 // document.
216 content::WaitForLoadStop(contents);
217
218 ASSERT_TRUE(contents != NULL);
219 EXPECT_EQ(url, contents->GetLastCommittedURL());
220
221 std::string result;
222 EXPECT_TRUE(content::ExecuteScriptAndExtractString(
223 contents, kGetContent , &result));
224 EXPECT_THAT(result, HasSubstr(l10n_util::GetStringUTF8(
225 IDS_DOM_DISTILLER_VIEWER_FAILED_TO_FIND_ARTICLE_CONTENT)));
226 }
227
203 // The DomDistillerViewerSource renders untrusted content, so ensure no bindings 228 // The DomDistillerViewerSource renders untrusted content, so ensure no bindings
204 // are enabled when the CSS resource is loaded. This CSS might be bundle with 229 // are enabled when the CSS resource is loaded. This CSS might be bundle with
205 // Chrome or provided by an extension. 230 // Chrome or provided by an extension.
206 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest, 231 IN_PROC_BROWSER_TEST_F(DomDistillerViewerSourceBrowserTest,
207 NoWebUIBindingsDisplayCSS) { 232 NoWebUIBindingsDisplayCSS) {
208 expect_distillation_ = false; 233 expect_distillation_ = false;
209 expect_distiller_page_ = false; 234 expect_distiller_page_ = false;
210 // Navigate to a URL which the source should respond to with CSS. 235 // Navigate to a URL which the source should respond to with CSS.
211 std::string url_without_scheme = std::string("://foobar/") + kViewerCssPath; 236 std::string url_without_scheme = std::string("://foobar/") + kViewerCssPath;
212 GURL url(kDomDistillerScheme + url_without_scheme); 237 GURL url(kDomDistillerScheme + url_without_scheme);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 EXPECT_EQ("dark sans-serif", result); 379 EXPECT_EQ("dark sans-serif", result);
355 380
356 distilled_page_prefs->SetFontFamily(DistilledPagePrefs::SERIF); 381 distilled_page_prefs->SetFontFamily(DistilledPagePrefs::SERIF);
357 base::RunLoop().RunUntilIdle(); 382 base::RunLoop().RunUntilIdle();
358 EXPECT_TRUE( 383 EXPECT_TRUE(
359 content::ExecuteScriptAndExtractString(contents, kGetBodyClass, &result)); 384 content::ExecuteScriptAndExtractString(contents, kGetBodyClass, &result));
360 EXPECT_EQ("dark serif", result); 385 EXPECT_EQ("dark serif", result);
361 } 386 }
362 387
363 } // namespace dom_distiller 388 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698