Skip to content

Commit d4411b8

Browse files
committed
dom: implement navigatorID
1 parent 2ec6b94 commit d4411b8

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

src/browser/browser.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const polyfill = @import("../polyfill/polyfill.zig");
4646

4747
const log = std.log.scoped(.browser);
4848

49-
const user_agent = "Lightpanda.io/1.0";
49+
pub const user_agent = "Lightpanda/1.0";
5050

5151
// Browser is an instance of the browser.
5252
// You can create multiple browser instances.

src/browser/loader.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
const std = @import("std");
2020
const Client = @import("../http/Client.zig");
2121

22-
const user_agent = "Lightpanda.io/1.0";
22+
const user_agent = @import("browser.zig").user_agent;
2323

2424
pub const Loader = struct {
2525
client: Client,

src/html/navigator.zig

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
const std = @import("std");
2020

21+
const builtin = @import("builtin");
2122
const parser = @import("netsurf");
2223
const jsruntime = @import("jsruntime");
2324
const Callback = jsruntime.Callback;
@@ -35,11 +36,38 @@ const storage = @import("../storage/storage.zig");
3536
pub const Navigator = struct {
3637
pub const mem_guarantied = true;
3738

38-
agent: []const u8 = "",
39+
agent: []const u8 = "Lightpanda/1.0",
40+
version: []const u8 = "1.0",
41+
vendor: []const u8 = "",
42+
platform: []const u8 = std.fmt.comptimePrint("{any} {any}", .{ builtin.os.tag, builtin.cpu.arch }),
3943

4044
pub fn get_userAgent(self: *Navigator) []const u8 {
4145
return self.agent;
4246
}
47+
pub fn get_appCodeName(_: *Navigator) []const u8 {
48+
return "Mozilla";
49+
}
50+
pub fn get_appName(_: *Navigator) []const u8 {
51+
return "Netscape";
52+
}
53+
pub fn get_appVersion(self: *Navigator) []const u8 {
54+
return self.version;
55+
}
56+
pub fn get_platform(self: *Navigator) []const u8 {
57+
return self.platform;
58+
}
59+
pub fn get_product(_: *Navigator) []const u8 {
60+
return "Gecko";
61+
}
62+
pub fn get_productSub(_: *Navigator) []const u8 {
63+
return "20030107";
64+
}
65+
pub fn get_vendor(self: *Navigator) []const u8 {
66+
return self.vendor;
67+
}
68+
pub fn get_vendorSub(_: *Navigator) []const u8 {
69+
return "";
70+
}
4371
};
4472

4573
// Tests
@@ -50,7 +78,8 @@ pub fn testExecFn(
5078
js_env: *jsruntime.Env,
5179
) anyerror!void {
5280
var navigator = [_]Case{
53-
.{ .src = "navigator.userAgent", .ex = "" },
81+
.{ .src = "navigator.userAgent", .ex = "Lightpanda/1.0" },
82+
.{ .src = "navigator.appVersion", .ex = "1.0" },
5483
};
5584
try checkCases(js_env, &navigator);
5685
}

0 commit comments

Comments
 (0)