Add ability to WPT-test file uploads and fetches, fixes #12322

This commit is contained in:
Zhen Zhang 2016-07-08 19:52:10 +08:00
parent c2a22bd05e
commit 5e051c08f6
9 changed files with 168 additions and 71 deletions

View file

@ -40,7 +40,7 @@ fn test_filemanager() {
{
// Try to select a dummy file "tests/unit/net/test.txt"
let (tx, rx) = ipc::channel().unwrap();
chan.send(FileManagerThreadMsg::SelectFile(patterns.clone(), tx, origin.clone())).unwrap();
chan.send(FileManagerThreadMsg::SelectFile(patterns.clone(), tx, origin.clone(), None)).unwrap();
let selected = rx.recv().expect("Broken channel")
.expect("The file manager failed to find test.txt");
@ -88,7 +88,7 @@ fn test_filemanager() {
{
let (tx, rx) = ipc::channel().unwrap();
let _ = chan.send(FileManagerThreadMsg::SelectFile(patterns.clone(), tx, origin.clone()));
let _ = chan.send(FileManagerThreadMsg::SelectFile(patterns.clone(), tx, origin.clone(), None));
assert!(rx.try_recv().is_err(), "The thread should not respond normally after exited");
}

View file

@ -6456,6 +6456,12 @@
"url": "/_mozilla/mozilla/event_listener.html"
}
],
"mozilla/file_upload.html": [
{
"path": "mozilla/file_upload.html",
"url": "/_mozilla/mozilla/file_upload.html"
}
],
"mozilla/focus_blur.html": [
{
"path": "mozilla/focus_blur.html",

View file

@ -0,0 +1,3 @@
[file_upload.html]
type: testharness
prefs: [dom.testing.htmlinputelement.select_files.enabled:true]

View file

@ -0,0 +1,31 @@
<!doctype html>
<meta charset="utf-8">
<title>Test of uploading a file through input element</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body><input id="file-input" type="file"></body>
<script>
async_test(function() {
var e = document.getElementById("file-input");
assert_true(e.selectFiles != undefined, "selectFiles is not defined")
e.selectFiles(["./tests/wpt/mozilla/tests/mozilla/test.txt"]);
assert_true(e.files.length > 0, "test.txt is not selected");
var reader = new FileReader;
reader.onloadend = this.step_func(function(evt) {
assert_equals(evt.target.result, "hello, servo\n");
this.done();
});
reader.readAsText(e.files[0]);
}, "Select a file");
</script>

View file

@ -0,0 +1 @@
hello, servo