[Qt] When calling accept() on the FilePickerContextObject with an empty list, early...
authoralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2012 13:32:29 +0000 (13:32 +0000)
committeralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Jul 2012 13:32:29 +0000 (13:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=89755

Reviewed by Simon Hausmann.

When calling accept with an empty list of files we can just bailout
and call reject(). Any other processing is pointless.

       * UIProcess/API/qt/tests/qmltests/WebView/tst_singleFileUpload.qml:
       * UIProcess/qt/QtDialogRunner.cpp:
(WebKit::FilePickerContextObject::accept):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121761 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_singleFileUpload.qml
Source/WebKit2/UIProcess/qt/QtDialogRunner.cpp

index a614070..4b742b7 100644 (file)
@@ -1,3 +1,17 @@
+2012-07-03  Alexis Menard  <alexis.menard@openbossa.org>
+
+        [Qt] When calling accept() on the FilePickerContextObject with an empty list, early return and call reject().
+        https://bugs.webkit.org/show_bug.cgi?id=89755
+
+        Reviewed by Simon Hausmann.
+
+        When calling accept with an empty list of files we can just bailout
+        and call reject(). Any other processing is pointless.
+
+       * UIProcess/API/qt/tests/qmltests/WebView/tst_singleFileUpload.qml:
+       * UIProcess/qt/QtDialogRunner.cpp:
+        (WebKit::FilePickerContextObject::accept):
+
 2012-07-03  Balazs Kelemen  <kbalazs@webkit.org>
 
         [Qt][WK2] fast/viewport/viewport-91.html still fails after r121555 and r121661
index 6bcd803..30514a3 100644 (file)
@@ -11,18 +11,20 @@ TestWebView {
     height: 400
 
     property bool selectFile
+    property bool returnEmpty: false
     property bool acceptMultiple: false
 
     experimental.filePicker: Item {
         Component.onCompleted: {
-            var selectedFiles = ["filename1", "filename2"]
-            if (selectFile) {
+            if (returnEmpty)
+                model.accept("");
+            else if (selectFile) {
+                var selectedFiles = ["filename1", "filename2"];
                 if (acceptMultiple)
-                    model.accept(selectedFiles)
+                    model.accept(selectedFiles);
                 else
                     model.accept("acceptedfilename");
-            }
-            else
+            } else
                 model.reject();
         }
     }
@@ -57,12 +59,21 @@ TestWebView {
 
         function test_multiple() {
             webView.selectFile = true;
+            webView.returnEmpty = false;
             webView.acceptMultiple = true;
             openItemSelector()
             titleSpy.wait()
             compare(webView.title, "filename1")
         }
 
+        function test_rejectIfEmptyAccept() {
+            var oldTitle = webView.title
+            webView.selectFile = false;
+            webView.returnEmpty = true;
+            openItemSelector()
+            compare(webView.title, oldTitle)
+        }
+
         function test_reject() {
             var oldTitle = webView.title
             webView.selectFile = false;
index 3ff4f27..3d4c4e6 100644 (file)
@@ -223,6 +223,12 @@ public slots:
     void accept(const QVariant& path)
     {
         QStringList filesPath = path.toStringList();
+
+        if (filesPath.isEmpty()) {
+            emit rejected();
+            return;
+        }
+
         // For single file upload, send only the first element if there are more than one file paths
         if (!m_allowMultiple && filesPath.count() > 1)
             filesPath = QStringList(filesPath.at(0));