mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Throw RangeErrors in TextEncoder/TextDecoder constructors.
Fixes #5620. Fix the TODOs and FIXMEs to comply with the spec. Add test case for passing invalid invalid labels. Update test metadata; three test cases have been resolved upstream and will be fixed whenever the rust-encoding dependency is sufficiently upgraded.
This commit is contained in:
parent
f3aee90b06
commit
97301400a5
6 changed files with 37 additions and 130 deletions
|
@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::TextEncoderBinding;
|
|||
use dom::bindings::codegen::Bindings::TextEncoderBinding::TextEncoderMethods;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::error::Error::IndexSize;
|
||||
use dom::bindings::error::Error::Range;
|
||||
use dom::bindings::js::{JSRef, Temporary};
|
||||
use dom::bindings::str::USVString;
|
||||
use dom::bindings::utils::{Reflector, reflect_dom_object};
|
||||
|
@ -54,8 +54,7 @@ impl TextEncoder {
|
|||
Some(enc) => enc,
|
||||
None => {
|
||||
debug!("Encoding Label Not Supported");
|
||||
// TODO: should throw RangeError
|
||||
return Err(IndexSize)
|
||||
return Err(Range("The given encoding is not supported.".to_owned()))
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -65,8 +64,7 @@ impl TextEncoder {
|
|||
}
|
||||
_ => {
|
||||
debug!("Encoding Not UTF");
|
||||
// TODO: should throw RangeError
|
||||
Err(IndexSize)
|
||||
return Err(Range("The encoding must be utf-8, utf-16le, or utf-16be.".to_owned()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue