Don't return early from report_pending_exception() if the value is an unexpected object.

We will now dispatch the error event in this case as well.
This commit is contained in:
Ms2ger 2016-11-26 22:54:43 +01:00
parent c4f87f451f
commit 154b16a25d
13 changed files with 31 additions and 19 deletions

View file

@ -214,15 +214,16 @@ pub unsafe fn report_pending_exception(cx: *mut JSContext, dispatch_event: bool)
JS_ClearPendingException(cx); JS_ClearPendingException(cx);
let error_info = if value.is_object() { let error_info = if value.is_object() {
rooted!(in(cx) let object = value.to_object()); rooted!(in(cx) let object = value.to_object());
let error_info = ErrorInfo::from_native_error(cx, object.handle()) ErrorInfo::from_native_error(cx, object.handle())
.or_else(|| ErrorInfo::from_dom_exception(object.handle())); .or_else(|| ErrorInfo::from_dom_exception(object.handle()))
match error_info { .unwrap_or_else(|| {
Some(error_info) => error_info, ErrorInfo {
None => { message: format!("uncaught exception: unknown (can't convert to string)"),
error!("Uncaught exception: failed to extract information"); filename: String::new(),
return; lineno: 0,
} column: 0,
} }
})
} else { } else {
match USVString::from_jsval(cx, value.handle(), ()) { match USVString::from_jsval(cx, value.handle(), ()) {
Ok(ConversionResult::Success(USVString(string))) => { Ok(ConversionResult::Success(USVString(string))) => {

View file

@ -1,6 +1,7 @@
[AddEventListenerOptions-passive.html] [AddEventListenerOptions-passive.html]
type: testharness type: testharness
bug: https://github.com/servo/servo/issues/13243 bug: https://github.com/servo/servo/issues/13243
expected: ERROR
[Supports passive option on addEventListener only] [Supports passive option on addEventListener only]
expected: FAIL expected: FAIL

View file

@ -1,3 +1,3 @@
[headers-idl.html] [headers-idl.html]
type: testharness type: testharness
expected: TIMEOUT expected: ERROR

View file

@ -1,3 +1,3 @@
[request-idl.html] [request-idl.html]
type: testharness type: testharness
expected: TIMEOUT expected: ERROR

View file

@ -1,3 +1,3 @@
[response-idl.html] [response-idl.html]
type: testharness type: testharness
expected: TIMEOUT expected: ERROR

View file

@ -8,3 +8,4 @@
[history position should be calculated when executing, not when calling the .go command] [history position should be calculated when executing, not when calling the .go command]
expected: FAIL expected: FAIL

View file

@ -1,6 +1,6 @@
[sandbox-allow-scripts.html] [sandbox-allow-scripts.html]
type: testharness type: testharness
expected: TIMEOUT expected: ERROR
[Running script from sandbox='allow-scripts' iframe is allowed] [Running script from sandbox='allow-scripts' iframe is allowed]
expected: NOTRUN expected: NOTRUN

View file

@ -8,3 +8,4 @@
[Resize iframe from 200x100 to 200x50, then to 100x50] [Resize iframe from 200x100 to 200x50, then to 100x50]
expected: FAIL expected: FAIL

View file

@ -2,3 +2,4 @@
type: testharness type: testharness
[disconnect() called during startNotifications. Reject with NetworkError.] [disconnect() called during startNotifications. Reject with NetworkError.]
expected: FAIL expected: FAIL

View file

@ -2,3 +2,4 @@
type: testharness type: testharness
[disconnect() called during stopNotifications. Reject with NetworkError.] [disconnect() called during stopNotifications. Reject with NetworkError.]
expected: FAIL expected: FAIL

View file

@ -0,0 +1,6 @@
[htmllabel-activation.html]
type: testharness
[If label's 1st child (submit) is disabled, click should have no impact]
expected: FAIL

View file

@ -37,7 +37,7 @@
label.click(); label.click();
assert_false(disabledcb.checked, "checkbox should not be checked") assert_false(disabledcb.checked, "checkbox should not be checked")
assert_false(checkbox.checked, "checkbox should not be checked") assert_false(checkbox.checked, "checkbox should not be checked")
}, "If label's 1st child is disabled, click should have no impact"); }, "If label's 1st child (checkbox) is disabled, click should have no impact");
test(function() { test(function() {
document.querySelector("#test").innerHTML = '<label id="label">hi \ document.querySelector("#test").innerHTML = '<label id="label">hi \
@ -81,7 +81,7 @@
label.click(); label.click();
assert_false(disabledRadio.checked, "disabled radio should not be checked") assert_false(disabledRadio.checked, "disabled radio should not be checked")
assert_false(checkbox.checked, "checkbox should not be checked") assert_false(checkbox.checked, "checkbox should not be checked")
}, "If label's 1st child is disabled, click should have no impact"); }, "If label's 1st child (radio) is disabled, click should have no impact");
test(function() { test(function() {
@ -110,13 +110,13 @@
disabledSubmit = document.getElementById('disabledSubmit'), disabledSubmit = document.getElementById('disabledSubmit'),
checkbox = document.getElementById('checkbox'); checkbox = document.getElementById('checkbox');
disabledSubmit.onclick = function() { disabledSubmit.onclick = this.step_func(function() {
assert_unreached("disabled submit should not have been activated") assert_unreached("disabled submit should not have been activated")
}; });
label.click(); label.click();
assert_false(checkbox.checked, "checkbox should not be checked") assert_false(checkbox.checked, "checkbox should not be checked")
}, "If label's 1st child is disabled, click should have no impact"); }, "If label's 1st child (submit) is disabled, click should have no impact");
test(function() { test(function() {
document.querySelector("#test").innerHTML = '<label id="label" for="checkbox2">hi \ document.querySelector("#test").innerHTML = '<label id="label" for="checkbox2">hi \