diff options
3 files changed, 20 insertions, 13 deletions
diff --git a/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event-expected.txt b/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event-expected.txt index 6d03df6..aff2c22 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event-expected.txt +++ b/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event-expected.txt @@ -13,6 +13,9 @@ PASS singleFileInput.value is "C:\\fakepath\\bar.txt" PASS changeDispatched is false PASS singleFileInput.value is "C:\\fakepath\\foo.txt" PASS changeDispatched is true +PASS singleFileInput.value is "C:\\fakepath\\baz.png" +PASS changeDispatched is true + Test that the 'change' event is triggered on a multiple file form when a selected file is changed: PASS multipleFilesInput.value is "C:\\fakepath\\foo.txt" PASS changeDispatched is true diff --git a/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html b/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html index 89a80d9..fab3c8a 100644 --- a/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html +++ b/third_party/WebKit/LayoutTests/fast/forms/file/file-input-change-event.html @@ -33,6 +33,11 @@ if (window.testRunner) { shouldBeEqualToString("singleFileInput.value", "C:\\fakepath\\foo.txt"); shouldBe("changeDispatched", "true"); + dragFilesOntoButtonInsideFileInput(singleFileInput, ["baz.png"]); + shouldBeEqualToString("singleFileInput.value", "C:\\fakepath\\baz.png"); + shouldBe("changeDispatched", "true"); + + debug(""); debug("Test that the 'change' event is triggered on a multiple file form when a selected file is changed:"); dragFilesOntoInput(multipleFilesInput, ["foo.txt"]); shouldBeEqualToString("multipleFilesInput.value", "C:\\fakepath\\foo.txt"); @@ -100,6 +105,13 @@ function dragFilesOntoInput(input, files) { moveMouseToCenterOfElement(input); eventSender.mouseUp(); } + +function dragFilesOntoButtonInsideFileInput(input, files) { + changeDispatched = false; + eventSender.beginDragWithFiles(files); + eventSender.mouseMoveTo(input.offsetLeft + 10, input.offsetTop + input.offsetHeight / 2); + eventSender.mouseUp(); +} </script> <script src="../../js/resources/js-test-post.js"></script> </body> diff --git a/third_party/WebKit/Source/core/page/DragController.cpp b/third_party/WebKit/Source/core/page/DragController.cpp index 875d2da..5e8998e 100644 --- a/third_party/WebKit/Source/core/page/DragController.cpp +++ b/third_party/WebKit/Source/core/page/DragController.cpp @@ -297,19 +297,11 @@ DragSession DragController::dragEnteredOrUpdated(DragData* dragData) static HTMLInputElement* asFileInput(Node* node) { ASSERT(node); - - if (!node->hasTagName(HTMLNames::inputTag)) - return 0; - HTMLInputElement* inputElement = toHTMLInputElement(node); - // If this is a button inside of the a file input, move up to the file input. - if (inputElement->isTextButton() && inputElement->treeScope()->rootNode()->isShadowRoot()) { - Element* host = toShadowRoot(inputElement->treeScope()->rootNode())->host(); - if (!host->hasTagName(HTMLNames::inputTag)) - return 0; - inputElement = toHTMLInputElement(host); + for (; node; node = node->shadowHost()) { + if (node->hasTagName(HTMLNames::inputTag) && toHTMLInputElement(node)->isFileUpload()) + return toHTMLInputElement(node); } - - return inputElement->isFileUpload() ? inputElement : 0; + return 0; } // This can return null if an empty document is loaded. @@ -325,7 +317,7 @@ static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint& Node* n = result.innerNode(); while (n && !n->isElementNode()) - n = n->parentNode(); + n = n->parentOrShadowHostNode(); if (n) n = n->deprecatedShadowAncestorNode(); |