mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Dispatch error events at the window object.
This commit is contained in:
parent
92c3961743
commit
ae38c53de7
737 changed files with 815 additions and 758 deletions
|
@ -14,7 +14,7 @@ use dom::bindings::codegen::Bindings::FunctionBinding::Function;
|
|||
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::{ScrollBehavior, ScrollToOptions};
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::{self, FrameRequestCallback, WindowMethods};
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exception};
|
||||
use dom::bindings::error::{Error, ErrorResult, Fallible, report_pending_exception, ErrorInfo};
|
||||
use dom::bindings::global::{GlobalRef, global_root_from_object};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||
|
@ -30,7 +30,8 @@ use dom::crypto::Crypto;
|
|||
use dom::cssstyledeclaration::{CSSModificationAccess, CSSStyleDeclaration};
|
||||
use dom::document::Document;
|
||||
use dom::element::Element;
|
||||
use dom::event::Event;
|
||||
use dom::errorevent::ErrorEvent;
|
||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use dom::eventtarget::EventTarget;
|
||||
use dom::history::History;
|
||||
use dom::htmliframeelement::build_mozbrowser_custom_event;
|
||||
|
@ -273,6 +274,9 @@ pub struct Window {
|
|||
|
||||
/// A list of scroll offsets for each scrollable element.
|
||||
scroll_offsets: DOMRefCell<HashMap<UntrustedNodeAddress, Point2D<f32>>>,
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#in-error-reporting-mode
|
||||
in_error_reporting_mode: Cell<bool>
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
@ -952,7 +956,7 @@ impl<'a, T: Reflectable> ScriptHelpers for &'a T {
|
|||
code.len() as libc::size_t,
|
||||
rval) {
|
||||
debug!("error evaluating JS string");
|
||||
report_pending_exception(cx);
|
||||
report_pending_exception(cx, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1742,6 +1746,7 @@ impl Window {
|
|||
ignore_further_async_events: Arc::new(AtomicBool::new(false)),
|
||||
error_reporter: error_reporter,
|
||||
scroll_offsets: DOMRefCell::new(HashMap::new()),
|
||||
in_error_reporting_mode: Cell::new(false),
|
||||
};
|
||||
|
||||
WindowBinding::Wrap(runtime.cx(), win)
|
||||
|
@ -1749,6 +1754,34 @@ impl Window {
|
|||
pub fn live_devtools_updates(&self) -> bool {
|
||||
return self.devtools_wants_updates.get();
|
||||
}
|
||||
|
||||
/// https://html.spec.whatwg.org/multipage/#report-the-error
|
||||
pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) {
|
||||
// Step 1.
|
||||
if self.in_error_reporting_mode.get() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 2.
|
||||
self.in_error_reporting_mode.set(true);
|
||||
|
||||
// Steps 3-12.
|
||||
let event = ErrorEvent::new(GlobalRef::Window(self),
|
||||
atom!("error"),
|
||||
EventBubbles::DoesNotBubble,
|
||||
EventCancelable::Cancelable,
|
||||
error_info.message.into(),
|
||||
error_info.filename.into(),
|
||||
error_info.lineno,
|
||||
error_info.column,
|
||||
value);
|
||||
|
||||
// Step 13.
|
||||
event.upcast::<Event>().fire(self.upcast::<EventTarget>());
|
||||
|
||||
// Step 14.
|
||||
self.in_error_reporting_mode.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
fn should_move_clip_rect(clip_rect: Rect<Au>, new_viewport: Rect<f32>) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue