mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-16 08:18:59 +00:00
initialize ICU
This makes functions like new Intl.DateTimeFormat() not crash.
This commit is contained in:
@@ -940,3 +940,14 @@ fn timestamp() u32 {
|
||||
const ts = std.posix.clock_gettime(std.posix.CLOCK.MONOTONIC) catch unreachable;
|
||||
return @intCast(ts.sec);
|
||||
}
|
||||
|
||||
const testing = @import("../testing.zig");
|
||||
test "Browser" {
|
||||
var runner = try testing.jsRunner(testing.tracking_allocator, .{});
|
||||
defer runner.deinit();
|
||||
|
||||
// this will crash if ICU isn't properly configured / ininitialized
|
||||
try runner.testCases(&.{
|
||||
.{ "new Intl.DateTimeFormat()", "[object Intl.DateTimeFormat]" },
|
||||
}, .{});
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ pub fn main() !void {
|
||||
else => {},
|
||||
}
|
||||
|
||||
const platform = Platform.init();
|
||||
const platform = try Platform.init();
|
||||
defer platform.deinit();
|
||||
|
||||
var app = try App.init(alloc, .{
|
||||
@@ -423,7 +423,7 @@ var test_wg: std.Thread.WaitGroup = .{};
|
||||
test "tests:beforeAll" {
|
||||
try parser.init();
|
||||
test_wg.startMany(3);
|
||||
_ = Platform.init();
|
||||
_ = try Platform.init();
|
||||
|
||||
{
|
||||
const address = try std.net.Address.parseIp("127.0.0.1", 9582);
|
||||
|
||||
@@ -118,7 +118,7 @@ pub fn main() !void {
|
||||
}
|
||||
|
||||
// initialize VM JS lib.
|
||||
const platform = Platform.init();
|
||||
const platform = try Platform.init();
|
||||
defer platform.deinit();
|
||||
|
||||
// prepare libraries to load on each test case.
|
||||
|
||||
@@ -34,7 +34,10 @@ const SCOPE_ARENA_RETAIN = 1024 * 64;
|
||||
pub const Platform = struct {
|
||||
inner: v8.Platform,
|
||||
|
||||
pub fn init() Platform {
|
||||
pub fn init() !Platform {
|
||||
if (v8.initV8ICU() == false) {
|
||||
return error.FailedToInitializeICU;
|
||||
}
|
||||
const platform = v8.Platform.initDefault(0, true);
|
||||
v8.initV8Platform(platform);
|
||||
v8.initV8();
|
||||
|
||||
Reference in New Issue
Block a user