mirror of
https://github.com/servo/servo.git
synced 2025-09-09 22:48:21 +01:00
Add ability to WPT-test file uploads and fetches, fixes #12322
This commit is contained in:
parent
c2a22bd05e
commit
5e051c08f6
9 changed files with 168 additions and 71 deletions
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
3
tests/wpt/mozilla/meta/mozilla/file_upload.html.ini
Normal file
3
tests/wpt/mozilla/meta/mozilla/file_upload.html.ini
Normal file
|
@ -0,0 +1,3 @@
|
|||
[file_upload.html]
|
||||
type: testharness
|
||||
prefs: [dom.testing.htmlinputelement.select_files.enabled:true]
|
31
tests/wpt/mozilla/tests/mozilla/file_upload.html
Normal file
31
tests/wpt/mozilla/tests/mozilla/file_upload.html
Normal 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>
|
1
tests/wpt/mozilla/tests/mozilla/test.txt
Normal file
1
tests/wpt/mozilla/tests/mozilla/test.txt
Normal file
|
@ -0,0 +1 @@
|
|||
hello, servo
|
Loading…
Add table
Add a link
Reference in a new issue