[iOS] Need a test for bug #145539: Uploading an animated GIF from the
[WebKit-https.git] / ManualTests / ios / image-file-uploads-as-original-type.html
1 <!DOCTYPE html>
2 <html>
3     <head>
4         <script>
5             const GIFSignature = "GIF89a";
6
7             function runTest(fileControl) {
8                 var reader = new FileReader();
9                 reader.onload = function(e) {
10                     var arrayBuffer = reader.result;
11                     if (!arrayBuffer || arrayBuffer.byteLength < GIFSignature.length) {
12                         document.getElementById("console").textContent = "TEST FAILED. Failed to get array buffer for file.";
13                         return;
14                     }
15                     var view = new Uint8Array(arrayBuffer, 0, GIFSignature.length);
16                     var signature = Array.prototype.map.call(view, function(value) { return String.fromCharCode(value); }).join('');
17                     if (signature !== GIFSignature) {
18                         document.getElementById("console").textContent = "TEST FAILED. File was not of correct type.";
19                         return;
20                     }
21                     document.getElementById("console").textContent = "TEST PASSED";
22                 }
23                 reader.readAsArrayBuffer(fileControl.files[0]);
24             }
25         </script>
26     </head>
27     <body>
28         <div>
29             This is a test for Bug #<a href="http://trac.webkit.org/changeset/185241">185241</a>: [iOS] Uploading an animated GIF from the photo library uploads a JPEG.
30             <br><br>
31             This test should be run on iOS. If the test passes, TEST PASSED will appear below.
32             <br><br>
33             <div id="console">Waiting on test to complete...</div>
34             <br><br>
35         </div>
36         <div>
37             Long-press on this image, and save it to your photo library:
38             <img src="../resources/non-animated.gif">
39         </div>
40         <br>
41         <div>
42             Tap "Choose File," and select the image from your photo library:
43             <input type="file" onchange="runTest(this)">
44         </div>
45     </body>
46 </html>