diff --git a/moli-renderer-v8/src/context_bootstrap/dom_quad.rs b/moli-renderer-v8/src/context_bootstrap/dom_quad.rs index 6ecee1470e..19892db4e4 100644 --- a/moli-renderer-v8/src/context_bootstrap/dom_quad.rs +++ b/moli-renderer-v8/src/context_bootstrap/dom_quad.rs @@ -82,7 +82,7 @@ struct DomQuadPrototypeDeclaration { } #[derive(WebApiFunctionTemplate)] -#[webapi(interface = web_api_interfaces::DOMQuad)] +#[webapi(interface = web_api_interfaces::DOMQuad, enumerable)] struct DomQuadConstructorDeclaration { #[webapi( static_method = "fromRect", diff --git a/moli-renderer-v8/src/context_bootstrap/dom_rect.rs b/moli-renderer-v8/src/context_bootstrap/dom_rect.rs index 05c907d3df..cfa8034043 100644 --- a/moli-renderer-v8/src/context_bootstrap/dom_rect.rs +++ b/moli-renderer-v8/src/context_bootstrap/dom_rect.rs @@ -136,7 +136,7 @@ struct DomRectPrototypeDeclaration { } #[derive(WebApiFunctionTemplate)] -#[webapi(interface = web_api_interfaces::DOMRectReadOnly)] +#[webapi(interface = web_api_interfaces::DOMRectReadOnly, enumerable)] struct DomRectReadOnlyConstructorDeclaration { #[webapi( static_method = "fromRect", @@ -147,7 +147,7 @@ struct DomRectReadOnlyConstructorDeclaration { } #[derive(WebApiFunctionTemplate)] -#[webapi(interface = web_api_interfaces::DOMRect)] +#[webapi(interface = web_api_interfaces::DOMRect, enumerable)] struct DomRectConstructorDeclaration { #[webapi( static_method = "fromRect", diff --git a/moli-renderer-v8/src/context_bootstrap/exposed_interfaces/tests.rs b/moli-renderer-v8/src/context_bootstrap/exposed_interfaces/tests.rs index cb16aa3448..0552e6f1d5 100644 --- a/moli-renderer-v8/src/context_bootstrap/exposed_interfaces/tests.rs +++ b/moli-renderer-v8/src/context_bootstrap/exposed_interfaces/tests.rs @@ -420,6 +420,37 @@ fn worker_geometry_interfaces_use_worker_specific_matrix_surface() { return error.name; } }; + const operationSets = [ + [DOMPointReadOnly, ["fromPoint"]], + [DOMPointReadOnly.prototype, ["matrixTransform"]], + [DOMPoint, ["fromPoint"]], + [DOMRectReadOnly, ["fromRect"]], + [DOMRect, ["fromRect"]], + [DOMQuad, ["fromRect", "fromQuad"]], + [DOMMatrixReadOnly, [ + "fromMatrix", "fromFloat32Array", "fromFloat64Array" + ]], + [DOMMatrixReadOnly.prototype, [ + "translate", "scale", "scaleNonUniform", "scale3d", "rotate", + "rotateFromVector", "rotateAxisAngle", "skewX", "skewY", + "multiply", "flipX", "flipY", "inverse", "transformPoint", + "toFloat32Array", "toFloat64Array" + ]], + [DOMMatrix, [ + "fromMatrix", "fromFloat32Array", "fromFloat64Array" + ]], + [DOMMatrix.prototype, [ + "multiplySelf", "preMultiplySelf", "translateSelf", "scaleSelf", + "scale3dSelf", "rotateSelf", "rotateFromVectorSelf", + "rotateAxisAngleSelf", "skewXSelf", "skewYSelf", "invertSelf" + ]] + ]; + const hasWebIdlOperationDescriptor = (owner, name) => { + const descriptor = Object.getOwnPropertyDescriptor(owner, name); + return descriptor !== undefined && + typeof descriptor.value === "function" && + descriptor.enumerable && descriptor.writable && descriptor.configurable; + }; return JSON.stringify({ constructors: names.map(name => typeof globalThis[name]).join(","), strings: [ @@ -436,6 +467,9 @@ fn worker_geometry_interfaces_use_worker_specific_matrix_surface() { "setMatrixValue" in DOMMatrix.prototype, "WebKitCSSMatrix" in globalThis ].join(","), + operations: operationSets.every(([owner, operationNames]) => + operationNames.every(name => hasWebIdlOperationDescriptor(owner, name)) + ), lengths: [DOMMatrix.length, DOMMatrixReadOnly.length].join(",") }); })() @@ -450,6 +484,6 @@ fn worker_geometry_interfaces_use_worker_specific_matrix_surface() { assert_eq!( result, - r#"{"constructors":"function,function,function,function,function,function,function","strings":"TypeError,TypeError","tags":"[object DOMMatrix],[object DOMMatrixReadOnly],[object DOMMatrix]","windowOnly":"false,false,false","lengths":"0,0"}"# + r#"{"constructors":"function,function,function,function,function,function,function","strings":"TypeError,TypeError","tags":"[object DOMMatrix],[object DOMMatrixReadOnly],[object DOMMatrix]","windowOnly":"false,false,false","operations":true,"lengths":"0,0"}"# ); } diff --git a/moli-renderer-v8/src/context_bootstrap/geometry_runtime.rs b/moli-renderer-v8/src/context_bootstrap/geometry_runtime.rs index f3182560c2..20f5e81f92 100644 --- a/moli-renderer-v8/src/context_bootstrap/geometry_runtime.rs +++ b/moli-renderer-v8/src/context_bootstrap/geometry_runtime.rs @@ -216,7 +216,7 @@ struct DomPointPrototypeAccessorsDeclaration { } #[derive(WebApiFunctionTemplate)] -#[webapi(interface = web_api_interfaces::DOMPointReadOnly)] +#[webapi(interface = web_api_interfaces::DOMPointReadOnly, enumerable)] struct DomPointReadOnlyPrototypeMethodsDeclaration { #[webapi( method = "matrixTransform", @@ -243,14 +243,14 @@ struct DomPointReadOnlyPrototypeAccessorsDeclaration { } #[derive(WebApiFunctionTemplate)] -#[webapi(interface = web_api_interfaces::DOMPoint)] +#[webapi(interface = web_api_interfaces::DOMPoint, enumerable)] struct DomPointConstructorDeclaration { #[webapi(static_method = "fromPoint", length = 0, callback = dom_point_from_point_callback)] from_point: (), } #[derive(WebApiFunctionTemplate)] -#[webapi(interface = web_api_interfaces::DOMPointReadOnly)] +#[webapi(interface = web_api_interfaces::DOMPointReadOnly, enumerable)] struct DomPointReadOnlyConstructorDeclaration { #[webapi( static_method = "fromPoint", @@ -495,7 +495,11 @@ struct DomMatrixPrototypeMethodsDeclaration { #[derive(WebApiFunctionTemplate)] #[webapi(name = "DOMMatrix", enumerable)] struct DomMatrixWindowPrototypeMethodsDeclaration { - #[webapi(method = "setMatrixValue", length = 1, callback = dom_matrix_set_matrix_value_callback)] + #[webapi( + method = "setMatrixValue", + length = 1, + callback = dom_matrix_set_matrix_value_callback + )] set_matrix_value: (), } diff --git a/moli-renderer-v8/src/script_vm/tests/browser_api/misc/extracted/css_surface.rs b/moli-renderer-v8/src/script_vm/tests/browser_api/misc/extracted/css_surface.rs index 3a75c70a04..52e761f138 100644 --- a/moli-renderer-v8/src/script_vm/tests/browser_api/misc/extracted/css_surface.rs +++ b/moli-renderer-v8/src/script_vm/tests/browser_api/misc/extracted/css_surface.rs @@ -165,3 +165,36 @@ fn dom_matrix_exposes_webkit_css_matrix_alias() { assert_eq!(result, "true|true|DOMMatrix|true|true|true,false,true"); } + +#[test] +fn dom_matrix_window_operations_use_webidl_descriptors() { + let mut vm = new_storage_test_vm("https://dommatrix-operation-descriptors.test/"); + + let result = vm + .eval( + r#" +(() => { + const descriptorShape = (owner, name) => { + const descriptor = Object.getOwnPropertyDescriptor(owner, name); + return [ + typeof descriptor.value, + descriptor.value.length, + descriptor.enumerable, + descriptor.writable, + descriptor.configurable + ].join(","); + }; + return [ + descriptorShape(DOMMatrixReadOnly.prototype, "toString"), + descriptorShape(DOMMatrix.prototype, "setMatrixValue") + ].join("|"); +})() +"#, + ) + .expect("DOMMatrix Window operation descriptors should evaluate"); + + assert_eq!( + result, + "function,0,true,true,true|function,1,true,true,true" + ); +}