mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +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 `()`.
|
/// return `()`.
|
||||||
pub type ErrorResult = Fallible<()>;
|
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,
|
pub fn throw_dom_exception(cx: *mut JSContext, global: GlobalRef,
|
||||||
result: Error) {
|
result: Error) {
|
||||||
assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
|
|
||||||
let code = match result {
|
let code = match result {
|
||||||
Error::IndexSize => DOMErrorName::IndexSizeError,
|
Error::IndexSize => DOMErrorName::IndexSizeError,
|
||||||
Error::NotFound => DOMErrorName::NotFoundError,
|
Error::NotFound => DOMErrorName::NotFoundError,
|
||||||
|
@ -93,11 +92,17 @@ pub fn throw_dom_exception(cx: *mut JSContext, global: GlobalRef,
|
||||||
Error::DataClone => DOMErrorName::DataCloneError,
|
Error::DataClone => DOMErrorName::DataCloneError,
|
||||||
Error::NoModificationAllowed => DOMErrorName::NoModificationAllowedError,
|
Error::NoModificationAllowed => DOMErrorName::NoModificationAllowedError,
|
||||||
Error::Type(message) => {
|
Error::Type(message) => {
|
||||||
|
assert!(unsafe { JS_IsExceptionPending(cx) } == 0);
|
||||||
throw_type_error(cx, &message);
|
throw_type_error(cx, &message);
|
||||||
return;
|
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 exception = DOMException::new(global, code).root();
|
||||||
let thrown = exception.to_jsval(cx);
|
let thrown = exception.to_jsval(cx);
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
[WorkerGlobalScope_importScripts_NetworkErr.htm]
|
[WorkerGlobalScope_importScripts_NetworkErr.htm]
|
||||||
type: testharness
|
type: testharness
|
||||||
expected: TIMEOUT
|
|
||||||
[ importScripts() with non-existent script file ]
|
[ importScripts() with non-existent script file ]
|
||||||
expected: TIMEOUT
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue