Skip to content

Lightpanda: the headless browser designed for AI and automation

update getHighEntropyValues

Pierre Tachoired91a5b1abdaa
diff --git a/src/browser/tests/navigator/navigator.html b/src/browser/tests/navigator/navigator.html
index a797b6401..6cd4b80f3 100644
--- a/src/browser/tests/navigator/navigator.html
+++ b/src/browser/tests/navigator/navigator.html
@@ -116,7 +116,8 @@
testing.expectEqual(true, validUAPlatforms.includes(navigator.userAgentData.platform));
testing.expectEqual(1, navigator.userAgentData.brands.length);
- testing.expectEqual({brand: 'Lightpanda', version: "1"}, navigator.userAgentData.brands[0]);
+ testing.expectEqual('Lightpanda', navigator.userAgentData.brands[0].brand);
+ testing.expectEqual("1.0.0-", navigator.userAgentData.brands[0].version.substring(0,6));
// Same instance returned on repeated access
testing.expectEqual(true, navigator.userAgentData === navigator.userAgentData);
@@ -142,7 +143,7 @@
testing.expectEqual(true, Array.isArray(v.brands));
testing.expectEqual(true, Array.isArray(v.fullVersionList));
testing.expectEqual('Lightpanda', v.fullVersionList[0].brand);
- testing.expectEqual('1.0.0.0', v.uaFullVersion);
+ testing.expectEqual('1.0.0-', v.uaFullVersion.substring(0,6));
testing.expectEqual(false, v.wow64);
testing.expectEqual(true, Array.isArray(v.formFactor));
testing.expectEqual('Desktop', v.formFactor[0]);
diff --git a/src/browser/webapi/NavigatorUAData.zig b/src/browser/webapi/NavigatorUAData.zig
index fe5cf01c4..7a5cf0e95 100644
--- a/src/browser/webapi/NavigatorUAData.zig
+++ b/src/browser/webapi/NavigatorUAData.zig
@@ -62,6 +62,8 @@ pub fn getHighEntropyValues(_: *const NavigatorUAData, hints: []const []const u8
_ = hints;
+ const brands = brandList();
+
return exec.js.local.?.resolvePromise(.{
.brands = brandList(),
.mobile = false,
@@ -70,8 +72,8 @@ pub fn getHighEntropyValues(_: *const NavigatorUAData, hints: []const []const u8
.bitness = uaBitness(),
.model = "",
.platformVersion = "",
- .uaFullVersion = "1.0.0.0",
- .fullVersionList = brandList(),
+ .uaFullVersion = if (brands.len > 0) brands[0].version else "1.0.0.0",
+ .fullVersionList = brands,
.wow64 = false,
.formFactor = [_][]const u8{"Desktop"},
});
@@ -82,7 +84,7 @@ fn brandList() []const Brand {
const src = &Config.HttpHeaders.brands;
var arr: [src.len]Brand = undefined;
for (src, 0..) |b, i| {
- arr[i] = .{ .brand = b.brand, .version = b.version };
+ arr[i] = .{ .brand = b.brand, .version = b.full_version };
}
const final = arr;
break :blk final;