mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
Adjust the assertions in throw_dom_exception.
This commit is contained in:
parent
a745dda863
commit
f8dec0fe58
2 changed files with 9 additions and 5 deletions
|
@ -71,10 +71,9 @@ pub type Fallible<T> = Result<T, Error>;
|
|||
/// return `()`.
|
||||
pub type ErrorResult = Fallible<()>;
|
||||
|
||||
/// Set a pending DOM exception for the given `result` on `cx`.
|
||||
/// Set a pending exception for the given `result` on `cx`.
|
||||
pub fn throw_dom_exception(cx: *mut JSContext, global: GlobalRef,
|
||||
result: Error) {
|
||||
assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
|
||||
let code = match result {
|
||||
Error::IndexSize => DOMErrorName::IndexSizeError,
|
||||
Error::NotFound => DOMErrorName::NotFoundError,
|
||||
|
@ -93,11 +92,17 @@ pub fn throw_dom_exception(cx: *mut JSContext, global: GlobalRef,
|
|||
Error::DataClone => DOMErrorName::DataCloneError,
|
||||
Error::NoModificationAllowed => DOMErrorName::NoModificationAllowedError,
|
||||
Error::Type(message) => {
|
||||
assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
|
||||
throw_type_error(cx, &message);
|
||||
return;
|
||||
}
|
||||
Error::JSFailed => panic!(),
|
||||
Error::JSFailed => {
|
||||
assert!(unsafe { JS_IsExceptionPending(cx) } == 1);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
|
||||
let exception = DOMException::new(global, code).root();
|
||||
let thrown = exception.to_jsval(cx);
|
||||
unsafe {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
[WorkerGlobalScope_importScripts_NetworkErr.htm]
|
||||
type: testharness
|
||||
expected: TIMEOUT
|
||||
[ importScripts() with non-existent script file ]
|
||||
expected: TIMEOUT
|
||||
expected: FAIL
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue