mirror of
https://github.com/oven-sh/bun
synced 2026-02-14 12:51:54 +00:00
Update WebKit (#1165)
* Update WebKit * Fix `DataView` and non-8 bit sized typed arrays with TextDecoder * New WebKit Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -262,9 +262,6 @@ ZIG_REPR_TYPE JSFunctionCall(void* globalObject, void* callFrame);
|
||||
bool my_callback_function(void* arg0);
|
||||
|
||||
bool my_callback_function(void* arg0) {
|
||||
#ifdef INJECT_BEFORE
|
||||
INJECT_BEFORE;
|
||||
#endif
|
||||
EncodedJSValue arguments[1] = {
|
||||
PTR_TO_JSVALUE(arg0)
|
||||
};
|
||||
|
||||
@@ -2,125 +2,135 @@ import { it, expect } from "bun:test";
|
||||
import * as os from "node:os";
|
||||
|
||||
it("arch", () => {
|
||||
expect(["x64", "x86", "arm64"].some(arch => os.arch() === arch)).toBe(true);
|
||||
expect(["x64", "x86", "arm64"].some((arch) => os.arch() === arch)).toBe(true);
|
||||
});
|
||||
|
||||
it("endianness", () => {
|
||||
expect(/[BL]E/.test(os.endianness())).toBe(true);
|
||||
expect(/[BL]E/.test(os.endianness())).toBe(true);
|
||||
});
|
||||
|
||||
it("freemem", () => {
|
||||
expect(os.freemem() > 0).toBe(true);
|
||||
expect(os.freemem() > 0).toBe(true);
|
||||
});
|
||||
|
||||
it("totalmem", () => {
|
||||
expect(os.totalmem() > 0).toBe(true);
|
||||
expect(os.totalmem() > 0).toBe(true);
|
||||
});
|
||||
|
||||
it("getPriority", () => {
|
||||
expect(os.getPriority()).toBe(0);
|
||||
expect(os.getPriority(0)).toBe(0);
|
||||
expect(os.getPriority()).toBe(0);
|
||||
expect(os.getPriority(0)).toBe(0);
|
||||
});
|
||||
|
||||
it("setPriority", () => {
|
||||
expect(os.setPriority(0, 2)).toBe(undefined);
|
||||
expect(os.getPriority()).toBe(2);
|
||||
expect(os.setPriority(5)).toBe(undefined);
|
||||
expect(os.getPriority()).toBe(5);
|
||||
expect(os.setPriority(0, 2)).toBe(undefined);
|
||||
expect(os.getPriority()).toBe(2);
|
||||
expect(os.setPriority(5)).toBe(undefined);
|
||||
expect(os.getPriority()).toBe(5);
|
||||
});
|
||||
|
||||
it("loadavg", () => {
|
||||
expect(os.loadavg().length === 3).toBe(true);
|
||||
expect(os.loadavg().length === 3).toBe(true);
|
||||
});
|
||||
|
||||
it("homedir", () => {
|
||||
expect(os.homedir() !== "unknown").toBe(true);
|
||||
expect(os.homedir() !== "unknown").toBe(true);
|
||||
});
|
||||
|
||||
it("tmpdir", () => {
|
||||
if (process.platform === 'win32') {
|
||||
expect(os.tmpdir()).toBe((process.env.TEMP || process.env.TMP));
|
||||
expect(os.tmpdir()).toBe(`${(process.env.SystemRoot || process.env.windir)}\\temp`);
|
||||
} else {
|
||||
expect(os.tmpdir()).toBe((process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp"));
|
||||
}
|
||||
if (process.platform === "win32") {
|
||||
expect(os.tmpdir()).toBe(process.env.TEMP || process.env.TMP);
|
||||
expect(os.tmpdir()).toBe(
|
||||
`${process.env.SystemRoot || process.env.windir}\\temp`
|
||||
);
|
||||
} else {
|
||||
expect(os.tmpdir()).toBe(
|
||||
process.env.TMPDIR || process.env.TMP || process.env.TEMP || "/tmp"
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it("hostname", () => {
|
||||
expect(os.hostname() !== "unknown").toBe(true);
|
||||
expect(os.hostname() !== "unknown").toBe(true);
|
||||
});
|
||||
|
||||
it("platform", () => {
|
||||
expect(["win32", "darwin", "linux", "wasm"].some(platform => os.platform() === platform)).toBe(true);
|
||||
expect(
|
||||
["win32", "darwin", "linux", "wasm"].some(
|
||||
(platform) => os.platform() === platform
|
||||
)
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("release", () => {
|
||||
expect(os.release().length > 1).toBe(true);
|
||||
expect(os.release().length > 1).toBe(true);
|
||||
});
|
||||
|
||||
it("type", () => {
|
||||
expect(["Windows_NT", "Darwin", "Linux"].some(type => os.type() === type)).toBe(true);
|
||||
expect(
|
||||
["Windows_NT", "Darwin", "Linux"].some((type) => os.type() === type)
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("uptime", () => {
|
||||
expect(os.uptime() > 0).toBe(true);
|
||||
expect(os.uptime() > 0).toBe(true);
|
||||
});
|
||||
|
||||
it("version", () => {
|
||||
expect(typeof os.version() === "string").toBe(true);
|
||||
expect(typeof os.version() === "string").toBe(true);
|
||||
});
|
||||
|
||||
it("userInfo", () => {
|
||||
const info = os.userInfo();
|
||||
const info = os.userInfo();
|
||||
|
||||
if (process.platform !== 'win32') {
|
||||
expect(info.username).toBe(process.env.USER);
|
||||
expect(info.shell).toBe(process.env.SHELL);
|
||||
expect(info.uid >= 0).toBe(true);
|
||||
expect(info.gid >= 0).toBe(true);
|
||||
} else {
|
||||
expect(info.username).toBe(process.env.USERNAME);
|
||||
expect(info.shell).toBe(null);
|
||||
expect(info.uid).toBe(-1);
|
||||
expect(info.gid).toBe(-1);
|
||||
}
|
||||
if (process.platform !== "win32") {
|
||||
expect(info.username).toBe(process.env.USER);
|
||||
expect(info.shell).toBe(process.env.SHELL);
|
||||
expect(info.uid >= 0).toBe(true);
|
||||
expect(info.gid >= 0).toBe(true);
|
||||
} else {
|
||||
expect(info.username).toBe(process.env.USERNAME);
|
||||
expect(info.shell).toBe(null);
|
||||
expect(info.uid).toBe(-1);
|
||||
expect(info.gid).toBe(-1);
|
||||
}
|
||||
});
|
||||
|
||||
it("cpus", () => {
|
||||
const cpus = os.cpus();
|
||||
const cpus = os.cpus();
|
||||
|
||||
for (const cpu of cpus) {
|
||||
expect(typeof cpu.model === 'string').toBe(true);
|
||||
expect(typeof cpu.speed === 'number').toBe(true);
|
||||
expect(typeof cpu.times.idle === 'number').toBe(true);
|
||||
expect(typeof cpu.times.irq === 'number').toBe(true);
|
||||
expect(typeof cpu.times.nice === 'number').toBe(true);
|
||||
expect(typeof cpu.times.sys === 'number').toBe(true);
|
||||
expect(typeof cpu.times.user === 'number').toBe(true);
|
||||
}
|
||||
})
|
||||
for (const cpu of cpus) {
|
||||
expect(typeof cpu.model === "string").toBe(true);
|
||||
expect(typeof cpu.speed === "number").toBe(true);
|
||||
expect(typeof cpu.times.idle === "number").toBe(true);
|
||||
expect(typeof cpu.times.irq === "number").toBe(true);
|
||||
expect(typeof cpu.times.nice === "number").toBe(true);
|
||||
expect(typeof cpu.times.sys === "number").toBe(true);
|
||||
expect(typeof cpu.times.user === "number").toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("networkInterfaces", () => {
|
||||
const networkInterfaces = os.networkInterfaces();
|
||||
const networkInterfaces = os.networkInterfaces();
|
||||
|
||||
for (const networkInterface of Object.values(networkInterfaces)) {
|
||||
for (const nI of networkInterface) {
|
||||
expect(typeof nI.address === 'string').toBe(true);
|
||||
expect(typeof nI.netmask === 'string').toBe(true);
|
||||
expect(typeof nI.family === 'string').toBe(true);
|
||||
expect(typeof nI.mac === 'string').toBe(true);
|
||||
expect(typeof nI.internal === 'boolean').toBe(true);
|
||||
expect(nI.cidr === null).toBe(true);
|
||||
}
|
||||
for (const networkInterface of Object.values(networkInterfaces)) {
|
||||
for (const nI of networkInterface) {
|
||||
expect(typeof nI.address === "string").toBe(true);
|
||||
expect(typeof nI.netmask === "string").toBe(true);
|
||||
expect(typeof nI.family === "string").toBe(true);
|
||||
expect(typeof nI.mac === "string").toBe(true);
|
||||
expect(typeof nI.internal === "boolean").toBe(true);
|
||||
expect(typeof nI.cidr).toBe("string");
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
it("EOL", () => {
|
||||
if (process.platform === 'win32') expect(os.EOL).toBe("\\r\\n");
|
||||
else expect(os.EOL).toBe("\\n");
|
||||
if (process.platform === "win32") expect(os.EOL).toBe("\\r\\n");
|
||||
else expect(os.EOL).toBe("\\n");
|
||||
});
|
||||
|
||||
it("devNull", () => {
|
||||
if (process.platform === 'win32') expect(os.devNull).toBe("\\\\.\\nul");
|
||||
else expect(os.devNull).toBe("/dev/null");
|
||||
});
|
||||
if (process.platform === "win32") expect(os.devNull).toBe("\\\\.\\nul");
|
||||
else expect(os.devNull).toBe("/dev/null");
|
||||
});
|
||||
|
||||
@@ -49,6 +49,30 @@ describe("TextDecoder", () => {
|
||||
gcTrace(true);
|
||||
});
|
||||
|
||||
describe("typedArrays", () => {
|
||||
var text = `ABC DEF GHI JKL MNO PQR STU VWX YZ ABC DEF GHI JKL MNO PQR STU V`;
|
||||
var bytes = new TextEncoder().encode(text);
|
||||
var decoder = new TextDecoder();
|
||||
for (let TypedArray of [
|
||||
Uint8Array,
|
||||
Uint16Array,
|
||||
Uint32Array,
|
||||
Int8Array,
|
||||
Int16Array,
|
||||
Int32Array,
|
||||
Float32Array,
|
||||
Float64Array,
|
||||
DataView,
|
||||
BigInt64Array,
|
||||
BigUint64Array,
|
||||
]) {
|
||||
it(`should decode ${TypedArray.name}`, () => {
|
||||
const decoded = decoder.decode(new TypedArray(bytes.buffer));
|
||||
expect(decoded).toBe(text);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it("should decode unicode text with multiple consecutive emoji", () => {
|
||||
const decoder = new TextDecoder();
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
Reference in New Issue
Block a user