OLD | NEW |
---|---|
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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/profiles/profile.h" | |
11 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/test/base/in_process_browser_test.h" | 14 #include "chrome/test/base/in_process_browser_test.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
16 #include "components/guest_view/browser/guest_view_manager_delegate.h" | |
17 #include "components/guest_view/browser/test_guest_view_manager.h" | |
15 #include "content/public/browser/interstitial_page.h" | 18 #include "content/public/browser/interstitial_page.h" |
16 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
17 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
18 #include "content/public/browser/notification_types.h" | 21 #include "content/public/browser/notification_types.h" |
19 #include "content/public/browser/render_frame_host.h" | 22 #include "content/public/browser/render_frame_host.h" |
20 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
21 #include "content/public/browser/web_contents_observer.h" | 24 #include "content/public/browser/web_contents_observer.h" |
22 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
23 #include "content/public/test/content_browser_test_utils.h" | 26 #include "content/public/test/content_browser_test_utils.h" |
24 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
28 #include "extensions/browser/api/extensions_api_client.h" | |
25 #include "net/dns/mock_host_resolver.h" | 29 #include "net/dns/mock_host_resolver.h" |
26 #include "net/test/embedded_test_server/embedded_test_server.h" | 30 #include "net/test/embedded_test_server/embedded_test_server.h" |
27 #include "ui/display/display_switches.h" | 31 #include "ui/display/display_switches.h" |
28 #include "url/gurl.h" | 32 #include "url/gurl.h" |
29 | 33 |
30 class ChromeSitePerProcessTest : public InProcessBrowserTest { | 34 class ChromeSitePerProcessTest : public InProcessBrowserTest { |
31 public: | 35 public: |
32 ChromeSitePerProcessTest() {} | 36 ChromeSitePerProcessTest() {} |
33 ~ChromeSitePerProcessTest() override {} | 37 ~ChromeSitePerProcessTest() override {} |
34 | 38 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 content::WebContents* new_contents = new_tab_observer.GetWebContents(); | 282 content::WebContents* new_contents = new_tab_observer.GetWebContents(); |
279 | 283 |
280 // Verify that the new tab has the right contents and is in the right, new | 284 // Verify that the new tab has the right contents and is in the right, new |
281 // place in the tab strip. | 285 // place in the tab strip. |
282 EXPECT_TRUE(WaitForLoadStop(new_contents)); | 286 EXPECT_TRUE(WaitForLoadStop(new_contents)); |
283 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | 287 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
284 EXPECT_EQ(new_contents, browser()->tab_strip_model()->GetWebContentsAt(1)); | 288 EXPECT_EQ(new_contents, browser()->tab_strip_model()->GetWebContentsAt(1)); |
285 GURL expected_url(embedded_test_server()->GetURL("c.com", "/title1.html")); | 289 GURL expected_url(embedded_test_server()->GetURL("c.com", "/title1.html")); |
286 EXPECT_EQ(expected_url, new_contents->GetLastCommittedURL()); | 290 EXPECT_EQ(expected_url, new_contents->GetLastCommittedURL()); |
287 } | 291 } |
292 | |
293 class ChromeSitePerProcessPDFTest : public ChromeSitePerProcessTest { | |
294 public: | |
295 ChromeSitePerProcessPDFTest() : test_guest_view_manager_(nullptr) {} | |
296 ~ChromeSitePerProcessPDFTest() override {} | |
297 | |
298 void SetUpOnMainThread() override { | |
299 ChromeSitePerProcessTest::SetUpOnMainThread(); | |
300 guest_view::GuestViewManager::set_factory_for_testing(&factory_); | |
301 test_guest_view_manager_ = static_cast<guest_view::TestGuestViewManager*>( | |
302 guest_view::GuestViewManager::CreateWithDelegate( | |
303 browser()->profile(), | |
304 extensions::ExtensionsAPIClient::Get() | |
305 ->CreateGuestViewManagerDelegate(browser()->profile()))); | |
306 } | |
307 | |
308 protected: | |
309 guest_view::TestGuestViewManager* test_guest_view_manager() const { | |
310 return test_guest_view_manager_; | |
311 } | |
312 | |
313 private: | |
314 guest_view::TestGuestViewManagerFactory factory_; | |
315 guest_view::TestGuestViewManager* test_guest_view_manager_; | |
316 | |
317 DISALLOW_COPY_AND_ASSIGN(ChromeSitePerProcessPDFTest); | |
318 }; | |
319 | |
320 // This test verifies that when navigating an OOPIF to a page with <embed>-ed | |
321 // PDF, the guest is properly created (https://crbug.com/649856). | |
322 IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessPDFTest, | |
323 EmbeddedPDFInsideCrossOriginFrame) { | |
324 // Navigate to a page with an <iframe>. | |
325 GURL main_url(embedded_test_server()->GetURL("a.com", "/iframe.html")); | |
326 ui_test_utils::NavigateToURL(browser(), main_url); | |
327 | |
328 // Initially, no guests are created. | |
329 EXPECT_EQ(0U, test_guest_view_manager()->num_guests_created()); | |
330 | |
331 // Navigate subframe to a cross-site page with an embedded PDF. | |
332 content::WebContents* active_web_contents = | |
333 browser()->tab_strip_model()->GetActiveWebContents(); | |
334 GURL frame_url = | |
335 embedded_test_server()->GetURL("b.com", "/page_with_embedded_pdf.html"); | |
336 | |
337 // Ensure the page finishes loading without crashing. | |
338 EXPECT_TRUE(NavigateIframeToURL(active_web_contents, "test", frame_url)); | |
339 | |
340 // Wait until the guest for PDF is created. | |
341 guest_view_manager->WaitForSingleGuestCreated(1U); | |
alexmos
2016/11/08 23:21:45
The 1U is not needed anymore.
EhsanK
2016/11/15 19:54:22
Thanks! Of course, this also caused bots to go rea
| |
342 } | |
OLD | NEW |