mirror of
https://github.com/servo/servo.git
synced 2025-07-22 06:43:40 +01:00
Trigger RTCErrorEvent on data channel error
This commit is contained in:
parent
84598a5173
commit
5c6dcbf54e
3 changed files with 22 additions and 4 deletions
|
@ -5,15 +5,18 @@
|
|||
use crate::dom::bindings::cell::DomRefCell;
|
||||
use crate::dom::bindings::codegen::Bindings::RTCDataChannelBinding::RTCDataChannelInit;
|
||||
use crate::dom::bindings::codegen::Bindings::RTCDataChannelBinding::RTCDataChannelMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::RTCErrorBinding::{RTCErrorDetailType, RTCErrorInit};
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::refcounted::Trusted;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object, DomObject};
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::USVString;
|
||||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::blob::Blob;
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::dom::rtcerror::RTCError;
|
||||
use crate::dom::rtcerrorevent::RTCErrorEvent;
|
||||
use crate::task_source::TaskSource;
|
||||
use dom_struct::dom_struct;
|
||||
use js::rust::CustomAutoRooterGuard;
|
||||
|
@ -164,7 +167,22 @@ impl RTCDataChannel {
|
|||
event.upcast::<Event>().fire(self.upcast());
|
||||
}
|
||||
|
||||
fn on_error(&self, error: WebRtcError) {}
|
||||
fn on_error(&self, error: WebRtcError) {
|
||||
let init = RTCErrorInit {
|
||||
errorDetail: RTCErrorDetailType::Data_channel_failure,
|
||||
httpRequestStatusCode: None,
|
||||
receivedAlert: None,
|
||||
sctpCauseCode: None,
|
||||
sdpLineNumber: None,
|
||||
sentAlert: None,
|
||||
};
|
||||
let message = match error {
|
||||
WebRtcError::Backend(message) => DOMString::from(message),
|
||||
};
|
||||
let error = RTCError::new(&self.global(), &init, message);
|
||||
let event = RTCErrorEvent::new(&self.global(), atom!("error"), false, false, &error);
|
||||
event.upcast::<Event>().fire(self.upcast());
|
||||
}
|
||||
|
||||
fn on_message(&self, message: String) {}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ impl RTCError {
|
|||
}
|
||||
}
|
||||
|
||||
fn new(global: &GlobalScope, init: &RTCErrorInit, message: DOMString) -> DomRoot<RTCError> {
|
||||
pub fn new(global: &GlobalScope, init: &RTCErrorInit, message: DOMString) -> DomRoot<RTCError> {
|
||||
reflect_dom_object(
|
||||
Box::new(RTCError::new_inherited(global, init, message)),
|
||||
global,
|
||||
|
|
|
@ -30,7 +30,7 @@ impl RTCErrorEvent {
|
|||
}
|
||||
}
|
||||
|
||||
fn new(
|
||||
pub fn new(
|
||||
global: &GlobalScope,
|
||||
type_: Atom,
|
||||
bubbles: bool,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue