Skip to content
Permalink
Browse files
CB-8017 Add manual test for <input type=file>
  • Loading branch information
agrieve committed Jan 19, 2015
1 parent 16019c5 commit d6b17a79bd0449e5f706d5d58372b307c38f65e2
Showing 2 changed files with 48 additions and 0 deletions.
@@ -43,4 +43,7 @@

<js-module src="tests/whitelist.tests.js" name="whitelist.tests">
</js-module>

<js-module src="tests/input.tests.js" name="input.tests">
</js-module>
</plugin>
@@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/


exports.defineManualTests = function (contentEl, createActionButton) {
contentEl.innerHTML = '<h1>Tests for &lt;input type="file"&gt;</h1>' +
'regular: <input type="file"><br>' +
'multiple: <input type="file"><br>' +
'photos only: <input type="file"><br>' +
'video only: <input type="file"><br>' +
'audio only: <input type="file"><br>' +
'multiple photos: <input type="file"><br>' +
'.txt only: <input type="file"><br>' +
'<img style="max-width:400px; max-height:200px; border:1px solid black">';
function logOnChange(e) {
var el = e.target;
console.log('Got result for input "' + el.value + '": ' + JSON.stringify(el.files));
var firstFile = el.files && el.files[0];
if (firstFile && firstFile.type.match('image.*')) {
contentEl.querySelector('img').src = URL.createObjectURL(firstFile);
} else {
contentEl.querySelector('img').src = 'about:blank';
}
}
var els = contentEl.querySelectorAll('input');
for (var i = 0; i < els.length; ++i) {
els[i].onchange = logOnChange;
}
};

0 comments on commit d6b17a7

Please sign in to comment.