Commit e3a1012b authored by Mustaq Ahmed's avatar Mustaq Ahmed Committed by Commit Bot

Add a console warning for rejected file-chooser dialog calls.

Bug: 936505
Change-Id: If468227536553d528951ce88744146c5f6913d58
Reviewed-on: https://chromium-review.googlesource.com/c/1495597
Commit-Queue: Mustaq Ahmed <mustaq@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636846}
parent 079aa27d
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "third_party/blink/renderer/core/html/forms/html_input_element.h" #include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html_names.h" #include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/input_type_names.h" #include "third_party/blink/renderer/core/input_type_names.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/layout/layout_file_upload_control.h" #include "third_party/blink/renderer/core/layout/layout_file_upload_control.h"
#include "third_party/blink/renderer/core/page/chrome_client.h" #include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/drag_data.h" #include "third_party/blink/renderer/core/page/drag_data.h"
...@@ -157,14 +158,19 @@ void FileInputType::HandleDOMActivateEvent(Event& event) { ...@@ -157,14 +158,19 @@ void FileInputType::HandleDOMActivateEvent(Event& event) {
if (GetElement().IsDisabledFormControl()) if (GetElement().IsDisabledFormControl())
return; return;
if (!LocalFrame::HasTransientUserActivation( HTMLInputElement& input = GetElement();
GetElement().GetDocument().GetFrame())) Document& document = input.GetDocument();
if (!LocalFrame::HasTransientUserActivation(document.GetFrame())) {
String message =
"File chooser dialog can only be shown with a user activation.";
document.AddConsoleMessage(ConsoleMessage::Create(
kJSMessageSource, kWarningMessageLevel, message));
return; return;
}
if (ChromeClient* chrome_client = GetChromeClient()) { if (ChromeClient* chrome_client = GetChromeClient()) {
FileChooserParams params; FileChooserParams params;
HTMLInputElement& input = GetElement();
Document& document = input.GetDocument();
bool is_directory = input.FastHasAttribute(kWebkitdirectoryAttr); bool is_directory = input.FastHasAttribute(kWebkitdirectoryAttr);
if (is_directory) if (is_directory)
params.mode = FileChooserParams::Mode::kUploadFolder; params.mode = FileChooserParams::Mode::kUploadFolder;
......
CONSOLE WARNING: line 32: File chooser dialog can only be shown with a user activation.
This file is to test that opening file dialog requires a user gesture. Please refer to https://bugs.webkit.org/show_bug.cgi?id=47593 for more details. This file is to test that opening file dialog requires a user gesture. Please refer to https://bugs.webkit.org/show_bug.cgi?id=47593 for more details.
Test opening file dialog without user gesture is PASSED Test opening file dialog without user gesture is PASSED
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment