#include "base/path_service.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/shell/browser/shell.h"
#include "content/test/content_browser_test_utils_internal.h"
namespace content {
using FileAPIBrowserTest = ContentBrowserTest;
IN_PROC_BROWSER_TEST_F(FileAPIBrowserTest, FileInputChooserParams) {
base::FilePath file;
EXPECT_TRUE(base::PathService::Get(base::DIR_TEMP, &file));
file = file.AppendASCII("bar");
EXPECT_TRUE(NavigateToURL(shell(), GetTestUrl(".", "file_input.html")));
{
base::RunLoop run_loop;
FileChooserDelegate delegate(file, run_loop.QuitClosure());
shell()->web_contents()->SetDelegate(&delegate);
EXPECT_TRUE(
ExecJs(shell(), "document.getElementById('fileinput').click();"));
run_loop.Run();
EXPECT_TRUE(delegate.params().default_file_name.empty());
}
{
base::RunLoop run_loop;
FileChooserDelegate delegate(file, run_loop.QuitClosure());
shell()->web_contents()->SetDelegate(&delegate);
EXPECT_TRUE(
ExecJs(shell(), "document.getElementById('fileinput').click();"));
run_loop.Run();
EXPECT_TRUE(delegate.params().default_file_name.empty());
}
}
}