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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 2100503002: Fix file input dialog from out-of-process iframe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('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 (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 "content/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/path_service.h"
16 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
17 #include "base/strings/pattern.h" 18 #include "base/strings/pattern.h"
18 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
19 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
20 #include "base/test/test_timeouts.h" 21 #include "base/test/test_timeouts.h"
21 #include "base/threading/thread_task_runner_handle.h" 22 #include "base/threading/thread_task_runner_handle.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 #include "components/network_session_configurator/switches.h" 24 #include "components/network_session_configurator/switches.h"
24 #include "content/browser/frame_host/cross_process_frame_connector.h" 25 #include "content/browser/frame_host/cross_process_frame_connector.h"
25 #include "content/browser/frame_host/frame_tree.h" 26 #include "content/browser/frame_host/frame_tree.h"
(...skipping 7266 matching lines...) Expand 10 before | Expand all | Expand 10 after
7292 EXPECT_TRUE(is_fullscreen_allowed(root)); 7293 EXPECT_TRUE(is_fullscreen_allowed(root));
7293 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0))); 7294 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)));
7294 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); 7295 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7295 7296
7296 // Cross-site navigation should preserve the fullscreen flags. 7297 // Cross-site navigation should preserve the fullscreen flags.
7297 NavigateFrameToURL(root->child_at(0)->child_at(0), 7298 NavigateFrameToURL(root->child_at(0)->child_at(0),
7298 embedded_test_server()->GetURL("d.com", "/title1.html")); 7299 embedded_test_server()->GetURL("d.com", "/title1.html"));
7299 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0))); 7300 EXPECT_TRUE(is_fullscreen_allowed(root->child_at(0)->child_at(0)));
7300 } 7301 }
7301 7302
7303 // Test for https://crbug.com/615575. It ensures that file chooser triggered
7304 // by a document in an out-of-process subframe works properly.
7305 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, FileChooserInSubframe) {
7306 EXPECT_TRUE(NavigateToURL(shell(), embedded_test_server()->GetURL(
7307 "a.com", "/cross_site_iframe_factory.html?a(b)")));
7308 WebContentsImpl* contents = web_contents();
Charlie Reis 2016/06/24 21:41:41 nit: This is unnecessary. The other tests have it
nasko 2016/06/24 22:11:24 Done.
7309 FrameTreeNode* root = contents->GetFrameTree()->root();
7310
7311 GURL url(embedded_test_server()->GetURL("b.com", "/file_input.html"));
7312 NavigateFrameToURL(root->child_at(0), url);
7313
7314 // Use FileChooserDelegate to avoid showing the actual dialog and to respond
7315 // back to the renderer process with predefined file.
7316 base::FilePath file;
7317 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file));
7318 file = file.AppendASCII("bar");
7319 std::unique_ptr<FileChooserDelegate> delegate(new FileChooserDelegate(file));
7320 shell()->web_contents()->SetDelegate(delegate.get());
7321 EXPECT_TRUE(ExecuteScript(root->child_at(0),
7322 "document.getElementById('fileinput').click();"));
7323 EXPECT_TRUE(delegate->file_chosen());
7324
7325 // Also, extract the file from the renderer process to ensure that the
7326 // response made it over successfully and the proper filename is set.
7327 std::string file_name;
7328 EXPECT_TRUE(ExecuteScriptAndExtractString(
7329 root->child_at(0),
7330 "window.domAutomationController.send("
7331 "document.getElementById('fileinput').files[0].name);",
7332 &file_name));
7333 EXPECT_EQ("bar", file_name);
7334 }
7335
7302 } // namespace content 7336 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698