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

Side by Side Diff: chrome/browser/chrome_site_per_process_browsertest.cc

Issue 2417693002: Allow MimeHandlerViewGuest be embedded inside OOPIFs (Closed)
Patch Set: Rebased Created 4 years, 1 month 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
« no previous file with comments | « no previous file | chrome/test/data/page_with_embedded_pdf.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 content::WebContents* new_contents = new_tab_observer.GetWebContents(); 285 content::WebContents* new_contents = new_tab_observer.GetWebContents();
282 286
283 // Verify that the new tab has the right contents and is in the right, new 287 // Verify that the new tab has the right contents and is in the right, new
284 // place in the tab strip. 288 // place in the tab strip.
285 EXPECT_TRUE(WaitForLoadStop(new_contents)); 289 EXPECT_TRUE(WaitForLoadStop(new_contents));
286 EXPECT_EQ(2, browser()->tab_strip_model()->count()); 290 EXPECT_EQ(2, browser()->tab_strip_model()->count());
287 EXPECT_EQ(new_contents, browser()->tab_strip_model()->GetWebContentsAt(1)); 291 EXPECT_EQ(new_contents, browser()->tab_strip_model()->GetWebContentsAt(1));
288 GURL expected_url(embedded_test_server()->GetURL("c.com", "/title1.html")); 292 GURL expected_url(embedded_test_server()->GetURL("c.com", "/title1.html"));
289 EXPECT_EQ(expected_url, new_contents->GetLastCommittedURL()); 293 EXPECT_EQ(expected_url, new_contents->GetLastCommittedURL());
290 } 294 }
295
296 class ChromeSitePerProcessPDFTest : public ChromeSitePerProcessTest {
297 public:
298 ChromeSitePerProcessPDFTest() : test_guest_view_manager_(nullptr) {}
299 ~ChromeSitePerProcessPDFTest() override {}
300
301 void SetUpOnMainThread() override {
302 ChromeSitePerProcessTest::SetUpOnMainThread();
303 guest_view::GuestViewManager::set_factory_for_testing(&factory_);
304 test_guest_view_manager_ = static_cast<guest_view::TestGuestViewManager*>(
305 guest_view::GuestViewManager::CreateWithDelegate(
306 browser()->profile(),
307 extensions::ExtensionsAPIClient::Get()
308 ->CreateGuestViewManagerDelegate(browser()->profile())));
309 }
310
311 protected:
312 guest_view::TestGuestViewManager* test_guest_view_manager() const {
313 return test_guest_view_manager_;
314 }
315
316 private:
317 guest_view::TestGuestViewManagerFactory factory_;
318 guest_view::TestGuestViewManager* test_guest_view_manager_;
319
320 DISALLOW_COPY_AND_ASSIGN(ChromeSitePerProcessPDFTest);
321 };
322
323 // This test verifies that when navigating an OOPIF to a page with <embed>-ed
324 // PDF, the guest is properly created (https://crbug.com/649856).
325 IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessPDFTest,
326 EmbeddedPDFInsideCrossOriginFrame) {
327 // Navigate to a page with an <iframe>.
328 GURL main_url(embedded_test_server()->GetURL("a.com", "/iframe.html"));
329 ui_test_utils::NavigateToURL(browser(), main_url);
330
331 // Initially, no guests are created.
332 EXPECT_EQ(0U, test_guest_view_manager()->num_guests_created());
333
334 // Navigate subframe to a cross-site page with an embedded PDF.
335 content::WebContents* active_web_contents =
336 browser()->tab_strip_model()->GetActiveWebContents();
337 GURL frame_url =
338 embedded_test_server()->GetURL("b.com", "/page_with_embedded_pdf.html");
339
340 // Ensure the page finishes loading without crashing.
341 EXPECT_TRUE(NavigateIframeToURL(active_web_contents, "test", frame_url));
342
343 // Wait until the guest for PDF is created.
344 test_guest_view_manager()->WaitForSingleGuestCreated();
345 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/page_with_embedded_pdf.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698