aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-08-19 18:17:16 -0700
committerGravatar GitHub <noreply@github.com> 2023-08-19 18:17:16 -0700
commit507761b4637a83d10e2f8b64ff870881bba7c14b (patch)
treecb3a2920ed18832df3c7075bd8e21b15b1184a3d /test
parent196620183fd20ca42b363c5f947af1dc979f888f (diff)
downloadbun-507761b4637a83d10e2f8b64ff870881bba7c14b.tar.gz
bun-507761b4637a83d10e2f8b64ff870881bba7c14b.tar.zst
bun-507761b4637a83d10e2f8b64ff870881bba7c14b.zip
Fix crash impacting sharp & resvg (#4221)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test')
-rw-r--r--test/js/third_party/resvg/bbox.test.js31
1 files changed, 20 insertions, 11 deletions
diff --git a/test/js/third_party/resvg/bbox.test.js b/test/js/third_party/resvg/bbox.test.js
index d80e99cdd..0c8a19578 100644
--- a/test/js/third_party/resvg/bbox.test.js
+++ b/test/js/third_party/resvg/bbox.test.js
@@ -1,6 +1,16 @@
import { test, expect } from "bun:test";
import { Resvg } from "@resvg/resvg-js";
+const opts = {
+ fitTo: {
+ mode: "width",
+ value: 500,
+ },
+ font: {
+ loadSystemFonts: false,
+ },
+};
+
const svg = `<svg viewBox="-40 0 180 260" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g fill="green" transform="rotate(-10 50 100) translate(-36 45.5) skewX(40) scale(1 0.5)">
<path id="heart" d="M 10,30 A 20,20 0,0,1 50,30 A 20,20 0,0,1 90,30 Q 90,60 50,90 Q 10,60 10,30 z" />
@@ -20,16 +30,6 @@ for (let Class of [
},
]) {
test(`bbox ${Class.name}`, () => {
- const opts = {
- fitTo: {
- mode: "width",
- value: 500,
- },
- font: {
- loadSystemFonts: false,
- },
- };
-
const resvg = new Class(svg, opts);
const bbox = resvg.getBBox();
@@ -37,11 +37,12 @@ for (let Class of [
expect(resvg.height).toBe(260);
if (bbox) resvg.cropByBBox(bbox);
- const pngData = resvg.render();
expect(bbox.width).toBe(112.20712208389321);
expect(bbox.height).toBe(81);
+ const pngData = resvg.render();
+
expect(pngData.width).toBe(500);
expect(pngData.height).toBe(362);
@@ -51,3 +52,11 @@ for (let Class of [
}
});
}
+
+test("napi_create_external_buffer", () => {
+ const resvg = new Resvg(svg, opts);
+ for (let i = 0; i < 10; i++) {
+ resvg.render().asPng();
+ Bun.gc();
+ }
+});