Implement FileReader.{readAsText,readAsDataUrl}. Fixes #6172

This commit is contained in:
farodin91 2015-07-23 22:33:51 +02:00
parent f44d75e5b2
commit 27e760e28d
20 changed files with 565 additions and 326 deletions

View file

@ -9,6 +9,8 @@ use dom::bindings::utils::{Reflector, reflect_dom_object};
use dom::bindings::error::Fallible;
use dom::bindings::codegen::Bindings::BlobBinding;
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
use std::sync::mpsc;
use std::sync::mpsc::Receiver;
use util::str::DOMString;
@ -79,6 +81,22 @@ impl Blob {
}
}
pub trait BlobHelpers {
fn read_out_buffer(self) -> Receiver<Option<Vec<u8>>> ;
fn read_out_type(self) -> DOMString;
}
impl<'a> BlobHelpers for &'a Blob {
fn read_out_buffer(self) -> Receiver<Option<Vec<u8>>> {
let (send, recv) = mpsc::channel();
send.send(self.bytes.clone()).unwrap();
recv
}
fn read_out_type(self) -> DOMString {
self.typeString.clone()
}
}
impl<'a> BlobMethods for &'a Blob {
// http://dev.w3.org/2006/webapi/FileAPI/#dfn-size
fn Size(self) -> u64{

View file

@ -48,6 +48,7 @@ pub enum EventTargetTypeId {
WebSocket,
Window,
Worker,
FileReader,
WorkerGlobalScope(WorkerGlobalScopeTypeId),
XMLHttpRequestEventTarget(XMLHttpRequestEventTargetTypeId)
}

View file

@ -0,0 +1,491 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::Bindings::FileReaderBinding;
use dom::bindings::codegen::Bindings::FileReaderBinding::{FileReaderConstants, FileReaderMethods};
use dom::bindings::codegen::InheritTypes::{EventCast, EventTargetCast};
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::error::Error::InvalidState;
use dom::bindings::global::{GlobalRef, GlobalField};
use dom::bindings::js::{Root, JS, MutNullableHeap};
use dom::bindings::refcounted::Trusted;
use dom::bindings::utils::{reflect_dom_object, Reflectable};
use dom::event::{EventHelpers, EventCancelable, EventBubbles};
use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
use dom::blob::Blob;
use dom::blob::BlobHelpers;
use dom::domexception::{DOMException, DOMErrorName};
use dom::progressevent::ProgressEvent;
use encoding::all::UTF_8;
use encoding::types::{EncodingRef, DecoderTrap};
use encoding::label::encoding_from_whatwg_label;
use hyper::mime::{Mime, Attr};
use script_task::{ScriptChan, ScriptMsg, Runnable, ScriptPort};
use std::cell::{Cell, RefCell};
use std::sync::mpsc::Receiver;
use util::str::DOMString;
use util::task::spawn_named;
use rustc_serialize::base64::{Config, ToBase64, CharacterSet, Newline};
#[derive(PartialEq, Clone, Copy, JSTraceable)]
pub enum FileReaderFunction {
ReadAsText,
ReadAsDataUrl,
}
pub type TrustedFileReader = Trusted<FileReader>;
pub struct ReadData {
pub bytes: Receiver<Option<Vec<u8>>>,
pub blobtype: DOMString,
pub label: Option<DOMString>,
pub function: FileReaderFunction
}
impl ReadData {
pub fn new(bytes: Receiver<Option<Vec<u8>>>, blobtype: DOMString,
label: Option<DOMString>, function: FileReaderFunction) -> ReadData {
ReadData {
bytes: bytes,
blobtype: blobtype,
label: label,
function: function,
}
}
}
#[derive(Clone)]
pub struct BlobBody {
pub bytes: Vec<u8>,
pub blobtype: DOMString,
pub label: Option<DOMString>,
pub function: FileReaderFunction
}
impl BlobBody {
pub fn new(bytes: Vec<u8>, blobtype: DOMString,
label: Option<DOMString>, function: FileReaderFunction) -> BlobBody {
BlobBody {
bytes: bytes,
blobtype: blobtype,
label: label,
function: function,
}
}
}
#[derive(PartialEq, Clone, Copy, JSTraceable)]
pub struct GenerationId(u32);
#[repr(u16)]
#[derive(Copy, Clone, Debug, PartialEq, JSTraceable)]
pub enum FileReaderReadyState {
Empty = FileReaderConstants::EMPTY,
Loading = FileReaderConstants::LOADING,
Done = FileReaderConstants::DONE,
}
#[dom_struct]
pub struct FileReader {
eventtarget: EventTarget,
global: GlobalField,
ready_state: Cell<FileReaderReadyState>,
error: MutNullableHeap<JS<DOMException>>,
result: RefCell<Option<DOMString>>,
generation_id: Cell<GenerationId>,
}
impl FileReader {
pub fn new_inherited(global: GlobalRef) -> FileReader {
FileReader {
eventtarget: EventTarget::new_inherited(EventTargetTypeId::FileReader),//?
global: GlobalField::from_rooted(&global),
ready_state: Cell::new(FileReaderReadyState::Empty),
error: MutNullableHeap::new(None),
result: RefCell::new(None),
generation_id: Cell::new(GenerationId(0)),
}
}
pub fn new(global: GlobalRef) -> Root<FileReader> {
reflect_dom_object(box FileReader::new_inherited(global),
global, FileReaderBinding::Wrap)
}
pub fn Constructor(global: GlobalRef) -> Fallible<Root<FileReader>> {
Ok(FileReader::new(global))
}
//https://w3c.github.io/FileAPI/#dfn-error-steps
pub fn process_read_error(filereader: TrustedFileReader, gen_id: GenerationId, error: DOMErrorName) {
let fr = filereader.root();
macro_rules! return_on_abort(
() => (
if gen_id != fr.generation_id.get() {
return
}
);
);
return_on_abort!();
// Step 1
fr.change_ready_state(FileReaderReadyState::Done);
*fr.result.borrow_mut() = None;
let global = fr.global.root();
let exception = DOMException::new(global.r(), error);
fr.error.set(Some(JS::from_rooted(&exception)));
fr.dispatch_progress_event("error".to_owned(), 0, None);
return_on_abort!();
// Step 3
fr.dispatch_progress_event("loadend".to_owned(), 0, None);
return_on_abort!();
// Step 4
fr.terminate_ongoing_reading();
}
// https://w3c.github.io/FileAPI/#dfn-readAsText
pub fn process_read_data(filereader: TrustedFileReader, gen_id: GenerationId) {
let fr = filereader.root();
macro_rules! return_on_abort(
() => (
if gen_id != fr.generation_id.get() {
return
}
);
);
return_on_abort!();
//FIXME Step 7 send current progress
fr.dispatch_progress_event("progress".to_owned(), 0, None);
}
// https://w3c.github.io/FileAPI/#dfn-readAsText
pub fn process_read(filereader: TrustedFileReader, gen_id: GenerationId) {
let fr = filereader.root();
macro_rules! return_on_abort(
() => (
if gen_id != fr.generation_id.get() {
return
}
);
);
return_on_abort!();
// Step 6
fr.dispatch_progress_event("loadstart".to_owned(), 0, None);
}
// https://w3c.github.io/FileAPI/#dfn-readAsText
pub fn process_read_eof(filereader: TrustedFileReader, gen_id: GenerationId, data: Option<BlobBody>) {
let fr = filereader.root();
macro_rules! return_on_abort(
() => (
if gen_id != fr.generation_id.get() {
return
}
);
);
return_on_abort!();
// Step 8.1
fr.change_ready_state(FileReaderReadyState::Done);
// Step 8.2
let output = match data {
Some(blob_body) => {
match blob_body.function {
FileReaderFunction::ReadAsDataUrl =>
FileReader::perform_readasdataurl(blob_body),
FileReaderFunction::ReadAsText =>
FileReader::perform_readastext(blob_body),
}
},
None => {
Ok(None)
}
};
//FIXME handle error if error is possible
*fr.result.borrow_mut() = output.unwrap();
// Step 8.3
fr.dispatch_progress_event("load".to_owned(), 0, None);
return_on_abort!();
// Step 8.4
if fr.ready_state.get() != FileReaderReadyState::Loading {
fr.dispatch_progress_event("loadend".to_owned(), 0, None);
}
return_on_abort!();
// Step 9
fr.terminate_ongoing_reading();
}
// https://w3c.github.io/FileAPI/#dfn-readAsText
fn perform_readastext(blob_body: BlobBody)
-> Result<Option<DOMString>, DOMErrorName> {
//https://w3c.github.io/FileAPI/#encoding-determination
// Steps 1 & 2 & 3
let mut encoding = match blob_body.label {
Some(e) => encoding_from_whatwg_label(&e),
None => None
};
// Step 4 & 5
encoding = match encoding {
Some(e) => Some(e),
None => {
let resultmime = blob_body.blobtype.parse::<Mime>().ok();
resultmime.and_then(|Mime(_, _, ref parameters)| {
parameters.iter()
.find(|&&(ref k, _)| &Attr::Charset == k)
.and_then(|&(_, ref v)| encoding_from_whatwg_label(&v.to_string()))
})
}
};
// Step 6
let enc = match encoding {
Some(code) => code,
None => UTF_8 as EncodingRef
};
let convert = &blob_body.bytes[..];
// Step 7
let output = enc.decode(convert, DecoderTrap::Replace).unwrap();
Ok(Some(output))
}
//https://w3c.github.io/FileAPI/#dfn-readAsDataURL
fn perform_readasdataurl(blob_body: BlobBody)
-> Result<Option<DOMString>, DOMErrorName> {
let config = Config {
char_set: CharacterSet::UrlSafe,
newline: Newline::LF,
pad: true,
line_length: None
};
let base64 = blob_body.bytes.to_base64(config);
let output = if blob_body.blobtype.is_empty() {
format!("data:base64,{}", base64)
} else {
format!("data:{};base64,{}", blob_body.blobtype, base64)
};
Ok(Some(output))
}
}
impl<'a> FileReaderMethods for &'a FileReader {
event_handler!(loadstart, GetOnloadstart, SetOnloadstart);
event_handler!(progress, GetOnprogress, SetOnprogress);
event_handler!(load, GetOnload, SetOnload);
event_handler!(abort, GetOnabort, SetOnabort);
event_handler!(error, GetOnerror, SetOnerror);
event_handler!(loadend, GetOnloadend, SetOnloadend);
//TODO https://w3c.github.io/FileAPI/#dfn-readAsArrayBuffer
//https://w3c.github.io/FileAPI/#dfn-readAsDataURL
fn ReadAsDataURL(self, blob: &Blob) -> ErrorResult {
let global = self.global.root();
// Step 1
if self.ready_state.get() == FileReaderReadyState::Loading {
return Err(InvalidState);
}
//TODO STEP 2 if isClosed implemented in Blob
// Step 3
self.change_ready_state(FileReaderReadyState::Loading);
let bytes = blob.read_out_buffer();
let type_ = blob.read_out_type();
let load_data = ReadData::new(bytes, type_, None, FileReaderFunction::ReadAsDataUrl);
self.read(load_data, global.r())
}
// https://w3c.github.io/FileAPI/#dfn-readAsText
fn ReadAsText(self, blob: &Blob, label:Option<DOMString>) -> ErrorResult {
let global = self.global.root();
// Step 1
if self.ready_state.get() == FileReaderReadyState::Loading {
return Err(InvalidState);
}
//TODO STEP 2 if isClosed implemented in Blob
// Step 3
self.change_ready_state(FileReaderReadyState::Loading);
let bytes = blob.read_out_buffer();
let type_ = blob.read_out_type();
let load_data = ReadData::new(bytes, type_, label, FileReaderFunction::ReadAsText);
self.read(load_data, global.r())
}
// https://w3c.github.io/FileAPI/#dfn-abort
fn Abort(self) {
// Step 2
if self.ready_state.get() == FileReaderReadyState::Loading {
self.change_ready_state(FileReaderReadyState::Done);
}
// Steps 1 & 3
*self.result.borrow_mut() = None;
let global = self.global.root();
let exception = DOMException::new(global.r(), DOMErrorName::AbortError);
self.error.set(Some(JS::from_rooted(&exception)));
self.terminate_ongoing_reading();
// Steps 5 & 6
self.dispatch_progress_event("abort".to_owned(), 0, None);
self.dispatch_progress_event("loadend".to_owned(), 0, None);
}
fn GetError(self) -> Option<Root<DOMException>> {
self.error.get().map(|error| error.root())
}
fn GetResult(self) -> Option<DOMString> {
self.result.borrow().clone()
}
fn ReadyState(self) -> u16 {
self.ready_state.get() as u16
}
}
trait PrivateFileReaderHelpers {
fn dispatch_progress_event(self, type_: DOMString, loaded: u64, total: Option<u64>);
fn terminate_ongoing_reading(self);
fn read(self, read_data: ReadData, global: GlobalRef) -> ErrorResult;
fn change_ready_state(self, state: FileReaderReadyState);
}
impl<'a> PrivateFileReaderHelpers for &'a FileReader {
fn dispatch_progress_event(self, type_: DOMString, loaded: u64, total: Option<u64>) {
let global = self.global.root();
let progressevent = ProgressEvent::new(global.r(),
type_, EventBubbles::DoesNotBubble, EventCancelable::NotCancelable,
total.is_some(), loaded, total.unwrap_or(0));
let target = EventTargetCast::from_ref(self);
let event = EventCast::from_ref(progressevent.r());
event.fire(target);
}
fn terminate_ongoing_reading(self) {
let GenerationId(prev_id) = self.generation_id.get();
self.generation_id.set(GenerationId(prev_id + 1));
}
fn read(self, read_data: ReadData, global: GlobalRef) -> ErrorResult {
let fr = Trusted::new(global.get_cx(), self, global.script_chan());
let gen_id = self.generation_id.get();
let script_chan = global.script_chan();
spawn_named("file reader async operation".to_owned(), move || {
perform_annotated_read_operation(gen_id, read_data, fr, script_chan)
});
Ok(())
}
fn change_ready_state(self, state: FileReaderReadyState) {
self.ready_state.set(state);
}
}
#[derive(Clone)]
pub enum Process {
ProcessRead(TrustedFileReader, GenerationId),
ProcessReadData(TrustedFileReader, GenerationId, DOMString),
ProcessReadError(TrustedFileReader, GenerationId, DOMErrorName),
ProcessReadEOF(TrustedFileReader, GenerationId, Option<BlobBody>)
}
impl Process {
fn call(self, chan: &Box<ScriptChan + Send>) {
let task = box FileReaderEvent::new(self);
chan.send(ScriptMsg::RunnableMsg(task)).unwrap();
}
pub fn handle(process: Process) {
match process {
Process::ProcessRead(filereader, gen_id) => {
FileReader::process_read(filereader, gen_id);
},
Process::ProcessReadData(filereader, gen_id, _) => {
FileReader::process_read_data(filereader, gen_id);
},
Process::ProcessReadError(filereader, gen_id, error) => {
FileReader::process_read_error(filereader, gen_id, error);
},
Process::ProcessReadEOF(filereader, gen_id, blob_body) => {
FileReader::process_read_eof(filereader, gen_id, blob_body);
}
}
}
}
pub struct FileReaderEvent {
process: Process,
}
impl FileReaderEvent {
pub fn new(process: Process) -> FileReaderEvent {
FileReaderEvent {
process: process,
}
}
}
impl Runnable for FileReaderEvent {
fn handler(self: Box<FileReaderEvent>) {
let this = *self;
Process::handle(this.process);
}
}
//https://w3c.github.io/FileAPI/#task-read-operation
fn perform_annotated_read_operation(gen_id: GenerationId, read_data: ReadData,
filereader: TrustedFileReader, script_chan: Box<ScriptChan + Send>) {
let chan = &script_chan;
// Step 4
Process::ProcessRead(filereader.clone(),
gen_id).call(chan);
Process::ProcessReadData(filereader.clone(),
gen_id, DOMString::new()).call(chan);
let output = match read_data.bytes.recv() {
Ok(bytes) => bytes,
Err(_) => {
Process::ProcessReadError(filereader,
gen_id, DOMErrorName::NotFoundError).call(chan);
return;
}
};
let blobtype = read_data.blobtype.clone();
let label = read_data.label.clone();
let blob_body = output.map(|bytes| {
BlobBody::new(bytes, blobtype, label, read_data.function)
});
Process::ProcessReadEOF(filereader, gen_id, blob_body).call(chan);
}

View file

@ -215,6 +215,7 @@ pub mod event;
pub mod eventdispatcher;
pub mod eventtarget;
pub mod file;
pub mod filereader;
pub mod formdata;
pub mod htmlanchorelement;
pub mod htmlappletelement;

View file

@ -0,0 +1,43 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// http://dev.w3.org/2006/webapi/FileAPI/#APIASynch
//typedef (DOMString or ArrayBuffer) FileReaderResult;
[Constructor, Exposed=Window/*,Worker*/]
interface FileReader: EventTarget {
// async read methods
//[Throws]
//void readAsArrayBuffer(Blob blob);
[Throws]
void readAsText(Blob blob, optional DOMString label);
[Throws]
void readAsDataURL(Blob blob);
void abort();
// states
const unsigned short EMPTY = 0;
const unsigned short LOADING = 1;
const unsigned short DONE = 2;
readonly attribute unsigned short readyState;
// File or Blob data
//readonly attribute FileReaderResult? result;
readonly attribute DOMString? result;
readonly attribute DOMException? error;
// event handler attributes
attribute EventHandler onloadstart;
attribute EventHandler onprogress;
attribute EventHandler onload;
attribute EventHandler onabort;
attribute EventHandler onerror;
attribute EventHandler onloadend;
};

View file

@ -1,5 +0,0 @@
[Progress_event_bubbles_cancelable.html]
type: testharness
[Check the values of bubbles and cancelable are false when the progress event is dispatched]
expected: FAIL

View file

@ -9,9 +9,6 @@
[A plain object with a length property should be treated as a sequence for the blobParts argument.]
expected: FAIL
[A String object should be treated as a sequence for the blobParts argument.]
expected: FAIL
[A Uint8Array object should be treated as a sequence for the blobParts argument.]
expected: FAIL
@ -48,9 +45,6 @@
[Passing an element as the blobParts array should work.]
expected: FAIL
[Passing an platform object that supports indexed properties as the blobParts array should work (window).]
expected: FAIL
[Passing an platform object that supports indexed properties as the blobParts array should work (window with custom toString).]
expected: FAIL
@ -75,45 +69,3 @@
[Array with mixed types]
expected: FAIL
[Passing null (index 0) for options should use the defaults.]
expected: FAIL
[Passing null (index 0) for options should use the defaults (with newlines).]
expected: FAIL
[Passing undefined (index 1) for options should use the defaults.]
expected: FAIL
[Passing undefined (index 1) for options should use the defaults (with newlines).]
expected: FAIL
[Passing object "[object Object\]" (index 2) for options should use the defaults.]
expected: FAIL
[Passing object "[object Object\]" (index 2) for options should use the defaults (with newlines).]
expected: FAIL
[Passing object "[object Object\]" (index 3) for options should use the defaults.]
expected: FAIL
[Passing object "[object Object\]" (index 3) for options should use the defaults (with newlines).]
expected: FAIL
[Passing object "/regex/" (index 4) for options should use the defaults.]
expected: FAIL
[Passing object "/regex/" (index 4) for options should use the defaults (with newlines).]
expected: FAIL
[Passing function "function () {}" (index 5) for options should use the defaults.]
expected: FAIL
[Passing function "function () {}" (index 5) for options should use the defaults (with newlines).]
expected: FAIL
[Newlines should not change when endings is 'transparent'.]
expected: FAIL
[Newlines should not change when endings is 'native'.]
expected: FAIL

View file

@ -1,47 +1,8 @@
[Blob-slice.html]
type: testharness
[no-argument Blob slice]
expected: FAIL
[blob1.]
expected: FAIL
[blob2.]
expected: FAIL
[Slicing test: slice (0,0).]
expected: FAIL
[Slicing test: slice (0,1).]
expected: FAIL
[Slicing test: slice (0,2).]
expected: FAIL
[Slicing test: slice (0,3).]
expected: FAIL
[Slicing test: slice (0,4).]
expected: FAIL
[Slicing test: slice (0,5).]
expected: FAIL
[Slicing test: slice (0,6).]
expected: FAIL
[Slicing test: slice (0,7).]
expected: FAIL
[Slicing test: slice (0,8).]
expected: FAIL
[Slicing test: slice (1,0).]
expected: FAIL
[Slicing test: slice (1,1).]
expected: FAIL
[Slicing test: slice (1,2).]
expected: FAIL
@ -60,9 +21,6 @@
[Slicing test: slice (1,7).]
expected: FAIL
[Slicing test: slice (2,0).]
expected: FAIL
[Slicing test: slice (2,1).]
expected: FAIL
@ -87,9 +45,6 @@
[Slicing test: slice (3,4).]
expected: FAIL
[Slicing test: slice (3,5).]
expected: FAIL
[Slicing test: slice (4,0).]
expected: FAIL
@ -150,9 +105,6 @@
[Slicing test: slice (8,3).]
expected: FAIL
[Invalid contentType ("ÿ")]
expected: FAIL
[Invalid contentType ("te(xt/plain")]
expected: FAIL
@ -207,24 +159,3 @@
[Invalid contentType ("te xt/plain")]
expected: FAIL
[Invalid contentType ("te\\txt/plain")]
expected: FAIL
[Invalid contentType ("te\\0xt/plain")]
expected: FAIL
[Invalid contentType ("te\\x1fxt/plain")]
expected: FAIL
[Invalid contentType ("text/plain")]
expected: FAIL
[Valid contentType ("TEXT/PLAIN")]
expected: FAIL
[Valid contentType ("text/plain;charset = UTF-8")]
expected: FAIL
[Valid contentType ("text/plain;charset=UTF-8")]
expected: FAIL

View file

@ -1,11 +1,5 @@
[fileReader.html]
type: testharness
[FileReader interface object]
expected: FAIL
[no-argument FileReader constructor]
expected: FAIL
[FileReader States -- abort]
expected: FAIL

View file

@ -1,5 +0,0 @@
[historical.html]
type: testharness
[FileReader should not support readAsBinaryString]
expected: FAIL

View file

@ -96,135 +96,6 @@
[FileReader interface: existence and properties of interface object]
expected: FAIL
[FileReader interface object length]
expected: FAIL
[FileReader interface: existence and properties of interface prototype object]
expected: FAIL
[FileReader interface: existence and properties of interface prototype object's "constructor" property]
expected: FAIL
[FileReader interface: operation readAsArrayBuffer(Blob)]
expected: FAIL
[FileReader interface: operation readAsText(Blob,DOMString)]
expected: FAIL
[FileReader interface: operation readAsDataURL(Blob)]
expected: FAIL
[FileReader interface: operation abort()]
expected: FAIL
[FileReader interface: constant EMPTY on interface object]
expected: FAIL
[FileReader interface: constant EMPTY on interface prototype object]
expected: FAIL
[FileReader interface: constant LOADING on interface object]
expected: FAIL
[FileReader interface: constant LOADING on interface prototype object]
expected: FAIL
[FileReader interface: constant DONE on interface object]
expected: FAIL
[FileReader interface: constant DONE on interface prototype object]
expected: FAIL
[FileReader interface: attribute readyState]
expected: FAIL
[FileReader interface: attribute result]
expected: FAIL
[FileReader interface: attribute error]
expected: FAIL
[FileReader interface: attribute onloadstart]
expected: FAIL
[FileReader interface: attribute onprogress]
expected: FAIL
[FileReader interface: attribute onload]
expected: FAIL
[FileReader interface: attribute onabort]
expected: FAIL
[FileReader interface: attribute onerror]
expected: FAIL
[FileReader interface: attribute onloadend]
expected: FAIL
[FileReader must be primary interface of new FileReader()]
expected: FAIL
[Stringification of new FileReader()]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "readAsArrayBuffer" with the proper type (0)]
expected: FAIL
[FileReader interface: calling readAsArrayBuffer(Blob) on new FileReader() with too few arguments must throw TypeError]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "readAsText" with the proper type (1)]
expected: FAIL
[FileReader interface: calling readAsText(Blob,DOMString) on new FileReader() with too few arguments must throw TypeError]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "readAsDataURL" with the proper type (2)]
expected: FAIL
[FileReader interface: calling readAsDataURL(Blob) on new FileReader() with too few arguments must throw TypeError]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "abort" with the proper type (3)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "EMPTY" with the proper type (4)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "LOADING" with the proper type (5)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "DONE" with the proper type (6)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "readyState" with the proper type (7)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "result" with the proper type (8)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "error" with the proper type (9)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "onloadstart" with the proper type (10)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "onprogress" with the proper type (11)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "onload" with the proper type (12)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "onabort" with the proper type (13)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "onerror" with the proper type (14)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "onloadend" with the proper type (15)]
expected: FAIL
[FileReaderSync interface: existence and properties of interface object]
expected: FAIL
@ -246,3 +117,12 @@
[FileReaderSync interface: operation readAsDataURL(Blob)]
expected: FAIL
[FileReader interface: operation readAsArrayBuffer(Blob)]
expected: FAIL
[FileReader interface: new FileReader() must inherit property "readAsArrayBuffer" with the proper type (0)]
expected: FAIL
[FileReader interface: calling readAsArrayBuffer(Blob) on new FileReader() with too few arguments must throw TypeError]
expected: FAIL

View file

@ -1,20 +0,0 @@
[FileReader-event-handler-attributes.html]
type: testharness
[FileReader.onloadstart: initial value]
expected: FAIL
[FileReader.onprogress: initial value]
expected: FAIL
[FileReader.onload: initial value]
expected: FAIL
[FileReader.onabort: initial value]
expected: FAIL
[FileReader.onerror: initial value]
expected: FAIL
[FileReader.onloadend: initial value]
expected: FAIL

View file

@ -1,9 +1,6 @@
[FileReader-multiple-reads.html]
type: testharness
[test FileReader InvalidStateError exception for readAsText]
expected: FAIL
[test FileReader InvalidStateError exception for readAsDataURL]
[test FileReader no InvalidStateError exception in onloadstart event for readAsArrayBuffer]
expected: FAIL
[test FileReader InvalidStateError exception for readAsArrayBuffer]
@ -12,6 +9,3 @@
[test FileReader InvalidStateError exception in onloadstart event for readAsArrayBuffer]
expected: FAIL
[test FileReader no InvalidStateError exception in onloadstart event for readAsArrayBuffer]
expected: FAIL

View file

@ -1,8 +0,0 @@
[filereader_abort.html]
type: testharness
[Aborting before read]
expected: FAIL
[Aborting after read]
expected: FAIL

View file

@ -1,5 +0,0 @@
[filereader_error.html]
type: testharness
[FileAPI Test: filereader_error]
expected: FAIL

View file

@ -1,5 +0,0 @@
[filereader_readAsDataURL.html]
type: testharness
[FileAPI Test: filereader_readAsDataURL]
expected: FAIL

View file

@ -1,8 +0,0 @@
[filereader_readAsText.html]
type: testharness
[readAsText should correctly read UTF-8.]
expected: FAIL
[readAsText should correctly read UTF-16.]
expected: FAIL

View file

@ -1,5 +0,0 @@
[filereader_readystate.html]
type: testharness
[FileAPI Test: filereader_readystate]
expected: FAIL

View file

@ -1,11 +1,5 @@
[filereader_result.html]
type: testharness
[readAsText]
expected: FAIL
[readAsDataURL]
expected: FAIL
[readAsArrayBuffer]
expected: FAIL

View file

@ -99,6 +99,7 @@ var interfaceNamesInGlobalScope = [
"Event",
"EventTarget",
"File",
"FileReader",
"FormData",
"HTMLAnchorElement",
"HTMLAppletElement",