<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[243523] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/243523">243523</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2019-03-26 16:24:35 -0700 (Tue, 26 Mar 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add basic layout test coverage for File Picker on iOS
https://bugs.webkit.org/show_bug.cgi?id=196265

Reviewed by Wenson Hsieh.

Source/WebKit:

Add layout test infrastructure to test the file picker on iOS.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _dismissFilePicker]):
* UIProcess/API/Cocoa/WKWebViewPrivate.h:
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView dismissFilePicker]):
(-[WKContentView _contentsOfUserInterfaceItem:]):
* UIProcess/ios/forms/WKFileUploadPanel.h:
* UIProcess/ios/forms/WKFileUploadPanel.mm:
(-[WKFileUploadPanel currentAvailableActionTitles]):

Tools:

Add layout test infrastructure to test the file picker on iOS.

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::dismissFilePicker):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::dismissFilePicker):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::createWebViewWithOptions):
(WTR::updateTestOptionsFromTestHeader):
* WebKitTestRunner/TestOptions.h:
(WTR::TestOptions::hasSameInitializationOptions const):
* WebKitTestRunner/ios/TestControllerIOS.mm:
(overridePresentViewController):
(WTR::TestController::platformInitialize):
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::dismissFilePicker):

LayoutTests:

Add new layout test.

* fast/forms/ios/file-upload-panel-expected.txt: Added.
* fast/forms/ios/file-upload-panel.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoaWKWebViewPrivateh">trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWKContentViewInteractionh">trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosWKContentViewInteractionmm">trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosformsWKFileUploadPanelh">trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosformsWKFileUploadPanelmm">trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreeiosUIScriptControllerIOSmm">trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm</a></li>
<li><a href="#trunkToolsTestRunnerSharedUIScriptContextBindingsUIScriptControlleridl">trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl</a></li>
<li><a href="#trunkToolsTestRunnerSharedUIScriptContextUIScriptControllercpp">trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp</a></li>
<li><a href="#trunkToolsTestRunnerSharedUIScriptContextUIScriptControllerh">trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestControllercpp">trunk/Tools/WebKitTestRunner/TestController.cpp</a></li>
<li><a href="#trunkToolsWebKitTestRunnerTestOptionsh">trunk/Tools/WebKitTestRunner/TestOptions.h</a></li>
<li><a href="#trunkToolsWebKitTestRunneriosTestControllerIOSmm">trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm</a></li>
<li><a href="#trunkToolsWebKitTestRunneriosUIScriptControllerIOSmm">trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastformsiosfileuploadpanelexpectedtxt">trunk/LayoutTests/fast/forms/ios/file-upload-panel-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastformsiosfileuploadpanelhtml">trunk/LayoutTests/fast/forms/ios/file-upload-panel.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/LayoutTests/ChangeLog 2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2019-03-26  Chris Dumez  <cdumez@apple.com>
+
+        Add basic layout test coverage for File Picker on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=196265
+
+        Reviewed by Wenson Hsieh.
+
+        Add new layout test.
+
+        * fast/forms/ios/file-upload-panel-expected.txt: Added.
+        * fast/forms/ios/file-upload-panel.html: Added.
+
</ins><span class="cx"> 2019-03-26  Shawn Roberts  <sroberts@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Layout tests editing/deleting/delete-emoji-1.html
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsiosfileuploadpanelexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/ios/file-upload-panel-expected.txt (0 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/ios/file-upload-panel-expected.txt                          (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/file-upload-panel-expected.txt     2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -0,0 +1,39 @@
</span><ins>+Basic testing for the File Upload Panel on iOS.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+* accept = 
+PASS areArraysEqual(items, ["Photo Library", "Take Photo or Video", "Browse"]) is true
+
+* accept = image/*
+PASS areArraysEqual(items, ["Photo Library", "Take Photo", "Browse"]) is true
+
+* accept = video/*
+PASS areArraysEqual(items, ["Photo Library", "Take Video", "Browse"]) is true
+
+* accept = image/*, video/*
+PASS areArraysEqual(items, ["Photo Library", "Take Photo or Video", "Browse"]) is true
+
+* accept = .PNG, .GIF
+PASS areArraysEqual(items, ["Photo Library", "Take Photo", "Browse"]) is true
+
+* accept = .PNG, .GIF, .MOV
+PASS areArraysEqual(items, ["Photo Library", "Take Photo or Video", "Browse"]) is true
+
+* accept = audio/*
+PASS areArraysEqual(items, ["Browse"]) is true
+
+* accept = .TXT
+PASS areArraysEqual(items, ["Browse"]) is true
+
+* accept = .PDF
+PASS areArraysEqual(items, ["Browse"]) is true
+
+* accept = .PDF, .TXT
+PASS areArraysEqual(items, ["Browse"]) is true
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastformsiosfileuploadpanelhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/forms/ios/file-upload-panel.html (0 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/ios/file-upload-panel.html                          (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/file-upload-panel.html     2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -0,0 +1,90 @@
</span><ins>+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true, shouldHandleRunOpenPanel=false ] -->
+<html>
+<head>
+<meta name="viewport" content="width=device-width">
+<script src="../../../resources/js-test.js"></script>
+<script src="../../../resources/ui-helper.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<input id="testInput" type="file">
+<div id="console"></div>
+<script>
+description("Basic testing for the File Upload Panel on iOS.");
+jsTestIsAsync = true;
+
+function getFileUploadPickerMenuItemsScript()
+{ 
+    return `
+    (function() {
+        return JSON.stringify(uiController.contentsOfUserInterfaceItem('fileUploadPanelMenu'));
+    })();`
+}
+
+function dismissFilePickerScript()
+{
+    return `
+    (function() {
+        uiController.dismissFilePicker(function() {
+            uiController.uiScriptComplete();
+        });
+    })();`
+}
+
+function getFileUploadPickerMenuItems()
+{
+    return new Promise((resolve) => {
+        testRunner.runUIScript(getFileUploadPickerMenuItemsScript(), function(result) {
+            resolve(JSON.parse(result).fileUploadPanelMenu);
+        });
+    });
+}
+
+function dismissFilePicker()
+{
+    const uiScript = `uiController.dismissFilePicker(() => uiController.uiScriptComplete())`;
+    return new Promise(resolve => testRunner.runUIScript(uiScript, resolve));
+}
+
+function runAcceptTest(accept, expectedMenuItems)
+{
+    return new Promise((resolve) => {
+        debug("* accept = " + accept);
+        testInput.accept = accept;
+
+        UIHelper.activateElement(testInput).then(() => {
+            getFileUploadPickerMenuItems().then((_items) => {
+                items = _items;
+                shouldBeTrue("areArraysEqual(items, " + expectedMenuItems + ")");
+                debug("");
+                dismissFilePicker().then(() => { resolve(); });
+            });
+        });
+    });
+}
+
+async function runTests()
+{
+    document.getElementById("console").style = "display: none";
+
+    await runAcceptTest("", '["Photo Library", "Take Photo or Video", "Browse"]');
+    await runAcceptTest("image/*", '["Photo Library", "Take Photo", "Browse"]');
+    await runAcceptTest("video/*", '["Photo Library", "Take Video", "Browse"]');
+    await runAcceptTest("image/*, video/*", '["Photo Library", "Take Photo or Video", "Browse"]');
+    await runAcceptTest(".PNG, .GIF", '["Photo Library", "Take Photo", "Browse"]');
+    await runAcceptTest(".PNG, .GIF, .MOV", '["Photo Library", "Take Photo or Video", "Browse"]');
+    await runAcceptTest("audio/*", '["Browse"]');
+    await runAcceptTest(".TXT", '["Browse"]');
+    await runAcceptTest(".PDF", '["Browse"]');
+    await runAcceptTest(".PDF, .TXT", '["Browse"]');
+
+    document.getElementById("console").style = "";
+    finishJSTest();
+}
+
+
+onload = runTests;
+
+</script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Source/WebKit/ChangeLog       2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2019-03-26  Chris Dumez  <cdumez@apple.com>
+
+        Add basic layout test coverage for File Picker on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=196265
+
+        Reviewed by Wenson Hsieh.
+
+        Add layout test infrastructure to test the file picker on iOS.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _dismissFilePicker]):
+        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView dismissFilePicker]):
+        (-[WKContentView _contentsOfUserInterfaceItem:]):
+        * UIProcess/ios/forms/WKFileUploadPanel.h:
+        * UIProcess/ios/forms/WKFileUploadPanel.mm:
+        (-[WKFileUploadPanel currentAvailableActionTitles]):
+
</ins><span class="cx"> 2019-03-26  Daniel Bates  <dabates@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [iOS][WK2] Use a better concept to describe the reason we defer zooming a focused element: selectabiltiy
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm     2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm        2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -6669,6 +6669,11 @@
</span><span class="cx">     [_contentView accessoryDone];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)_dismissFilePicker
+{
+    [_contentView dismissFilePicker];
+}
+
</ins><span class="cx"> - (void)setTimePickerValueToHour:(NSInteger)hour minute:(NSInteger)minute
</span><span class="cx"> {
</span><span class="cx">     [_contentView setTimePickerValueToHour:hour minute:minute];
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoaWKWebViewPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h       2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h  2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -451,6 +451,7 @@
</span><span class="cx"> - (void)keyboardAccessoryBarNext WK_API_AVAILABLE(ios(10.0));
</span><span class="cx"> - (void)keyboardAccessoryBarPrevious WK_API_AVAILABLE(ios(10.0));
</span><span class="cx"> - (void)dismissFormAccessoryView WK_API_AVAILABLE(ios(10.3));
</span><ins>+- (void)_dismissFilePicker WK_API_AVAILABLE(ios(WK_IOS_TBA));
</ins><span class="cx"> - (void)selectFormAccessoryPickerRow:(int)rowIndex WK_API_AVAILABLE(ios(10.3));
</span><span class="cx"> @property (nonatomic, readonly) NSString *textContentTypeForTesting WK_API_AVAILABLE(ios(12.0));
</span><span class="cx"> @property (nonatomic, readonly) NSString *selectFormPopoverTitle WK_API_AVAILABLE(ios(12.0));
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWKContentViewInteractionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h     2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h        2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -430,6 +430,7 @@
</span><span class="cx"> - (void)_showRunOpenPanel:(API::OpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
</span><span class="cx"> - (void)_showShareSheet:(const WebCore::ShareDataWithParsedURL&)shareData completionHandler:(WTF::CompletionHandler<void(bool)>&&)completionHandler;
</span><span class="cx"> - (void)accessoryDone;
</span><ins>+- (void)dismissFilePicker;
</ins><span class="cx"> - (void)_didHandleKeyEvent:(::WebEvent *)event eventWasHandled:(BOOL)eventWasHandled;
</span><span class="cx"> - (Vector<WebKit::OptionItem>&) focusedSelectElementOptions;
</span><span class="cx"> - (void)_enableInspectorNodeSearch;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosWKContentViewInteractionmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm    2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm       2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -4509,6 +4509,11 @@
</span><span class="cx">     return NO;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)dismissFilePicker
+{
+    [_fileUploadPanel dismiss];
+}
+
</ins><span class="cx"> - (BOOL)isScrollableForKeyboardScrollViewAnimator:(WKKeyboardScrollViewAnimator *)animator
</span><span class="cx"> {
</span><span class="cx">     if (_page->editorState().isContentEditable)
</span><span class="lines">@@ -7019,6 +7024,12 @@
</span><span class="cx">         return @{ userInterfaceItem: @{ @"pageURL": url } };
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><ins>+
+    if ([userInterfaceItem isEqualToString:@"fileUploadPanelMenu"]) {
+        if (!_fileUploadPanel)
+            return @{ userInterfaceItem: @[] };
+        return @{ userInterfaceItem: [_fileUploadPanel currentAvailableActionTitles] };
+    }
</ins><span class="cx">     
</span><span class="cx">     return nil;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosformsWKFileUploadPanelh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.h (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.h      2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.h 2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -43,6 +43,8 @@
</span><span class="cx"> - (instancetype)initWithView:(WKContentView *)view;
</span><span class="cx"> - (void)presentWithParameters:(API::OpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
</span><span class="cx"> - (void)dismiss;
</span><ins>+
+- (NSArray<NSString *> *)currentAvailableActionTitles;
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @protocol WKFileUploadPanelDelegate <NSObject>
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosformsWKFileUploadPanelmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm     2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm        2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -312,6 +312,26 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (NSArray<NSString *> *)currentAvailableActionTitles
+{
+    NSMutableArray<NSString *> *actionTitles = [NSMutableArray array];
+
+    NSArray *mediaTypes = UTIsForMIMETypes(_mimeTypes.get()).allObjects;
+    BOOL containsImageMediaType = !mediaTypes.count || arrayContainsUTIThatConformsTo(mediaTypes, kUTTypeImage);
+    BOOL containsVideoMediaType = !mediaTypes.count || arrayContainsUTIThatConformsTo(mediaTypes, kUTTypeMovie);
+    if (containsImageMediaType || containsVideoMediaType) {
+        [actionTitles addObject:@"Photo Library"];
+        if (containsImageMediaType && containsVideoMediaType)
+            [actionTitles addObject:@"Take Photo or Video"];
+        else if (containsVideoMediaType)
+            [actionTitles addObject:@"Take Video"];
+        else
+            [actionTitles addObject:@"Take Photo"];
+    }
+    [actionTitles addObject:@"Browse"];
+    return actionTitles;
+}
+
</ins><span class="cx"> #pragma mark - Media Types
</span><span class="cx"> 
</span><span class="cx"> static NSSet<NSString *> *UTIsForMIMETypes(NSArray *mimeTypes)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog    2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Tools/ChangeLog       2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -1,3 +1,29 @@
</span><ins>+2019-03-26  Chris Dumez  <cdumez@apple.com>
+
+        Add basic layout test coverage for File Picker on iOS
+        https://bugs.webkit.org/show_bug.cgi?id=196265
+
+        Reviewed by Wenson Hsieh.
+
+        Add layout test infrastructure to test the file picker on iOS.
+
+        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::dismissFilePicker):
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+        (WTR::UIScriptController::dismissFilePicker):
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::createWebViewWithOptions):
+        (WTR::updateTestOptionsFromTestHeader):
+        * WebKitTestRunner/TestOptions.h:
+        (WTR::TestOptions::hasSameInitializationOptions const):
+        * WebKitTestRunner/ios/TestControllerIOS.mm:
+        (overridePresentViewController):
+        (WTR::TestController::platformInitialize):
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::dismissFilePicker):
+
</ins><span class="cx"> 2019-03-26  Wenson Hsieh  <wenson_hsieh@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Implement async paste method on UIWKInteractionViewProtocol
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreeiosUIScriptControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm  2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm     2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -175,6 +175,10 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UIScriptController::dismissFilePicker(JSValueRef)
+{
+}
+
</ins><span class="cx"> void UIScriptController::setTimePickerValue(long, long)
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsTestRunnerSharedUIScriptContextBindingsUIScriptControlleridl"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl     2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl        2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -187,6 +187,8 @@
</span><span class="cx">     // Equivalent of pressing the Done button in the form accessory bar.
</span><span class="cx">     void dismissFormAccessoryView();
</span><span class="cx"> 
</span><ins>+    void dismissFilePicker(object callback);
+
</ins><span class="cx">     readonly attribute DOMString textContentType;
</span><span class="cx"> 
</span><span class="cx">     // Form control handling
</span></span></pre></div>
<a id="trunkToolsTestRunnerSharedUIScriptContextUIScriptControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp      2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp 2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -347,6 +347,10 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UIScriptController::dismissFilePicker(JSValueRef)
+{
+}
+
</ins><span class="cx"> void UIScriptController::setTimePickerValue(long, long)
</span><span class="cx"> {
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsTestRunnerSharedUIScriptContextUIScriptControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h        2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h   2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -106,6 +106,7 @@
</span><span class="cx"> 
</span><span class="cx">     void applyAutocorrection(JSStringRef newString, JSStringRef oldString, JSValueRef callback);
</span><span class="cx">     
</span><ins>+    void dismissFilePicker(JSValueRef callback);
</ins><span class="cx">     void dismissFormAccessoryView();
</span><span class="cx">     void selectFormAccessoryPickerRow(long);
</span><span class="cx">     JSRetainPtr<JSStringRef> textContentType() const;
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestController.cpp  2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp     2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -607,7 +607,7 @@
</span><span class="cx">         0, // didDraw
</span><span class="cx">         0, // pageDidScroll
</span><span class="cx">         0, // exceededDatabaseQuota,
</span><del>-        runOpenPanel,
</del><ins>+        options.shouldHandleRunOpenPanel ? runOpenPanel : 0,
</ins><span class="cx">         decidePolicyForGeolocationPermissionRequest,
</span><span class="cx">         0, // headerHeight
</span><span class="cx">         0, // footerHeight
</span><span class="lines">@@ -1316,6 +1316,8 @@
</span><span class="cx">             testOptions.editable = parseBooleanTestHeaderValue(value);
</span><span class="cx">         else if (key == "enableUndoManagerAPI")
</span><span class="cx">             testOptions.enableUndoManagerAPI = parseBooleanTestHeaderValue(value);
</span><ins>+        else if (key == "shouldHandleRunOpenPanel")
+            testOptions.shouldHandleRunOpenPanel = parseBooleanTestHeaderValue(value);
</ins><span class="cx">         else if (key == "contentInset.top")
</span><span class="cx">             testOptions.contentInsetTop = std::stod(value);
</span><span class="cx">         else if (key == "ignoreSynchronousMessagingTimeouts")
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunnerTestOptionsh"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/TestOptions.h       2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h  2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -89,6 +89,7 @@
</span><span class="cx">     bool enableEditableImages { false };
</span><span class="cx">     bool editable { false };
</span><span class="cx">     bool enableUndoManagerAPI { false };
</span><ins>+    bool shouldHandleRunOpenPanel { true };
</ins><span class="cx"> 
</span><span class="cx">     double contentInsetTop { 0 };
</span><span class="cx"> 
</span><span class="lines">@@ -136,6 +137,7 @@
</span><span class="cx">             || enableEditableImages != options.enableEditableImages
</span><span class="cx">             || editable != options.editable
</span><span class="cx">             || enableUndoManagerAPI != options.enableUndoManagerAPI
</span><ins>+            || shouldHandleRunOpenPanel != options.shouldHandleRunOpenPanel
</ins><span class="cx">             || contentInsetTop != options.contentInsetTop)
</span><span class="cx">             return false;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunneriosTestControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm    2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm       2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -50,6 +50,10 @@
</span><span class="cx">     return NO;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static void overridePresentViewControllerOrPopover()
+{
+}
+
</ins><span class="cx"> namespace WTR {
</span><span class="cx"> 
</span><span class="cx"> static bool isDoneWaitingForKeyboardToDismiss = true;
</span><span class="lines">@@ -96,6 +100,9 @@
</span><span class="cx">     // Override the implementation of +[UIKeyboard isInHardwareKeyboardMode] to ensure that test runs are deterministic
</span><span class="cx">     // regardless of whether a hardware keyboard is attached. We intentionally never restore the original implementation.
</span><span class="cx">     method_setImplementation(class_getClassMethod([UIKeyboard class], @selector(isInHardwareKeyboardMode)), reinterpret_cast<IMP>(overrideIsInHardwareKeyboardMode));
</span><ins>+
+    method_setImplementation(class_getInstanceMethod([UIViewController class], @selector(presentViewController:animated:completion:)), reinterpret_cast<IMP>(overridePresentViewControllerOrPopover));
+    method_setImplementation(class_getInstanceMethod([UIPopoverController class], @selector(presentPopoverFromRect:inView:permittedArrowDirections:animated:)), reinterpret_cast<IMP>(overridePresentViewControllerOrPopover));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TestController::platformDestroy()
</span></span></pre></div>
<a id="trunkToolsWebKitTestRunneriosUIScriptControllerIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (243522 => 243523)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm        2019-03-26 22:59:28 UTC (rev 243522)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm   2019-03-26 23:24:35 UTC (rev 243523)
</span><span class="lines">@@ -482,6 +482,19 @@
</span><span class="cx">     [webView dismissFormAccessoryView];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void UIScriptController::dismissFilePicker(JSValueRef callback)
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+    [webView _dismissFilePicker];
+
+    // Round-trip with the WebProcess to make sure it has been notified of the dismissal.
+    unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
+    [webView evaluateJavaScript:@"" completionHandler:^(id result, NSError *error) {
+        if (m_context)
+            m_context->asyncTaskComplete(callbackID);
+    }];
+}
+
</ins><span class="cx"> JSRetainPtr<JSStringRef> UIScriptController::selectFormPopoverTitle() const
</span><span class="cx"> {
</span><span class="cx">     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
</span></span></pre>
</div>
</div>

</body>
</html>