REGRESSION (iOS 13): Trying to record just audio using HTML Media Capture crashes...
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Sep 2019 03:00:10 +0000 (03:00 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Sep 2019 03:00:10 +0000 (03:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=202039
<rdar://problem/55566628>

Reviewed by Jer Noble.

Source/WebKit:

* UIProcess/ios/forms/WKFileUploadPanel.mm:
(-[WKFileUploadPanel _mediaTypesForPickerSourceType:]): UIImagePickerController doesn't
support audio-only recording, so show the video recorder for "audio/*".

LayoutTests:

* fast/forms/ios/file-upload-panel-capture-expected.txt: Added.
* fast/forms/ios/file-upload-panel-capture.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/forms/ios/file-upload-panel-capture-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/ios/file-upload-panel-capture.html [new file with mode: 0644]
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/ios/forms/WKFileUploadPanel.mm

index 4bcd046..65e4c62 100644 (file)
@@ -1,3 +1,14 @@
+2019-09-26  Eric Carlson  <eric.carlson@apple.com>
+
+        REGRESSION (iOS 13): Trying to record just audio using HTML Media Capture crashes Safari
+        https://bugs.webkit.org/show_bug.cgi?id=202039
+        <rdar://problem/55566628>
+
+        Reviewed by Jer Noble.
+
+        * fast/forms/ios/file-upload-panel-capture-expected.txt: Added.
+        * fast/forms/ios/file-upload-panel-capture.html: Added.
+
 2019-09-26  Russell Epstein  <repstein@apple.com>
 
         [ iOS ] Layout Test scrollingcoordinator/ios/fixed-scrolling-with-keyboard.html is a Flaky Failure
diff --git a/LayoutTests/fast/forms/ios/file-upload-panel-capture-expected.txt b/LayoutTests/fast/forms/ios/file-upload-panel-capture-expected.txt
new file mode 100644 (file)
index 0000000..0e76842
--- /dev/null
@@ -0,0 +1,15 @@
+Test that the iOS File Upload Panel doesn't crash when the 'capture' is present.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+* accept = image/*
+
+* accept = video/*
+
+* accept = audio/*
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/forms/ios/file-upload-panel-capture.html b/LayoutTests/fast/forms/ios/file-upload-panel-capture.html
new file mode 100644 (file)
index 0000000..83fc03d
--- /dev/null
@@ -0,0 +1,52 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true, shouldHandleRunOpenPanel=false, shouldPresentPopovers=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" capture>
+<div id="console"></div>
+<script>
+description("Test that the iOS File Upload Panel doesn't crash when the 'capture' is present.");
+jsTestIsAsync = true;
+
+function dismissFilePicker()
+{
+    const uiScript = `uiController.dismissFilePicker(() => uiController.uiScriptComplete())`;
+    return new Promise(resolve => testRunner.runUIScript(uiScript, resolve));
+}
+
+function runCaptureTest(accept)
+{
+    return new Promise((resolve) => {
+        debug("* accept = " + accept);
+        testInput.accept = accept;
+
+        UIHelper.activateElement(testInput).then(() => {
+            debug("");
+            dismissFilePicker().then(() => { resolve(); });
+        });
+    });
+}
+
+async function runTests()
+{
+    document.getElementById("console").style = "display: none";
+
+    await runCaptureTest("image/*");
+    await runCaptureTest("video/*");
+    await runCaptureTest("audio/*");
+
+    document.getElementById("console").style = "";
+    finishJSTest();
+}
+
+
+onload = runTests;
+
+</script>
+</body>
+</html>
index d5c3159..19e235b 100644 (file)
@@ -1,3 +1,15 @@
+2019-09-26  Eric Carlson  <eric.carlson@apple.com>
+
+        REGRESSION (iOS 13): Trying to record just audio using HTML Media Capture crashes Safari
+        https://bugs.webkit.org/show_bug.cgi?id=202039
+        <rdar://problem/55566628>
+
+        Reviewed by Jer Noble.
+
+        * UIProcess/ios/forms/WKFileUploadPanel.mm:
+        (-[WKFileUploadPanel _mediaTypesForPickerSourceType:]): UIImagePickerController doesn't 
+        support audio-only recording, so show the video recorder for "audio/*".
+
 2019-09-26  Tim Horton  <timothy_horton@apple.com>
 
         Add some logging to help diagnose blank or stuck WKWebViews
index 7c37e93..d6f5787 100644 (file)
@@ -343,7 +343,9 @@ static NSSet<NSString *> *UTIsForMIMETypes(NSArray *mimeTypes)
         else if ([mimeType caseInsensitiveCompare:@"video/*"] == NSOrderedSame)
             [mediaTypes addObject:(__bridge NSString *)kUTTypeMovie];
         else if ([mimeType caseInsensitiveCompare:@"audio/*"] == NSOrderedSame)
-            [mediaTypes addObject:(__bridge NSString *)kUTTypeAudio];
+            // UIImagePickerController doesn't allow audio-only recording, so show the video
+            // recorder for "audio/*".
+            [mediaTypes addObject:(__bridge NSString *)kUTTypeMovie];
         else {
             auto uti = WebCore::UTIFromMIMEType(mimeType);
             if (!uti.isEmpty())
@@ -371,7 +373,10 @@ static NSSet<NSString *> *UTIsForMIMETypes(NSArray *mimeTypes)
                 }
             }
         }
-        return mediaTypes;
+
+        ASSERT(mediaTypes.count);
+        if (mediaTypes.count)
+            return mediaTypes;
     }
 
     // Fallback to every supported media type if there is no filter.