mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
script: Throw a TypeError
when trying to create an OffscreenCanvas
with an unknown context type (#34276)
* fixing test failures that involves throwing TypeError Signed-off-by: L Ashwin B <lashwinib@gmail.com> * handle all unknown values in a single fallback case Signed-off-by: L Ashwin B <lashwinib@gmail.com> * updating few more test- expectations Signed-off-by: L Ashwin B <lashwinib@gmail.com> --------- Signed-off-by: L Ashwin B <lashwinib@gmail.com>
This commit is contained in:
parent
bd9843405a
commit
1f0b88934b
17 changed files with 23 additions and 32 deletions
|
@ -15,7 +15,7 @@ use crate::dom::bindings::cell::{ref_filter_map, DomRefCell, Ref};
|
|||
use crate::dom::bindings::codegen::Bindings::OffscreenCanvasBinding::{
|
||||
OffscreenCanvasMethods, OffscreenRenderingContext,
|
||||
};
|
||||
use crate::dom::bindings::error::Fallible;
|
||||
use crate::dom::bindings::error::{Error, Fallible};
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot};
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
|
@ -157,18 +157,20 @@ impl OffscreenCanvasMethods for OffscreenCanvas {
|
|||
_cx: JSContext,
|
||||
id: DOMString,
|
||||
_options: HandleValue,
|
||||
) -> Option<OffscreenRenderingContext> {
|
||||
) -> Fallible<Option<OffscreenRenderingContext>> {
|
||||
match &*id {
|
||||
"2d" => self
|
||||
"2d" => Ok(self
|
||||
.get_or_init_2d_context()
|
||||
.map(OffscreenRenderingContext::OffscreenCanvasRenderingContext2D),
|
||||
.map(OffscreenRenderingContext::OffscreenCanvasRenderingContext2D)),
|
||||
/*"webgl" | "experimental-webgl" => self
|
||||
.get_or_init_webgl_context(cx, options)
|
||||
.map(OffscreenRenderingContext::WebGLRenderingContext),
|
||||
"webgl2" | "experimental-webgl2" => self
|
||||
.get_or_init_webgl2_context(cx, options)
|
||||
.map(OffscreenRenderingContext::WebGL2RenderingContext),*/
|
||||
_ => None,
|
||||
_ => Err(Error::Type(String::from(
|
||||
"Unrecognized OffscreenCanvas context type",
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue