mirror of
https://github.com/servo/servo.git
synced 2025-10-01 00:59:15 +01:00
script: Add message to InvalidStateError (#39535)
Adding an optional message to be attached to an InvalidStateError. Testing: Only a refactor, no behavior change Fixes: Partially #39053 Signed-off-by: Excitable Snowball <excitablesnowball@gmail.com>
This commit is contained in:
parent
55d094a871
commit
601ad7e5c6
58 changed files with 182 additions and 168 deletions
|
@ -149,7 +149,7 @@ impl AudioBufferSourceNodeMethods<crate::DomTypeHolder> for AudioBufferSourceNod
|
||||||
if new_buffer.is_some() {
|
if new_buffer.is_some() {
|
||||||
if self.buffer_set.get() {
|
if self.buffer_set.get() {
|
||||||
// Step 2.
|
// Step 2.
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
// Step 3.
|
// Step 3.
|
||||||
self.buffer_set.set(true);
|
self.buffer_set.set(true);
|
||||||
|
|
|
@ -146,7 +146,7 @@ impl AudioContextMethods<crate::DomTypeHolder> for AudioContext {
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.context.control_thread_state() == ProcessingState::Closed {
|
if self.context.control_thread_state() == ProcessingState::Closed {
|
||||||
promise.reject_error(Error::InvalidState, can_gc);
|
promise.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ impl AudioContextMethods<crate::DomTypeHolder> for AudioContext {
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.context.control_thread_state() == ProcessingState::Closed {
|
if self.context.control_thread_state() == ProcessingState::Closed {
|
||||||
promise.reject_error(Error::InvalidState, can_gc);
|
promise.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -259,7 +259,7 @@ impl AudioNodeMethods<crate::DomTypeHolder> for AudioNode {
|
||||||
match self.upcast::<EventTarget>().type_id() {
|
match self.upcast::<EventTarget>().type_id() {
|
||||||
EventTargetTypeId::AudioNode(AudioNodeTypeId::AudioDestinationNode) => {
|
EventTargetTypeId::AudioNode(AudioNodeTypeId::AudioDestinationNode) => {
|
||||||
if self.context.is_offline() {
|
if self.context.is_offline() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
} else if !(1..=MAX_CHANNEL_COUNT).contains(&value) {
|
} else if !(1..=MAX_CHANNEL_COUNT).contains(&value) {
|
||||||
return Err(Error::IndexSize);
|
return Err(Error::IndexSize);
|
||||||
}
|
}
|
||||||
|
@ -277,10 +277,10 @@ impl AudioNodeMethods<crate::DomTypeHolder> for AudioNode {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelMergerNode) => {
|
EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelMergerNode) => {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
},
|
},
|
||||||
EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelSplitterNode) => {
|
EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelSplitterNode) => {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
},
|
},
|
||||||
// XXX We do not support any of the other AudioNodes with
|
// XXX We do not support any of the other AudioNodes with
|
||||||
// constraints yet. Add more cases here as we add support
|
// constraints yet. Add more cases here as we add support
|
||||||
|
@ -312,7 +312,7 @@ impl AudioNodeMethods<crate::DomTypeHolder> for AudioNode {
|
||||||
match self.upcast::<EventTarget>().type_id() {
|
match self.upcast::<EventTarget>().type_id() {
|
||||||
EventTargetTypeId::AudioNode(AudioNodeTypeId::AudioDestinationNode) => {
|
EventTargetTypeId::AudioNode(AudioNodeTypeId::AudioDestinationNode) => {
|
||||||
if self.context.is_offline() {
|
if self.context.is_offline() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
EventTargetTypeId::AudioNode(AudioNodeTypeId::PannerNode) => {
|
EventTargetTypeId::AudioNode(AudioNodeTypeId::PannerNode) => {
|
||||||
|
@ -328,10 +328,10 @@ impl AudioNodeMethods<crate::DomTypeHolder> for AudioNode {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelMergerNode) => {
|
EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelMergerNode) => {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
},
|
},
|
||||||
EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelSplitterNode) => {
|
EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelSplitterNode) => {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
},
|
},
|
||||||
// XXX We do not support any of the other AudioNodes with
|
// XXX We do not support any of the other AudioNodes with
|
||||||
// constraints yet. Add more cases here as we add support
|
// constraints yet. Add more cases here as we add support
|
||||||
|
@ -359,7 +359,7 @@ impl AudioNodeMethods<crate::DomTypeHolder> for AudioNode {
|
||||||
if let EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelSplitterNode) =
|
if let EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelSplitterNode) =
|
||||||
self.upcast::<EventTarget>().type_id()
|
self.upcast::<EventTarget>().type_id()
|
||||||
{
|
{
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
};
|
};
|
||||||
|
|
||||||
self.channel_interpretation.set(value);
|
self.channel_interpretation.set(value);
|
||||||
|
|
|
@ -129,7 +129,7 @@ impl AudioParamMethods<crate::DomTypeHolder> for AudioParam {
|
||||||
self.node_type == AudioNodeType::AudioBufferSourceNode &&
|
self.node_type == AudioNodeType::AudioBufferSourceNode &&
|
||||||
(self.param == ParamType::Detune || self.param == ParamType::PlaybackRate)
|
(self.param == ParamType::Detune || self.param == ParamType::PlaybackRate)
|
||||||
{
|
{
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.automation_rate.set(automation_rate);
|
self.automation_rate.set(automation_rate);
|
||||||
|
@ -274,7 +274,7 @@ impl AudioParamMethods<crate::DomTypeHolder> for AudioParam {
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
if values.len() < 2. as usize {
|
if values.len() < 2. as usize {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
if *end_time < 0. {
|
if *end_time < 0. {
|
||||||
|
|
|
@ -67,7 +67,7 @@ impl AudioScheduledSourceNodeMethods<crate::DomTypeHolder> for AudioScheduledSou
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.has_start.get() || self.has_stop.get() {
|
if self.has_start.get() || self.has_stop.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
let this = Trusted::new(self);
|
let this = Trusted::new(self);
|
||||||
|
@ -106,7 +106,7 @@ impl AudioScheduledSourceNodeMethods<crate::DomTypeHolder> for AudioScheduledSou
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.has_start.get() {
|
if !self.has_start.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
self.has_stop.set(true);
|
self.has_stop.set(true);
|
||||||
self.node
|
self.node
|
||||||
|
|
|
@ -292,7 +292,7 @@ impl BaseAudioContextMethods<crate::DomTypeHolder> for BaseAudioContext {
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.audio_context_impl.lock().unwrap().state() == ProcessingState::Closed {
|
if self.audio_context_impl.lock().unwrap().state() == ProcessingState::Closed {
|
||||||
promise.reject_error(Error::InvalidState, can_gc);
|
promise.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl ChannelMergerNode {
|
||||||
);
|
);
|
||||||
|
|
||||||
if node_options.count != 1 || node_options.mode != ChannelCountMode::Explicit {
|
if node_options.count != 1 || node_options.mode != ChannelCountMode::Explicit {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.numberOfInputs < 1 || options.numberOfInputs > MAX_CHANNEL_COUNT {
|
if options.numberOfInputs < 1 || options.numberOfInputs > MAX_CHANNEL_COUNT {
|
||||||
|
|
|
@ -46,7 +46,7 @@ impl ChannelSplitterNode {
|
||||||
node_options.mode != ChannelCountMode::Explicit ||
|
node_options.mode != ChannelCountMode::Explicit ||
|
||||||
node_options.interpretation != ChannelInterpretation::Discrete
|
node_options.interpretation != ChannelInterpretation::Discrete
|
||||||
{
|
{
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
let node = AudioNode::new_inherited(
|
let node = AudioNode::new_inherited(
|
||||||
|
|
|
@ -48,7 +48,7 @@ impl IIRFilterNode {
|
||||||
return Err(Error::NotSupported);
|
return Err(Error::NotSupported);
|
||||||
}
|
}
|
||||||
if options.feedforward.iter().all(|v| **v == 0.0) || *options.feedback[0] == 0.0 {
|
if options.feedforward.iter().all(|v| **v == 0.0) || *options.feedback[0] == 0.0 {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
let node_options =
|
let node_options =
|
||||||
options
|
options
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl MediaStreamAudioSourceNode {
|
||||||
.get_tracks()
|
.get_tracks()
|
||||||
.iter()
|
.iter()
|
||||||
.find(|t| t.ty() == MediaStreamType::Audio)
|
.find(|t| t.ty() == MediaStreamType::Audio)
|
||||||
.ok_or(Error::InvalidState)?
|
.ok_or(Error::InvalidState(None))?
|
||||||
.id();
|
.id();
|
||||||
let node = AudioNode::new_inherited(
|
let node = AudioNode::new_inherited(
|
||||||
AudioNodeInit::MediaStreamSourceNode(track),
|
AudioNodeInit::MediaStreamSourceNode(track),
|
||||||
|
|
|
@ -146,7 +146,7 @@ impl OfflineAudioContextMethods<crate::DomTypeHolder> for OfflineAudioContext {
|
||||||
fn StartRendering(&self, comp: InRealm, can_gc: CanGc) -> Rc<Promise> {
|
fn StartRendering(&self, comp: InRealm, can_gc: CanGc) -> Rc<Promise> {
|
||||||
let promise = Promise::new_in_current_realm(comp, can_gc);
|
let promise = Promise::new_in_current_realm(comp, can_gc);
|
||||||
if self.rendering_started.get() {
|
if self.rendering_started.get() {
|
||||||
promise.reject_error(Error::InvalidState, can_gc);
|
promise.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
self.rendering_started.set(true);
|
self.rendering_started.set(true);
|
||||||
|
|
|
@ -148,7 +148,7 @@ impl OscillatorNodeMethods<crate::DomTypeHolder> for OscillatorNode {
|
||||||
// https://webaudio.github.io/web-audio-api/#dom-oscillatornode-type
|
// https://webaudio.github.io/web-audio-api/#dom-oscillatornode-type
|
||||||
fn SetType(&self, type_: OscillatorType) -> ErrorResult {
|
fn SetType(&self, type_: OscillatorType) -> ErrorResult {
|
||||||
if type_ == OscillatorType::Custom {
|
if type_ == OscillatorType::Custom {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
self.oscillator_type.set(type_);
|
self.oscillator_type.set(type_);
|
||||||
self.source_node
|
self.source_node
|
||||||
|
|
|
@ -86,7 +86,7 @@ impl PannerNode {
|
||||||
return Err(Error::Range("rolloffFactor should be non-negative".into()));
|
return Err(Error::Range("rolloffFactor should be non-negative".into()));
|
||||||
}
|
}
|
||||||
if *options.coneOuterGain < 0. || *options.coneOuterGain > 1. {
|
if *options.coneOuterGain < 0. || *options.coneOuterGain > 1. {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
let options = options.convert();
|
let options = options.convert();
|
||||||
let node = AudioNode::new_inherited(
|
let node = AudioNode::new_inherited(
|
||||||
|
@ -356,7 +356,7 @@ impl PannerNodeMethods<crate::DomTypeHolder> for PannerNode {
|
||||||
// https://webaudio.github.io/web-audio-api/#dom-pannernode-coneoutergain
|
// https://webaudio.github.io/web-audio-api/#dom-pannernode-coneoutergain
|
||||||
fn SetConeOuterGain(&self, val: Finite<f64>) -> Fallible<()> {
|
fn SetConeOuterGain(&self, val: Finite<f64>) -> Fallible<()> {
|
||||||
if *val < 0. || *val > 1. {
|
if *val < 0. || *val > 1. {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
self.cone_outer_gain.set(*val);
|
self.cone_outer_gain.set(*val);
|
||||||
let msg = PannerNodeMessage::SetConeGain(self.cone_outer_gain.get());
|
let msg = PannerNodeMessage::SetConeGain(self.cone_outer_gain.get());
|
||||||
|
|
|
@ -199,7 +199,7 @@ fn html_constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
if !check_type(&element) {
|
if !check_type(&element) {
|
||||||
throw_dom_exception(cx, global, Error::InvalidState, can_gc);
|
throw_dom_exception(cx, global, Error::InvalidState(None), can_gc);
|
||||||
return Err(());
|
return Err(());
|
||||||
} else {
|
} else {
|
||||||
// Step 7.9 Return element.
|
// Step 7.9 Return element.
|
||||||
|
@ -217,7 +217,7 @@ fn html_constructor(
|
||||||
|
|
||||||
// Step 13
|
// Step 13
|
||||||
if !check_type(&element) {
|
if !check_type(&element) {
|
||||||
throw_dom_exception(cx, global, Error::InvalidState, can_gc);
|
throw_dom_exception(cx, global, Error::InvalidState(None), can_gc);
|
||||||
return Err(());
|
return Err(());
|
||||||
} else {
|
} else {
|
||||||
element
|
element
|
||||||
|
|
|
@ -116,7 +116,10 @@ pub(crate) fn create_dom_exception(
|
||||||
Error::InvalidCharacter => DOMErrorName::InvalidCharacterError,
|
Error::InvalidCharacter => DOMErrorName::InvalidCharacterError,
|
||||||
Error::NotSupported => DOMErrorName::NotSupportedError,
|
Error::NotSupported => DOMErrorName::NotSupportedError,
|
||||||
Error::InUseAttribute => DOMErrorName::InUseAttributeError,
|
Error::InUseAttribute => DOMErrorName::InUseAttributeError,
|
||||||
Error::InvalidState => DOMErrorName::InvalidStateError,
|
Error::InvalidState(Some(custom_message)) => {
|
||||||
|
return new_custom_exception(DOMErrorName::InvalidStateError, custom_message);
|
||||||
|
},
|
||||||
|
Error::InvalidState(None) => DOMErrorName::InvalidStateError,
|
||||||
Error::Syntax(Some(custom_message)) => {
|
Error::Syntax(Some(custom_message)) => {
|
||||||
return new_custom_exception(DOMErrorName::SyntaxError, custom_message);
|
return new_custom_exception(DOMErrorName::SyntaxError, custom_message);
|
||||||
},
|
},
|
||||||
|
|
|
@ -533,7 +533,7 @@ impl Convert<Error> for BluetoothError {
|
||||||
BluetoothError::NotFound => Error::NotFound(None),
|
BluetoothError::NotFound => Error::NotFound(None),
|
||||||
BluetoothError::NotSupported => Error::NotSupported,
|
BluetoothError::NotSupported => Error::NotSupported,
|
||||||
BluetoothError::Security => Error::Security,
|
BluetoothError::Security => Error::Security,
|
||||||
BluetoothError::InvalidState => Error::InvalidState,
|
BluetoothError::InvalidState => Error::InvalidState(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ impl BroadcastChannelMethods<crate::DomTypeHolder> for BroadcastChannel {
|
||||||
fn PostMessage(&self, cx: SafeJSContext, message: HandleValue) -> ErrorResult {
|
fn PostMessage(&self, cx: SafeJSContext, message: HandleValue) -> ErrorResult {
|
||||||
// Step 3, if closed.
|
// Step 3, if closed.
|
||||||
if self.closed.get() {
|
if self.closed.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6, StructuredSerialize(message).
|
// Step 6, StructuredSerialize(message).
|
||||||
|
|
|
@ -507,7 +507,7 @@ impl CanvasState {
|
||||||
CanvasImageSource::HTMLCanvasElement(ref canvas) => {
|
CanvasImageSource::HTMLCanvasElement(ref canvas) => {
|
||||||
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
||||||
if canvas.get_size().is_empty() {
|
if canvas.get_size().is_empty() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.draw_html_canvas_element(canvas, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh)
|
self.draw_html_canvas_element(canvas, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||||
|
@ -515,7 +515,7 @@ impl CanvasState {
|
||||||
CanvasImageSource::ImageBitmap(ref bitmap) => {
|
CanvasImageSource::ImageBitmap(ref bitmap) => {
|
||||||
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
||||||
if bitmap.is_detached() {
|
if bitmap.is_detached() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.draw_image_bitmap(bitmap, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh);
|
self.draw_image_bitmap(bitmap, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh);
|
||||||
|
@ -524,7 +524,7 @@ impl CanvasState {
|
||||||
CanvasImageSource::OffscreenCanvas(ref canvas) => {
|
CanvasImageSource::OffscreenCanvas(ref canvas) => {
|
||||||
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
||||||
if canvas.get_size().is_empty() {
|
if canvas.get_size().is_empty() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.draw_offscreen_canvas(canvas, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh)
|
self.draw_offscreen_canvas(canvas, htmlcanvas, sx, sy, sw, sh, dx, dy, dw, dh)
|
||||||
|
@ -532,7 +532,7 @@ impl CanvasState {
|
||||||
CanvasImageSource::CSSStyleValue(ref value) => {
|
CanvasImageSource::CSSStyleValue(ref value) => {
|
||||||
let url = value
|
let url = value
|
||||||
.get_url(self.base_url.clone())
|
.get_url(self.base_url.clone())
|
||||||
.ok_or(Error::InvalidState)?;
|
.ok_or(Error::InvalidState(None))?;
|
||||||
self.fetch_and_draw_image_data(
|
self.fetch_and_draw_image_data(
|
||||||
htmlcanvas, url, None, sx, sy, sw, sh, dx, dy, dw, dh,
|
htmlcanvas, url, None, sx, sy, sw, sh, dx, dy, dw, dh,
|
||||||
)
|
)
|
||||||
|
@ -705,7 +705,7 @@ impl CanvasState {
|
||||||
self.state.borrow().transform,
|
self.state.borrow().transform,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
OffscreenRenderingContext::Detached => return Err(Error::InvalidState),
|
OffscreenRenderingContext::Detached => return Err(Error::InvalidState(None)),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.send_canvas_2d_msg(Canvas2dMsg::DrawEmptyImage(
|
self.send_canvas_2d_msg(Canvas2dMsg::DrawEmptyImage(
|
||||||
|
@ -786,7 +786,7 @@ impl CanvasState {
|
||||||
},
|
},
|
||||||
RenderingContext::Placeholder(ref context) => {
|
RenderingContext::Placeholder(ref context) => {
|
||||||
let Some(context) = context.context() else {
|
let Some(context) = context.context() else {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
};
|
};
|
||||||
match *context {
|
match *context {
|
||||||
OffscreenRenderingContext::Context2d(ref context) => context
|
OffscreenRenderingContext::Context2d(ref context) => context
|
||||||
|
@ -814,10 +814,12 @@ impl CanvasState {
|
||||||
self.state.borrow().transform,
|
self.state.borrow().transform,
|
||||||
));
|
));
|
||||||
},
|
},
|
||||||
OffscreenRenderingContext::Detached => return Err(Error::InvalidState),
|
OffscreenRenderingContext::Detached => {
|
||||||
|
return Err(Error::InvalidState(None));
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => return Err(Error::InvalidState),
|
_ => return Err(Error::InvalidState(None)),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.send_canvas_2d_msg(Canvas2dMsg::DrawEmptyImage(
|
self.send_canvas_2d_msg(Canvas2dMsg::DrawEmptyImage(
|
||||||
|
@ -852,7 +854,7 @@ impl CanvasState {
|
||||||
debug!("Fetching image {}.", url);
|
debug!("Fetching image {}.", url);
|
||||||
let snapshot = self
|
let snapshot = self
|
||||||
.fetch_image_data(url, cors_setting)
|
.fetch_image_data(url, cors_setting)
|
||||||
.ok_or(Error::InvalidState)?;
|
.ok_or(Error::InvalidState(None))?;
|
||||||
let image_size = snapshot.size();
|
let image_size = snapshot.size();
|
||||||
|
|
||||||
let dw = dw.unwrap_or(image_size.width as f64);
|
let dw = dw.unwrap_or(image_size.width as f64);
|
||||||
|
@ -1254,7 +1256,9 @@ impl CanvasState {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
image.get_raster_image_data().ok_or(Error::InvalidState)?
|
image
|
||||||
|
.get_raster_image_data()
|
||||||
|
.ok_or(Error::InvalidState(None))?
|
||||||
},
|
},
|
||||||
CanvasImageSource::HTMLVideoElement(ref video) => {
|
CanvasImageSource::HTMLVideoElement(ref video) => {
|
||||||
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
||||||
|
@ -1262,36 +1266,41 @@ impl CanvasState {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
|
|
||||||
video.get_current_frame_data().ok_or(Error::InvalidState)?
|
video
|
||||||
|
.get_current_frame_data()
|
||||||
|
.ok_or(Error::InvalidState(None))?
|
||||||
},
|
},
|
||||||
CanvasImageSource::HTMLCanvasElement(ref canvas) => {
|
CanvasImageSource::HTMLCanvasElement(ref canvas) => {
|
||||||
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
||||||
if canvas.get_size().is_empty() {
|
if canvas.get_size().is_empty() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.get_image_data().ok_or(Error::InvalidState)?
|
canvas.get_image_data().ok_or(Error::InvalidState(None))?
|
||||||
},
|
},
|
||||||
CanvasImageSource::ImageBitmap(ref bitmap) => {
|
CanvasImageSource::ImageBitmap(ref bitmap) => {
|
||||||
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
||||||
if bitmap.is_detached() {
|
if bitmap.is_detached() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap.bitmap_data().clone().ok_or(Error::InvalidState)?
|
bitmap
|
||||||
|
.bitmap_data()
|
||||||
|
.clone()
|
||||||
|
.ok_or(Error::InvalidState(None))?
|
||||||
},
|
},
|
||||||
CanvasImageSource::OffscreenCanvas(ref canvas) => {
|
CanvasImageSource::OffscreenCanvas(ref canvas) => {
|
||||||
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
||||||
if canvas.get_size().is_empty() {
|
if canvas.get_size().is_empty() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.get_image_data().ok_or(Error::InvalidState)?
|
canvas.get_image_data().ok_or(Error::InvalidState(None))?
|
||||||
},
|
},
|
||||||
CanvasImageSource::CSSStyleValue(ref value) => value
|
CanvasImageSource::CSSStyleValue(ref value) => value
|
||||||
.get_url(self.base_url.clone())
|
.get_url(self.base_url.clone())
|
||||||
.and_then(|url| self.fetch_image_data(url, None))
|
.and_then(|url| self.fetch_image_data(url, None))
|
||||||
.ok_or(Error::InvalidState)?,
|
.ok_or(Error::InvalidState(None))?,
|
||||||
};
|
};
|
||||||
|
|
||||||
if repetition.is_empty() {
|
if repetition.is_empty() {
|
||||||
|
|
|
@ -310,12 +310,12 @@ impl ImageBitmap {
|
||||||
// Step 2. If either options's resizeWidth or options's resizeHeight is present and is 0,
|
// Step 2. If either options's resizeWidth or options's resizeHeight is present and is 0,
|
||||||
// then return a promise rejected with an "InvalidStateError" DOMException.
|
// then return a promise rejected with an "InvalidStateError" DOMException.
|
||||||
if options.resizeWidth.is_some_and(|w| w == 0) {
|
if options.resizeWidth.is_some_and(|w| w == 0) {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if options.resizeHeight.is_some_and(|h| h == 0) {
|
if options.resizeHeight.is_some_and(|h| h == 0) {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ impl ImageBitmap {
|
||||||
.queue(task!(reject_promise: move || {
|
.queue(task!(reject_promise: move || {
|
||||||
let promise = trusted_promise.root();
|
let promise = trusted_promise.root();
|
||||||
|
|
||||||
promise.reject_error(Error::InvalidState, CanGc::note());
|
promise.reject_error(Error::InvalidState(None), CanGc::note());
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -357,14 +357,14 @@ impl ImageBitmap {
|
||||||
ImageBitmapSource::HTMLImageElement(ref image) => {
|
ImageBitmapSource::HTMLImageElement(ref image) => {
|
||||||
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
||||||
if !image.is_usable().is_ok_and(|u| u) {
|
if !image.is_usable().is_ok_and(|u| u) {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no ImageBitmap object can be constructed, then the promise
|
// If no ImageBitmap object can be constructed, then the promise
|
||||||
// is rejected instead.
|
// is rejected instead.
|
||||||
let Some(snapshot) = image.get_raster_image_data() else {
|
let Some(snapshot) = image.get_raster_image_data() else {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ impl ImageBitmap {
|
||||||
let Some(bitmap_data) =
|
let Some(bitmap_data) =
|
||||||
ImageBitmap::crop_and_transform_bitmap_data(snapshot, sx, sy, sw, sh, options)
|
ImageBitmap::crop_and_transform_bitmap_data(snapshot, sx, sy, sw, sh, options)
|
||||||
else {
|
else {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -389,20 +389,20 @@ impl ImageBitmap {
|
||||||
ImageBitmapSource::HTMLVideoElement(ref video) => {
|
ImageBitmapSource::HTMLVideoElement(ref video) => {
|
||||||
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
||||||
if !video.is_usable() {
|
if !video.is_usable() {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 6.1. If image's networkState attribute is NETWORK_EMPTY, then return
|
// Step 6.1. If image's networkState attribute is NETWORK_EMPTY, then return
|
||||||
// a promise rejected with an "InvalidStateError" DOMException.
|
// a promise rejected with an "InvalidStateError" DOMException.
|
||||||
if video.is_network_state_empty() {
|
if video.is_network_state_empty() {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no ImageBitmap object can be constructed, then the promise is rejected instead.
|
// If no ImageBitmap object can be constructed, then the promise is rejected instead.
|
||||||
let Some(snapshot) = video.get_current_frame_data() else {
|
let Some(snapshot) = video.get_current_frame_data() else {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ impl ImageBitmap {
|
||||||
let Some(bitmap_data) =
|
let Some(bitmap_data) =
|
||||||
ImageBitmap::crop_and_transform_bitmap_data(snapshot, sx, sy, sw, sh, options)
|
ImageBitmap::crop_and_transform_bitmap_data(snapshot, sx, sy, sw, sh, options)
|
||||||
else {
|
else {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -429,13 +429,13 @@ impl ImageBitmap {
|
||||||
ImageBitmapSource::HTMLCanvasElement(ref canvas) => {
|
ImageBitmapSource::HTMLCanvasElement(ref canvas) => {
|
||||||
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
||||||
if canvas.get_size().is_empty() {
|
if canvas.get_size().is_empty() {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no ImageBitmap object can be constructed, then the promise is rejected instead.
|
// If no ImageBitmap object can be constructed, then the promise is rejected instead.
|
||||||
let Some(snapshot) = canvas.get_image_data() else {
|
let Some(snapshot) = canvas.get_image_data() else {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ impl ImageBitmap {
|
||||||
let Some(bitmap_data) =
|
let Some(bitmap_data) =
|
||||||
ImageBitmap::crop_and_transform_bitmap_data(snapshot, sx, sy, sw, sh, options)
|
ImageBitmap::crop_and_transform_bitmap_data(snapshot, sx, sy, sw, sh, options)
|
||||||
else {
|
else {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -460,13 +460,13 @@ impl ImageBitmap {
|
||||||
ImageBitmapSource::ImageBitmap(ref bitmap) => {
|
ImageBitmapSource::ImageBitmap(ref bitmap) => {
|
||||||
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
||||||
if bitmap.is_detached() {
|
if bitmap.is_detached() {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no ImageBitmap object can be constructed, then the promise is rejected instead.
|
// If no ImageBitmap object can be constructed, then the promise is rejected instead.
|
||||||
let Some(snapshot) = bitmap.bitmap_data().clone() else {
|
let Some(snapshot) = bitmap.bitmap_data().clone() else {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ impl ImageBitmap {
|
||||||
let Some(bitmap_data) =
|
let Some(bitmap_data) =
|
||||||
ImageBitmap::crop_and_transform_bitmap_data(snapshot, sx, sy, sw, sh, options)
|
ImageBitmap::crop_and_transform_bitmap_data(snapshot, sx, sy, sw, sh, options)
|
||||||
else {
|
else {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -491,13 +491,13 @@ impl ImageBitmap {
|
||||||
ImageBitmapSource::OffscreenCanvas(ref canvas) => {
|
ImageBitmapSource::OffscreenCanvas(ref canvas) => {
|
||||||
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
// <https://html.spec.whatwg.org/multipage/#check-the-usability-of-the-image-argument>
|
||||||
if canvas.get_size().is_empty() {
|
if canvas.get_size().is_empty() {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no ImageBitmap object can be constructed, then the promise is rejected instead.
|
// If no ImageBitmap object can be constructed, then the promise is rejected instead.
|
||||||
let Some(snapshot) = canvas.get_image_data() else {
|
let Some(snapshot) = canvas.get_image_data() else {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -506,7 +506,7 @@ impl ImageBitmap {
|
||||||
let Some(bitmap_data) =
|
let Some(bitmap_data) =
|
||||||
ImageBitmap::crop_and_transform_bitmap_data(snapshot, sx, sy, sw, sh, options)
|
ImageBitmap::crop_and_transform_bitmap_data(snapshot, sx, sy, sw, sh, options)
|
||||||
else {
|
else {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -582,7 +582,7 @@ impl ImageBitmap {
|
||||||
// Step 6.2. If IsDetachedBuffer(buffer) is true, then return a promise rejected
|
// Step 6.2. If IsDetachedBuffer(buffer) is true, then return a promise rejected
|
||||||
// with an "InvalidStateError" DOMException.
|
// with an "InvalidStateError" DOMException.
|
||||||
if image_data.is_detached() {
|
if image_data.is_detached() {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ impl ImageBitmap {
|
||||||
let Some(bitmap_data) =
|
let Some(bitmap_data) =
|
||||||
ImageBitmap::crop_and_transform_bitmap_data(snapshot, sx, sy, sw, sh, options)
|
ImageBitmap::crop_and_transform_bitmap_data(snapshot, sx, sy, sw, sh, options)
|
||||||
else {
|
else {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ impl ImageBitmapRenderingContextMethods<crate::DomTypeHolder> for ImageBitmapRen
|
||||||
// is set to true, then throw an "InvalidStateError"
|
// is set to true, then throw an "InvalidStateError"
|
||||||
// DOMException.
|
// DOMException.
|
||||||
if image_bitmap.is_detached() {
|
if image_bitmap.is_detached() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 4. Run the steps to set an ImageBitmapRenderingContext's
|
// Step 4. Run the steps to set an ImageBitmapRenderingContext's
|
||||||
|
|
|
@ -92,7 +92,7 @@ impl ImageData {
|
||||||
// then throw an "InvalidStateError" DOMException.
|
// then throw an "InvalidStateError" DOMException.
|
||||||
if !matches!(settings.pixelFormat, ImageDataPixelFormat::Rgba_unorm8) {
|
if !matches!(settings.pixelFormat, ImageDataPixelFormat::Rgba_unorm8) {
|
||||||
// we currently support only rgba-unorm8
|
// we currently support only rgba-unorm8
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
// 3. Initialize the data attribute of imageData to source.
|
// 3. Initialize the data attribute of imageData to source.
|
||||||
HeapBufferSource::<ClampedU8>::from_view(source)
|
HeapBufferSource::<ClampedU8>::from_view(source)
|
||||||
|
@ -252,12 +252,12 @@ impl ImageDataMethods<crate::DomTypeHolder> for ImageData {
|
||||||
// 2. Let length be the buffer source byte length of data.
|
// 2. Let length be the buffer source byte length of data.
|
||||||
let length = data.len();
|
let length = data.len();
|
||||||
if length == 0 {
|
if length == 0 {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
// 3. If length is not a nonzero integral multiple of bytesPerPixel,
|
// 3. If length is not a nonzero integral multiple of bytesPerPixel,
|
||||||
// then throw an "InvalidStateError" DOMException.
|
// then throw an "InvalidStateError" DOMException.
|
||||||
if length % bytes_per_pixel != 0 {
|
if length % bytes_per_pixel != 0 {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
// 4. Let length be length divided by bytesPerPixel.
|
// 4. Let length be length divided by bytesPerPixel.
|
||||||
let length = length / bytes_per_pixel;
|
let length = length / bytes_per_pixel;
|
||||||
|
|
|
@ -198,12 +198,12 @@ impl Transferable for OffscreenCanvas {
|
||||||
// Step 1. If value's context mode is not equal to none, then throw an
|
// Step 1. If value's context mode is not equal to none, then throw an
|
||||||
// "InvalidStateError" DOMException.
|
// "InvalidStateError" DOMException.
|
||||||
if !self.context.borrow().is_none() {
|
if !self.context.borrow().is_none() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(#37882): Allow to transfer with a placeholder canvas element.
|
// TODO(#37882): Allow to transfer with a placeholder canvas element.
|
||||||
if self.placeholder.is_some() {
|
if self.placeholder.is_some() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2. Set value's context mode to detached.
|
// Step 2. Set value's context mode to detached.
|
||||||
|
@ -294,7 +294,7 @@ impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {
|
||||||
// Step 3. Throw an "InvalidStateError" DOMException if the
|
// Step 3. Throw an "InvalidStateError" DOMException if the
|
||||||
// OffscreenCanvas object's context mode is detached.
|
// OffscreenCanvas object's context mode is detached.
|
||||||
if let Some(OffscreenRenderingContext::Detached) = *self.context.borrow() {
|
if let Some(OffscreenRenderingContext::Detached) = *self.context.borrow() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
match id.str() {
|
match id.str() {
|
||||||
|
@ -358,20 +358,20 @@ impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {
|
||||||
// internal slot is set to true, then throw an "InvalidStateError"
|
// internal slot is set to true, then throw an "InvalidStateError"
|
||||||
// DOMException.
|
// DOMException.
|
||||||
if let Some(OffscreenRenderingContext::Detached) = *self.context.borrow() {
|
if let Some(OffscreenRenderingContext::Detached) = *self.context.borrow() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2. If this OffscreenCanvas object's context mode is set to none,
|
// Step 2. If this OffscreenCanvas object's context mode is set to none,
|
||||||
// then throw an "InvalidStateError" DOMException.
|
// then throw an "InvalidStateError" DOMException.
|
||||||
if self.context.borrow().is_none() {
|
if self.context.borrow().is_none() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3. Let image be a newly created ImageBitmap object that
|
// Step 3. Let image be a newly created ImageBitmap object that
|
||||||
// references the same underlying bitmap data as this OffscreenCanvas
|
// references the same underlying bitmap data as this OffscreenCanvas
|
||||||
// object's bitmap.
|
// object's bitmap.
|
||||||
let Some(snapshot) = self.get_image_data() else {
|
let Some(snapshot) = self.get_image_data() else {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
};
|
};
|
||||||
|
|
||||||
let image_bitmap = ImageBitmap::new(&self.global(), snapshot, can_gc);
|
let image_bitmap = ImageBitmap::new(&self.global(), snapshot, can_gc);
|
||||||
|
@ -399,7 +399,7 @@ impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {
|
||||||
// then return a promise rejected with an "InvalidStateError"
|
// then return a promise rejected with an "InvalidStateError"
|
||||||
// DOMException.
|
// DOMException.
|
||||||
if let Some(OffscreenRenderingContext::Detached) = *self.context.borrow() {
|
if let Some(OffscreenRenderingContext::Detached) = *self.context.borrow() {
|
||||||
promise.reject_error(Error::InvalidState, can_gc);
|
promise.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +421,7 @@ impl OffscreenCanvasMethods<crate::DomTypeHolder> for OffscreenCanvas {
|
||||||
|
|
||||||
// Step 4. Let bitmap be a copy of this's bitmap.
|
// Step 4. Let bitmap be a copy of this's bitmap.
|
||||||
let Some(mut snapshot) = self.get_image_data() else {
|
let Some(mut snapshot) = self.get_image_data() else {
|
||||||
promise.reject_error(Error::InvalidState, can_gc);
|
promise.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return promise;
|
return promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ impl Convert<Error> for RulesMutateError {
|
||||||
RulesMutateError::Syntax => Error::Syntax(None),
|
RulesMutateError::Syntax => Error::Syntax(None),
|
||||||
RulesMutateError::IndexSize => Error::IndexSize,
|
RulesMutateError::IndexSize => Error::IndexSize,
|
||||||
RulesMutateError::HierarchyRequest => Error::HierarchyRequest,
|
RulesMutateError::HierarchyRequest => Error::HierarchyRequest,
|
||||||
RulesMutateError::InvalidState => Error::InvalidState,
|
RulesMutateError::InvalidState => Error::InvalidState(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -166,7 +166,7 @@ impl DataTransferItemListMethods<crate::DomTypeHolder> for DataTransferItemList
|
||||||
let mut option = self.data_store.borrow_mut();
|
let mut option = self.data_store.borrow_mut();
|
||||||
let data_store = match option.as_mut() {
|
let data_store = match option.as_mut() {
|
||||||
Some(value) if value.mode() == Mode::ReadWrite => value,
|
Some(value) if value.mode() == Mode::ReadWrite => value,
|
||||||
_ => return Err(Error::InvalidState),
|
_ => return Err(Error::InvalidState(None)),
|
||||||
};
|
};
|
||||||
|
|
||||||
let index = index as usize;
|
let index = index as usize;
|
||||||
|
|
|
@ -3139,13 +3139,13 @@ impl Document {
|
||||||
}
|
}
|
||||||
// Step 6: If document is an XML document, then throw an "InvalidStateError" DOMException.
|
// Step 6: If document is an XML document, then throw an "InvalidStateError" DOMException.
|
||||||
if !self.is_html_document() {
|
if !self.is_html_document() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 7: If document's throw-on-dynamic-markup-insertion counter is greater than 0,
|
// Step 7: If document's throw-on-dynamic-markup-insertion counter is greater than 0,
|
||||||
// then throw an "InvalidStateError" DOMException.
|
// then throw an "InvalidStateError" DOMException.
|
||||||
if self.throw_on_dynamic_markup_insertion_counter.get() > 0 {
|
if self.throw_on_dynamic_markup_insertion_counter.get() > 0 {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 8: If document's active parser was aborted is true, then return.
|
// Step 8: If document's active parser was aborted is true, then return.
|
||||||
|
@ -5663,12 +5663,12 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
|
||||||
) -> Fallible<DomRoot<Document>> {
|
) -> Fallible<DomRoot<Document>> {
|
||||||
// Step 1
|
// Step 1
|
||||||
if !self.is_html_document() {
|
if !self.is_html_document() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
if self.throw_on_dynamic_markup_insertion_counter.get() > 0 {
|
if self.throw_on_dynamic_markup_insertion_counter.get() > 0 {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3
|
// Step 3
|
||||||
|
@ -5808,12 +5808,12 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
|
||||||
fn Close(&self, can_gc: CanGc) -> ErrorResult {
|
fn Close(&self, can_gc: CanGc) -> ErrorResult {
|
||||||
if !self.is_html_document() {
|
if !self.is_html_document() {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if self.throw_on_dynamic_markup_insertion_counter.get() > 0 {
|
if self.throw_on_dynamic_markup_insertion_counter.get() > 0 {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
let parser = match self.get_current_parser() {
|
let parser = match self.get_current_parser() {
|
||||||
|
|
|
@ -860,7 +860,7 @@ impl DOMMatrixReadOnlyMethods<crate::DomTypeHolder> for DOMMatrixReadOnly {
|
||||||
!mat.m43.is_finite() ||
|
!mat.m43.is_finite() ||
|
||||||
!mat.m44.is_finite()
|
!mat.m44.is_finite()
|
||||||
{
|
{
|
||||||
return Err(error::Error::InvalidState);
|
return Err(error::Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
let cx = GlobalScope::get_cx();
|
let cx = GlobalScope::get_cx();
|
||||||
|
|
|
@ -1132,7 +1132,7 @@ impl EventTargetMethods<crate::DomTypeHolder> for EventTarget {
|
||||||
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
|
// https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent
|
||||||
fn DispatchEvent(&self, event: &Event, can_gc: CanGc) -> Fallible<bool> {
|
fn DispatchEvent(&self, event: &Event, can_gc: CanGc) -> Fallible<bool> {
|
||||||
if event.dispatching() || !event.initialized() {
|
if event.dispatching() || !event.initialized() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
event.set_trusted(false);
|
event.set_trusted(false);
|
||||||
Ok(self.dispatch_event(event, can_gc))
|
Ok(self.dispatch_event(event, can_gc))
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl ExtendableEventMethods<crate::DomTypeHolder> for ExtendableEvent {
|
||||||
fn WaitUntil(&self, _cx: JSContext, _val: HandleValue) -> ErrorResult {
|
fn WaitUntil(&self, _cx: JSContext, _val: HandleValue) -> ErrorResult {
|
||||||
// Step 1
|
// Step 1
|
||||||
if !self.extensions_allowed {
|
if !self.extensions_allowed {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
// Step 2
|
// Step 2
|
||||||
// TODO add a extended_promises array to enqueue the `val`
|
// TODO add a extended_promises array to enqueue the `val`
|
||||||
|
|
|
@ -490,7 +490,7 @@ impl FileReader {
|
||||||
|
|
||||||
// If fr’s state is "loading", throw an InvalidStateError DOMException.
|
// If fr’s state is "loading", throw an InvalidStateError DOMException.
|
||||||
if self.ready_state.get() == FileReaderReadyState::Loading {
|
if self.ready_state.get() == FileReaderReadyState::Loading {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set fr’s state to "loading".
|
// Set fr’s state to "loading".
|
||||||
|
|
|
@ -129,7 +129,7 @@ impl FormDataMethods<crate::DomTypeHolder> for FormData {
|
||||||
can_gc,
|
can_gc,
|
||||||
)),
|
)),
|
||||||
// Step 1.3. If list is null, then throw an "InvalidStateError" DOMException.
|
// Step 1.3. If list is null, then throw an "InvalidStateError" DOMException.
|
||||||
None => Err(Error::InvalidState),
|
None => Err(Error::InvalidState(None)),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ impl GamepadHapticActuatorMethods<crate::DomTypeHolder> for GamepadHapticActuato
|
||||||
|
|
||||||
let document = self.global().as_window().Document();
|
let document = self.global().as_window().Document();
|
||||||
if !document.is_fully_active() {
|
if !document.is_fully_active() {
|
||||||
playing_effect_promise.reject_error(Error::InvalidState, can_gc);
|
playing_effect_promise.reject_error(Error::InvalidState(None), can_gc);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.sequence_id.set(self.sequence_id.get().wrapping_add(1));
|
self.sequence_id.set(self.sequence_id.get().wrapping_add(1));
|
||||||
|
@ -259,7 +259,7 @@ impl GamepadHapticActuatorMethods<crate::DomTypeHolder> for GamepadHapticActuato
|
||||||
|
|
||||||
let document = self.global().as_window().Document();
|
let document = self.global().as_window().Document();
|
||||||
if !document.is_fully_active() {
|
if !document.is_fully_active() {
|
||||||
promise.reject_error(Error::InvalidState, can_gc);
|
promise.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -401,7 +401,7 @@ impl HTMLCanvasElementMethods<crate::DomTypeHolder> for HTMLCanvasElement {
|
||||||
// > is set to placeholder, the user agent must throw an "InvalidStateError" DOMException and leave the
|
// > is set to placeholder, the user agent must throw an "InvalidStateError" DOMException and leave the
|
||||||
// > attribute's value unchanged.
|
// > attribute's value unchanged.
|
||||||
if let Some(RenderingContext::Placeholder(_)) = *self.context_mode.borrow() {
|
if let Some(RenderingContext::Placeholder(_)) = *self.context_mode.borrow() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = if value > UNSIGNED_LONG_MAX {
|
let value = if value > UNSIGNED_LONG_MAX {
|
||||||
|
@ -423,7 +423,7 @@ impl HTMLCanvasElementMethods<crate::DomTypeHolder> for HTMLCanvasElement {
|
||||||
// > is set to placeholder, the user agent must throw an "InvalidStateError" DOMException and leave the
|
// > is set to placeholder, the user agent must throw an "InvalidStateError" DOMException and leave the
|
||||||
// > attribute's value unchanged.
|
// > attribute's value unchanged.
|
||||||
if let Some(RenderingContext::Placeholder(_)) = *self.context_mode.borrow() {
|
if let Some(RenderingContext::Placeholder(_)) = *self.context_mode.borrow() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
let value = if value > UNSIGNED_LONG_MAX {
|
let value = if value > UNSIGNED_LONG_MAX {
|
||||||
|
@ -446,7 +446,7 @@ impl HTMLCanvasElementMethods<crate::DomTypeHolder> for HTMLCanvasElement {
|
||||||
) -> Fallible<Option<RootedRenderingContext>> {
|
) -> Fallible<Option<RootedRenderingContext>> {
|
||||||
// Always throw an InvalidState exception when the canvas is in Placeholder mode (See table in the spec).
|
// Always throw an InvalidState exception when the canvas is in Placeholder mode (See table in the spec).
|
||||||
if let Some(RenderingContext::Placeholder(_)) = *self.context_mode.borrow() {
|
if let Some(RenderingContext::Placeholder(_)) = *self.context_mode.borrow() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(match id.str() {
|
Ok(match id.str() {
|
||||||
|
@ -599,7 +599,7 @@ impl HTMLCanvasElementMethods<crate::DomTypeHolder> for HTMLCanvasElement {
|
||||||
if self.context_mode.borrow().is_some() {
|
if self.context_mode.borrow().is_some() {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
// If this canvas element's context mode is not set to none, throw an "InvalidStateError" DOMException.
|
// If this canvas element's context mode is not set to none, throw an "InvalidStateError" DOMException.
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
|
|
|
@ -204,7 +204,7 @@ impl HTMLImageElement {
|
||||||
|
|
||||||
match self.current_request.borrow().state {
|
match self.current_request.borrow().state {
|
||||||
// If image's current request's state is broken, then throw an "InvalidStateError" DOMException.
|
// If image's current request's state is broken, then throw an "InvalidStateError" DOMException.
|
||||||
State::Broken => Err(Error::InvalidState),
|
State::Broken => Err(Error::InvalidState(None)),
|
||||||
State::CompletelyAvailable => Ok(true),
|
State::CompletelyAvailable => Ok(true),
|
||||||
// If image is not fully decodable, then return bad.
|
// If image is not fully decodable, then return bad.
|
||||||
State::PartiallyAvailable | State::Unavailable => Ok(false),
|
State::PartiallyAvailable | State::Unavailable => Ok(false),
|
||||||
|
|
|
@ -846,13 +846,13 @@ impl HTMLInputElement {
|
||||||
fn step_up_or_down(&self, n: i32, dir: StepDirection, can_gc: CanGc) -> ErrorResult {
|
fn step_up_or_down(&self, n: i32, dir: StepDirection, can_gc: CanGc) -> ErrorResult {
|
||||||
// Step 1
|
// Step 1
|
||||||
if !self.does_value_as_number_apply() {
|
if !self.does_value_as_number_apply() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
let step_base = self.step_base();
|
let step_base = self.step_base();
|
||||||
// Step 2
|
// Step 2
|
||||||
let allowed_value_step = match self.allowed_value_step() {
|
let allowed_value_step = match self.allowed_value_step() {
|
||||||
Some(avs) => avs,
|
Some(avs) => avs,
|
||||||
None => return Err(Error::InvalidState),
|
None => return Err(Error::InvalidState(None)),
|
||||||
};
|
};
|
||||||
let minimum = self.minimum();
|
let minimum = self.minimum();
|
||||||
let maximum = self.maximum();
|
let maximum = self.maximum();
|
||||||
|
@ -1716,7 +1716,7 @@ impl HTMLInputElementMethods<crate::DomTypeHolder> for HTMLInputElement {
|
||||||
let fl = FileList::new(&window, vec![], can_gc);
|
let fl = FileList::new(&window, vec![], can_gc);
|
||||||
self.filelist.set(Some(&fl));
|
self.filelist.set(Some(&fl));
|
||||||
} else {
|
} else {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1765,7 +1765,7 @@ impl HTMLInputElementMethods<crate::DomTypeHolder> for HTMLInputElement {
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
rooted!(in(*cx) let value = value);
|
rooted!(in(*cx) let value = value);
|
||||||
if !self.does_value_as_date_apply() {
|
if !self.does_value_as_date_apply() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
if value.is_null() {
|
if value.is_null() {
|
||||||
return self.SetValue(DOMString::from(""), can_gc);
|
return self.SetValue(DOMString::from(""), can_gc);
|
||||||
|
@ -1807,7 +1807,7 @@ impl HTMLInputElementMethods<crate::DomTypeHolder> for HTMLInputElement {
|
||||||
if value.is_infinite() {
|
if value.is_infinite() {
|
||||||
Err(Error::Type("value is not finite".to_string()))
|
Err(Error::Type("value is not finite".to_string()))
|
||||||
} else if !self.does_value_as_number_apply() {
|
} else if !self.does_value_as_number_apply() {
|
||||||
Err(Error::InvalidState)
|
Err(Error::InvalidState(None))
|
||||||
} else if value.is_nan() {
|
} else if value.is_nan() {
|
||||||
self.SetValue(DOMString::from(""), can_gc)
|
self.SetValue(DOMString::from(""), can_gc)
|
||||||
} else if let Some(converted) = self.convert_number_to_string(value) {
|
} else if let Some(converted) = self.convert_number_to_string(value) {
|
||||||
|
|
|
@ -163,7 +163,7 @@ impl IDBDatabaseMethods<crate::DomTypeHolder> for IDBDatabase {
|
||||||
|
|
||||||
// Step 2: if close flag is set, throw error
|
// Step 2: if close flag is set, throw error
|
||||||
if self.closing.get() {
|
if self.closing.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3
|
// Step 3
|
||||||
|
@ -198,7 +198,7 @@ impl IDBDatabaseMethods<crate::DomTypeHolder> for IDBDatabase {
|
||||||
// Step 2
|
// Step 2
|
||||||
let upgrade_transaction = match self.upgrade_transaction.get() {
|
let upgrade_transaction = match self.upgrade_transaction.get() {
|
||||||
Some(txn) => txn,
|
Some(txn) => txn,
|
||||||
None => return Err(Error::InvalidState),
|
None => return Err(Error::InvalidState(None)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Step 3
|
// Step 3
|
||||||
|
@ -276,7 +276,7 @@ impl IDBDatabaseMethods<crate::DomTypeHolder> for IDBDatabase {
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
warn!("Object store creation failed in idb thread");
|
warn!("Object store creation failed in idb thread");
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
};
|
};
|
||||||
|
|
||||||
self.object_store_names.borrow_mut().push(name);
|
self.object_store_names.borrow_mut().push(name);
|
||||||
|
@ -289,7 +289,7 @@ impl IDBDatabaseMethods<crate::DomTypeHolder> for IDBDatabase {
|
||||||
let transaction = self.upgrade_transaction.get();
|
let transaction = self.upgrade_transaction.get();
|
||||||
let transaction = match transaction {
|
let transaction = match transaction {
|
||||||
Some(transaction) => transaction,
|
Some(transaction) => transaction,
|
||||||
None => return Err(Error::InvalidState),
|
None => return Err(Error::InvalidState(None)),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Step 3
|
// Step 3
|
||||||
|
@ -330,7 +330,7 @@ impl IDBDatabaseMethods<crate::DomTypeHolder> for IDBDatabase {
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
warn!("Object store deletion failed in idb thread");
|
warn!("Object store deletion failed in idb thread");
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ impl IDBObjectStore {
|
||||||
fn verify_not_deleted(&self) -> ErrorResult {
|
fn verify_not_deleted(&self) -> ErrorResult {
|
||||||
let db = self.transaction.Db();
|
let db = self.transaction.Db();
|
||||||
if !db.object_store_exists(&self.name.borrow()) {
|
if !db.object_store_exists(&self.name.borrow()) {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ impl IDBObjectStore {
|
||||||
// Step 10. Let clone be a clone of value in targetRealm during transaction. Rethrow any exceptions.
|
// Step 10. Let clone be a clone of value in targetRealm during transaction. Rethrow any exceptions.
|
||||||
let cloned_value = structuredclone::write(cx, value, None)?;
|
let cloned_value = structuredclone::write(cx, value, None)?;
|
||||||
let Ok(serialized_value) = bincode::serialize(&cloned_value) else {
|
let Ok(serialized_value) = bincode::serialize(&cloned_value) else {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
};
|
};
|
||||||
|
|
||||||
let (sender, receiver) = indexed_db::create_channel(self.global());
|
let (sender, receiver) = indexed_db::create_channel(self.global());
|
||||||
|
@ -638,7 +638,7 @@ impl IDBObjectStoreMethods<crate::DomTypeHolder> for IDBObjectStore {
|
||||||
|
|
||||||
// Step 5. If transaction is not an upgrade transaction, throw an "InvalidStateError" DOMException.
|
// Step 5. If transaction is not an upgrade transaction, throw an "InvalidStateError" DOMException.
|
||||||
if transaction.Mode() != IDBTransactionMode::Versionchange {
|
if transaction.Mode() != IDBTransactionMode::Versionchange {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
// Step 6. If transaction’s state is not active, throw a "TransactionInactiveError" DOMException.
|
// Step 6. If transaction’s state is not active, throw a "TransactionInactiveError" DOMException.
|
||||||
self.check_transaction_active()?;
|
self.check_transaction_active()?;
|
||||||
|
|
|
@ -263,7 +263,7 @@ impl IDBTransactionMethods<crate::DomTypeHolder> for IDBTransaction {
|
||||||
fn ObjectStore(&self, name: DOMString) -> Fallible<DomRoot<IDBObjectStore>> {
|
fn ObjectStore(&self, name: DOMString) -> Fallible<DomRoot<IDBObjectStore>> {
|
||||||
// Step 1: If transaction has finished, throw an "InvalidStateError" DOMException.
|
// Step 1: If transaction has finished, throw an "InvalidStateError" DOMException.
|
||||||
if self.finished.get() {
|
if self.finished.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2: Check that the object store exists
|
// Step 2: Check that the object store exists
|
||||||
|
@ -332,7 +332,7 @@ impl IDBTransactionMethods<crate::DomTypeHolder> for IDBTransaction {
|
||||||
// This only sets the flags, and does not abort the transaction
|
// This only sets the flags, and does not abort the transaction
|
||||||
// see https://www.w3.org/TR/IndexedDB-2/#abort-a-transaction
|
// see https://www.w3.org/TR/IndexedDB-2/#abort-a-transaction
|
||||||
if self.finished.get() {
|
if self.finished.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.active.set(false);
|
self.active.set(false);
|
||||||
|
|
|
@ -3202,13 +3202,13 @@ impl Node {
|
||||||
)
|
)
|
||||||
.map_err(|error| {
|
.map_err(|error| {
|
||||||
error!("Cannot serialize node: {error}");
|
error!("Cannot serialize node: {error}");
|
||||||
Error::InvalidState
|
Error::InvalidState(None)
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
// FIXME(ajeffrey): Directly convert UTF8 to DOMString
|
// FIXME(ajeffrey): Directly convert UTF8 to DOMString
|
||||||
let string = DOMString::from(String::from_utf8(writer).map_err(|error| {
|
let string = DOMString::from(String::from_utf8(writer).map_err(|error| {
|
||||||
error!("Cannot serialize node: {error}");
|
error!("Cannot serialize node: {error}");
|
||||||
Error::InvalidState
|
Error::InvalidState(None)
|
||||||
})?);
|
})?);
|
||||||
|
|
||||||
Ok(string)
|
Ok(string)
|
||||||
|
|
|
@ -201,7 +201,7 @@ impl NodeIterator {
|
||||||
fn accept_node(&self, node: &Node, can_gc: CanGc) -> Fallible<u16> {
|
fn accept_node(&self, node: &Node, can_gc: CanGc) -> Fallible<u16> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if self.active.get() {
|
if self.active.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
// Step 2.
|
// Step 2.
|
||||||
let n = node.NodeType() - 1;
|
let n = node.NodeType() - 1;
|
||||||
|
|
|
@ -1028,7 +1028,7 @@ impl RangeMethods<crate::DomTypeHolder> for Range {
|
||||||
end.inclusive_ancestors(ShadowIncluding::No)
|
end.inclusive_ancestors(ShadowIncluding::No)
|
||||||
.any(|n| !n.is_inclusive_ancestor_of(&start) && !n.is::<Text>())
|
.any(|n| !n.is_inclusive_ancestor_of(&start) && !n.is::<Text>())
|
||||||
{
|
{
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
|
|
|
@ -284,7 +284,7 @@ impl SelectionMethods<crate::DomTypeHolder> for Selection {
|
||||||
can_gc,
|
can_gc,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Err(Error::InvalidState)
|
Err(Error::InvalidState(None))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ impl SelectionMethods<crate::DomTypeHolder> for Selection {
|
||||||
if let Some(range) = self.range.get() {
|
if let Some(range) = self.range.get() {
|
||||||
self.Collapse(Some(&*range.end_container()), range.end_offset(), can_gc)
|
self.Collapse(Some(&*range.end_container()), range.end_offset(), can_gc)
|
||||||
} else {
|
} else {
|
||||||
Err(Error::InvalidState)
|
Err(Error::InvalidState(None))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ impl SelectionMethods<crate::DomTypeHolder> for Selection {
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
// Step 2
|
// Step 2
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ impl ServiceWorker {
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
// Step 1
|
// Step 1
|
||||||
if let ServiceWorkerState::Redundant = self.state.get() {
|
if let ServiceWorkerState::Redundant = self.state.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
// Step 7
|
// Step 7
|
||||||
let data = structuredclone::write(cx, message, Some(transfer))?;
|
let data = structuredclone::write(cx, message, Some(transfer))?;
|
||||||
|
|
|
@ -63,7 +63,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> {
|
||||||
pub(crate) fn set_dom_start(&self, start: Option<u32>) -> ErrorResult {
|
pub(crate) fn set_dom_start(&self, start: Option<u32>) -> ErrorResult {
|
||||||
// Step 1
|
// Step 1
|
||||||
if !self.element.selection_api_applies() {
|
if !self.element.selection_api_applies() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
@ -96,7 +96,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> {
|
||||||
pub(crate) fn set_dom_end(&self, end: Option<u32>) -> ErrorResult {
|
pub(crate) fn set_dom_end(&self, end: Option<u32>) -> ErrorResult {
|
||||||
// Step 1
|
// Step 1
|
||||||
if !self.element.selection_api_applies() {
|
if !self.element.selection_api_applies() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
@ -118,7 +118,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> {
|
||||||
pub(crate) fn set_dom_direction(&self, direction: Option<DOMString>) -> ErrorResult {
|
pub(crate) fn set_dom_direction(&self, direction: Option<DOMString>) -> ErrorResult {
|
||||||
// Step 1
|
// Step 1
|
||||||
if !self.element.selection_api_applies() {
|
if !self.element.selection_api_applies() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
@ -140,7 +140,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> {
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
// Step 1
|
// Step 1
|
||||||
if !self.element.selection_api_applies() {
|
if !self.element.selection_api_applies() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
@ -163,7 +163,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> {
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
// Step 1
|
// Step 1
|
||||||
if !self.element.selection_api_applies() {
|
if !self.element.selection_api_applies() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
|
|
|
@ -442,7 +442,7 @@ impl TreeWalker {
|
||||||
fn accept_node(&self, node: &Node, can_gc: CanGc) -> Fallible<u16> {
|
fn accept_node(&self, node: &Node, can_gc: CanGc) -> Fallible<u16> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if self.active.get() {
|
if self.active.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
// Step 2.
|
// Step 2.
|
||||||
let n = node.NodeType() - 1;
|
let n = node.NodeType() - 1;
|
||||||
|
|
|
@ -377,7 +377,7 @@ impl GPUCanvasContextMethods<crate::DomTypeHolder> for GPUCanvasContext {
|
||||||
// 1. If this.[[configuration]] is null, throw an InvalidStateError and return.
|
// 1. If this.[[configuration]] is null, throw an InvalidStateError and return.
|
||||||
let configuration = self.configuration.borrow();
|
let configuration = self.configuration.borrow();
|
||||||
let Some(configuration) = configuration.as_ref() else {
|
let Some(configuration) = configuration.as_ref() else {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
};
|
};
|
||||||
// 2. Assert this.[[textureDescriptor]] is not null.
|
// 2. Assert this.[[textureDescriptor]] is not null.
|
||||||
let texture_descriptor = self.texture_descriptor.borrow();
|
let texture_descriptor = self.texture_descriptor.borrow();
|
||||||
|
|
|
@ -259,7 +259,7 @@ impl RTCDataChannel {
|
||||||
|
|
||||||
fn send(&self, source: &SendSource) -> Fallible<()> {
|
fn send(&self, source: &SendSource) -> Fallible<()> {
|
||||||
if self.ready_state.get() != RTCDataChannelState::Open {
|
if self.ready_state.get() != RTCDataChannelState::Open {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
let message = match source {
|
let message = match source {
|
||||||
|
|
|
@ -594,7 +594,7 @@ impl RTCPeerConnectionMethods<crate::DomTypeHolder> for RTCPeerConnection {
|
||||||
fn CreateOffer(&self, _options: &RTCOfferOptions, comp: InRealm, can_gc: CanGc) -> Rc<Promise> {
|
fn CreateOffer(&self, _options: &RTCOfferOptions, comp: InRealm, can_gc: CanGc) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(comp, can_gc);
|
let p = Promise::new_in_current_realm(comp, can_gc);
|
||||||
if self.closed.get() {
|
if self.closed.get() {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
self.offer_promises.borrow_mut().push(p.clone());
|
self.offer_promises.borrow_mut().push(p.clone());
|
||||||
|
@ -611,7 +611,7 @@ impl RTCPeerConnectionMethods<crate::DomTypeHolder> for RTCPeerConnection {
|
||||||
) -> Rc<Promise> {
|
) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(comp, can_gc);
|
let p = Promise::new_in_current_realm(comp, can_gc);
|
||||||
if self.closed.get() {
|
if self.closed.get() {
|
||||||
p.reject_error(Error::InvalidState, can_gc);
|
p.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
self.answer_promises.borrow_mut().push(p.clone());
|
self.answer_promises.borrow_mut().push(p.clone());
|
||||||
|
|
|
@ -143,7 +143,7 @@ impl WebSocket {
|
||||||
fn send_impl(&self, data_byte_len: u64) -> Fallible<bool> {
|
fn send_impl(&self, data_byte_len: u64) -> Fallible<bool> {
|
||||||
let return_after_buffer = match self.ready_state.get() {
|
let return_after_buffer = match self.ready_state.get() {
|
||||||
WebSocketRequestState::Connecting => {
|
WebSocketRequestState::Connecting => {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
},
|
},
|
||||||
WebSocketRequestState::Open => false,
|
WebSocketRequestState::Open => false,
|
||||||
WebSocketRequestState::Closing | WebSocketRequestState::Closed => true,
|
WebSocketRequestState::Closing | WebSocketRequestState::Closed => true,
|
||||||
|
|
|
@ -105,11 +105,11 @@ impl XRFrameMethods<crate::DomTypeHolder> for XRFrame {
|
||||||
can_gc: CanGc,
|
can_gc: CanGc,
|
||||||
) -> Result<Option<DomRoot<XRViewerPose>>, Error> {
|
) -> Result<Option<DomRoot<XRViewerPose>>, Error> {
|
||||||
if self.session != reference.upcast::<XRSpace>().session() {
|
if self.session != reference.upcast::<XRSpace>().session() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.active.get() || !self.animation_frame.get() {
|
if !self.active.get() || !self.animation_frame.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
let to_base = if let Some(to_base) = reference.get_base_transform(&self.data) {
|
let to_base = if let Some(to_base) = reference.get_base_transform(&self.data) {
|
||||||
|
@ -139,10 +139,10 @@ impl XRFrameMethods<crate::DomTypeHolder> for XRFrame {
|
||||||
can_gc: CanGc,
|
can_gc: CanGc,
|
||||||
) -> Result<Option<DomRoot<XRPose>>, Error> {
|
) -> Result<Option<DomRoot<XRPose>>, Error> {
|
||||||
if self.session != space.session() || self.session != base_space.session() {
|
if self.session != space.session() || self.session != base_space.session() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
if !self.active.get() {
|
if !self.active.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
let space = if let Some(space) = self.get_pose(space) {
|
let space = if let Some(space) = self.get_pose(space) {
|
||||||
space
|
space
|
||||||
|
@ -168,10 +168,10 @@ impl XRFrameMethods<crate::DomTypeHolder> for XRFrame {
|
||||||
if self.session != space.upcast::<XRSpace>().session() ||
|
if self.session != space.upcast::<XRSpace>().session() ||
|
||||||
self.session != base_space.session()
|
self.session != base_space.session()
|
||||||
{
|
{
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
if !self.active.get() {
|
if !self.active.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
let joint_frame = if let Some(frame) = space.frame(&self.data) {
|
let joint_frame = if let Some(frame) = space.frame(&self.data) {
|
||||||
frame
|
frame
|
||||||
|
@ -210,12 +210,12 @@ impl XRFrameMethods<crate::DomTypeHolder> for XRFrame {
|
||||||
mut radii: CustomAutoRooterGuard<Float32Array>,
|
mut radii: CustomAutoRooterGuard<Float32Array>,
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
if !self.active.get() {
|
if !self.active.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
for joint_space in &joint_spaces {
|
for joint_space in &joint_spaces {
|
||||||
if self.session != joint_space.upcast::<XRSpace>().session() {
|
if self.session != joint_space.upcast::<XRSpace>().session() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,17 +256,17 @@ impl XRFrameMethods<crate::DomTypeHolder> for XRFrame {
|
||||||
mut transforms: CustomAutoRooterGuard<Float32Array>,
|
mut transforms: CustomAutoRooterGuard<Float32Array>,
|
||||||
) -> Result<bool, Error> {
|
) -> Result<bool, Error> {
|
||||||
if !self.active.get() {
|
if !self.active.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
for space in &spaces {
|
for space in &spaces {
|
||||||
if self.session != space.session() {
|
if self.session != space.session() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.session != base_space.session() {
|
if self.session != base_space.session() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
if spaces.len() * 16 > transforms.len() {
|
if spaces.len() * 16 > transforms.len() {
|
||||||
|
|
|
@ -57,12 +57,12 @@ impl XRMediaBindingMethods<crate::DomTypeHolder> for XRMediaBinding {
|
||||||
) -> Fallible<DomRoot<XRMediaBinding>> {
|
) -> Fallible<DomRoot<XRMediaBinding>> {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
if session.is_ended() {
|
if session.is_ended() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 2.
|
// Step 2.
|
||||||
if !session.is_immersive() {
|
if !session.is_immersive() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Steps 3-5.
|
// Steps 3-5.
|
||||||
|
|
|
@ -118,7 +118,7 @@ impl XRRigidTransformMethods<crate::DomTypeHolder> for XRRigidTransform {
|
||||||
if !rotate.i.is_finite() {
|
if !rotate.i.is_finite() {
|
||||||
// if quaternion has zero norm, we'll get an infinite or NaN
|
// if quaternion has zero norm, we'll get an infinite or NaN
|
||||||
// value for each element. This is preferable to checking for zero.
|
// value for each element. This is preferable to checking for zero.
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
let transform = RigidTransform3D::new(rotate, translate);
|
let transform = RigidTransform3D::new(rotate, translate);
|
||||||
Ok(XRRigidTransform::new_with_proto(
|
Ok(XRRigidTransform::new_with_proto(
|
||||||
|
|
|
@ -671,18 +671,18 @@ impl XRSessionMethods<crate::DomTypeHolder> for XRSession {
|
||||||
fn UpdateRenderState(&self, init: &XRRenderStateInit, _: InRealm) -> ErrorResult {
|
fn UpdateRenderState(&self, init: &XRRenderStateInit, _: InRealm) -> ErrorResult {
|
||||||
// Step 2
|
// Step 2
|
||||||
if self.ended.get() {
|
if self.ended.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
// Step 3:
|
// Step 3:
|
||||||
if let Some(Some(ref layer)) = init.baseLayer {
|
if let Some(Some(ref layer)) = init.baseLayer {
|
||||||
if Dom::from_ref(layer.session()) != Dom::from_ref(self) {
|
if Dom::from_ref(layer.session()) != Dom::from_ref(self) {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 4:
|
// Step 4:
|
||||||
if init.inlineVerticalFieldOfView.is_some() && self.is_immersive() {
|
if init.inlineVerticalFieldOfView.is_some() && self.is_immersive() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://immersive-web.github.io/layers/#updaterenderstatechanges
|
// https://immersive-web.github.io/layers/#updaterenderstatechanges
|
||||||
|
@ -1045,7 +1045,7 @@ impl XRSessionMethods<crate::DomTypeHolder> for XRSession {
|
||||||
supported_frame_rates.is_empty() ||
|
supported_frame_rates.is_empty() ||
|
||||||
self.ended.get()
|
self.ended.get()
|
||||||
{
|
{
|
||||||
promise.reject_error(Error::InvalidState, can_gc);
|
promise.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ impl XRSystemMethods<crate::DomTypeHolder> for XRSystem {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.pending_or_active_session() {
|
if self.pending_or_active_session() {
|
||||||
promise.reject_error(Error::InvalidState, can_gc);
|
promise.reject_error(Error::InvalidState(None), can_gc);
|
||||||
return promise;
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,17 +82,17 @@ impl XRWebGLBindingMethods<crate::DomTypeHolder> for XRWebGLBinding {
|
||||||
};
|
};
|
||||||
// Step 2
|
// Step 2
|
||||||
if session.is_ended() {
|
if session.is_ended() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// step 3
|
// step 3
|
||||||
if context.IsContextLost() {
|
if context.IsContextLost() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 4
|
// Step 4
|
||||||
if !session.is_immersive() {
|
if !session.is_immersive() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Step 5 throw an InvalidStateError If context’s XR compatible boolean is false.
|
// Step 5 throw an InvalidStateError If context’s XR compatible boolean is false.
|
||||||
|
|
|
@ -245,7 +245,7 @@ impl XRWebGLLayerMethods<crate::DomTypeHolder> for XRWebGLLayer {
|
||||||
|
|
||||||
// Step 2
|
// Step 2
|
||||||
if session.is_ended() {
|
if session.is_ended() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
// XXXManishearth step 3: throw error if context is lost
|
// XXXManishearth step 3: throw error if context is lost
|
||||||
// XXXManishearth step 4: check XR compat flag for immersive sessions
|
// XXXManishearth step 4: check XR compat flag for immersive sessions
|
||||||
|
|
|
@ -339,7 +339,7 @@ impl XMLHttpRequestMethods<crate::DomTypeHolder> for XMLHttpRequest {
|
||||||
// Step 1
|
// Step 1
|
||||||
if let Some(window) = DomRoot::downcast::<Window>(self.global()) {
|
if let Some(window) = DomRoot::downcast::<Window>(self.global()) {
|
||||||
if !window.Document().is_fully_active() {
|
if !window.Document().is_fully_active() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ impl XMLHttpRequestMethods<crate::DomTypeHolder> for XMLHttpRequest {
|
||||||
// Step 1: If this’s state is not opened, then throw an "InvalidStateError" DOMException.
|
// Step 1: If this’s state is not opened, then throw an "InvalidStateError" DOMException.
|
||||||
// Step 2: If this’s send() flag is set, then throw an "InvalidStateError" DOMException.
|
// Step 2: If this’s send() flag is set, then throw an "InvalidStateError" DOMException.
|
||||||
if self.ready_state.get() != XMLHttpRequestState::Opened || self.send_flag.get() {
|
if self.ready_state.get() != XMLHttpRequestState::Opened || self.send_flag.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3: Normalize value.
|
// Step 3: Normalize value.
|
||||||
|
@ -521,9 +521,9 @@ impl XMLHttpRequestMethods<crate::DomTypeHolder> for XMLHttpRequest {
|
||||||
// Step 1
|
// Step 1
|
||||||
XMLHttpRequestState::HeadersReceived |
|
XMLHttpRequestState::HeadersReceived |
|
||||||
XMLHttpRequestState::Loading |
|
XMLHttpRequestState::Loading |
|
||||||
XMLHttpRequestState::Done => Err(Error::InvalidState),
|
XMLHttpRequestState::Done => Err(Error::InvalidState(None)),
|
||||||
// Step 2
|
// Step 2
|
||||||
_ if self.send_flag.get() => Err(Error::InvalidState),
|
_ if self.send_flag.get() => Err(Error::InvalidState(None)),
|
||||||
// Step 3
|
// Step 3
|
||||||
_ => {
|
_ => {
|
||||||
self.with_credentials.set(with_credentials);
|
self.with_credentials.set(with_credentials);
|
||||||
|
@ -541,7 +541,7 @@ impl XMLHttpRequestMethods<crate::DomTypeHolder> for XMLHttpRequest {
|
||||||
fn Send(&self, data: Option<DocumentOrXMLHttpRequestBodyInit>, can_gc: CanGc) -> ErrorResult {
|
fn Send(&self, data: Option<DocumentOrXMLHttpRequestBodyInit>, can_gc: CanGc) -> ErrorResult {
|
||||||
// Step 1, 2
|
// Step 1, 2
|
||||||
if self.ready_state.get() != XMLHttpRequestState::Opened || self.send_flag.get() {
|
if self.ready_state.get() != XMLHttpRequestState::Opened || self.send_flag.get() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 3
|
// Step 3
|
||||||
|
@ -873,7 +873,7 @@ impl XMLHttpRequestMethods<crate::DomTypeHolder> for XMLHttpRequest {
|
||||||
// DOMException.
|
// DOMException.
|
||||||
match self.ready_state.get() {
|
match self.ready_state.get() {
|
||||||
XMLHttpRequestState::Loading | XMLHttpRequestState::Done => {
|
XMLHttpRequestState::Loading | XMLHttpRequestState::Done => {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
|
@ -907,7 +907,9 @@ impl XMLHttpRequestMethods<crate::DomTypeHolder> for XMLHttpRequest {
|
||||||
}
|
}
|
||||||
match self.ready_state.get() {
|
match self.ready_state.get() {
|
||||||
// Step 2
|
// Step 2
|
||||||
XMLHttpRequestState::Loading | XMLHttpRequestState::Done => Err(Error::InvalidState),
|
XMLHttpRequestState::Loading | XMLHttpRequestState::Done => {
|
||||||
|
Err(Error::InvalidState(None))
|
||||||
|
},
|
||||||
_ => {
|
_ => {
|
||||||
if self.sync_in_window() {
|
if self.sync_in_window() {
|
||||||
// Step 3
|
// Step 3
|
||||||
|
@ -969,7 +971,7 @@ impl XMLHttpRequestMethods<crate::DomTypeHolder> for XMLHttpRequest {
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
// Step 1
|
// Step 1
|
||||||
_ => Err(Error::InvalidState),
|
_ => Err(Error::InvalidState(None)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,7 +988,7 @@ impl XMLHttpRequestMethods<crate::DomTypeHolder> for XMLHttpRequest {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Step 1
|
// Step 1
|
||||||
_ => Err(Error::InvalidState),
|
_ => Err(Error::InvalidState(None)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1672,7 +1674,7 @@ fn serialize_document(doc: &Document) -> Fallible<DOMString> {
|
||||||
let mut writer = vec![];
|
let mut writer = vec![];
|
||||||
match serialize(&mut writer, &doc.upcast::<Node>(), SerializeOpts::default()) {
|
match serialize(&mut writer, &doc.upcast::<Node>(), SerializeOpts::default()) {
|
||||||
Ok(_) => Ok(DOMString::from(String::from_utf8(writer).unwrap())),
|
Ok(_) => Ok(DOMString::from(String::from_utf8(writer).unwrap())),
|
||||||
Err(_) => Err(Error::InvalidState),
|
Err(_) => Err(Error::InvalidState(None)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ impl XPathResultMethods<crate::DomTypeHolder> for XPathResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.document_changed_since_creation() {
|
if self.document_changed_since_creation() {
|
||||||
return Err(Error::InvalidState);
|
return Err(Error::InvalidState(None));
|
||||||
}
|
}
|
||||||
|
|
||||||
let XPathResultValue::Nodeset(nodes) = &*self.value.borrow() else {
|
let XPathResultValue::Nodeset(nodes) = &*self.value.borrow() else {
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub enum Error {
|
||||||
/// InUseAttributeError DOMException
|
/// InUseAttributeError DOMException
|
||||||
InUseAttribute,
|
InUseAttribute,
|
||||||
/// InvalidStateError DOMException
|
/// InvalidStateError DOMException
|
||||||
InvalidState,
|
InvalidState(Option<String>),
|
||||||
/// SyntaxError DOMException
|
/// SyntaxError DOMException
|
||||||
Syntax(Option<String>),
|
Syntax(Option<String>),
|
||||||
/// NamespaceError DOMException
|
/// NamespaceError DOMException
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue