mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-15 15:58:57 +00:00
fix 0-size structs all having the same identity (the same pointer
This commit is contained in:
@@ -176,6 +176,8 @@ pub fn deinit(self: *Page) void {
|
||||
log.debug(.page, "page.deinit", .{ .url = self.url });
|
||||
}
|
||||
self.js.deinit();
|
||||
self._script_manager.shutdown = true;
|
||||
self._session.browser.http_client.abort();
|
||||
self._script_manager.deinit();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="testing.js"></script>
|
||||
<script id=navigator>
|
||||
testing.expectEqual(navigator, window.navigator);
|
||||
testing.expectEqual('object', typeof navigator);
|
||||
|
||||
testing.expectEqual(true, navigator.userAgent.length > 0);
|
||||
testing.expectEqual(true, navigator.userAgent.includes('LiteFetch'));
|
||||
|
||||
testing.expectEqual('LiteFetch', navigator.appName);
|
||||
|
||||
testing.expectEqual('0.1', navigator.appVersion);
|
||||
|
||||
testing.expectEqual(true, navigator.platform.length > 0);
|
||||
|
||||
const validPlatforms = ['MacIntel', 'Win32', 'Linux x86_64', 'FreeBSD', 'Unknown'];
|
||||
testing.expectEqual(true, validPlatforms.includes(navigator.platform));
|
||||
|
||||
testing.expectEqual('en-US', navigator.language);
|
||||
|
||||
testing.expectEqual(true, Array.isArray(navigator.languages));
|
||||
testing.expectEqual(1, navigator.languages.length);
|
||||
testing.expectEqual('en-US', navigator.languages[0]);
|
||||
|
||||
testing.expectEqual(true, navigator.onLine);
|
||||
testing.expectEqual(false, navigator.cookieEnabled);
|
||||
testing.expectEqual(4, navigator.hardwareConcurrency);
|
||||
testing.expectEqual(0, navigator.maxTouchPoints);
|
||||
</script>
|
||||
@@ -22,6 +22,7 @@ const js = @import("../js/js.zig");
|
||||
const logger = @import("../../log.zig");
|
||||
|
||||
const Console = @This();
|
||||
_pad: bool = false,
|
||||
|
||||
pub const init: Console = .{};
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@ const std = @import("std");
|
||||
const js = @import("../js/js.zig");
|
||||
|
||||
const Crypto = @This();
|
||||
_pad: bool = false,
|
||||
|
||||
pub const init: Crypto = .{};
|
||||
|
||||
// We take a js.Value, because we want to return the same instance, not a new
|
||||
// TypedArray
|
||||
|
||||
@@ -20,6 +20,7 @@ const builtin = @import("builtin");
|
||||
const js = @import("../js/js.zig");
|
||||
|
||||
const Navigator = @This();
|
||||
_pad: bool = false,
|
||||
|
||||
pub const init: Navigator = .{};
|
||||
|
||||
@@ -120,7 +121,3 @@ pub const JsApi = struct {
|
||||
pub const javaEnabled = bridge.function(Navigator.javaEnabled, .{});
|
||||
};
|
||||
|
||||
const testing = @import("../../testing.zig");
|
||||
test "WebApi: Navigator" {
|
||||
try testing.htmlRunner("navigator.html", .{});
|
||||
}
|
||||
|
||||
@@ -34,12 +34,15 @@ const EventTarget = @import("EventTarget.zig");
|
||||
const ErrorEvent = @import("event/ErrorEvent.zig");
|
||||
const MediaQueryList = @import("css/MediaQueryList.zig");
|
||||
const storage = @import("storage/storage.zig");
|
||||
const Element = @import("Element.zig");
|
||||
const CSSStyleDeclaration = @import("css/CSSStyleDeclaration.zig");
|
||||
const CustomElementRegistry = @import("CustomElementRegistry.zig");
|
||||
|
||||
const Window = @This();
|
||||
|
||||
_proto: *EventTarget,
|
||||
_document: *Document,
|
||||
_crypto: Crypto = .init,
|
||||
_console: Console = .init,
|
||||
_navigator: Navigator = .init,
|
||||
_performance: Performance,
|
||||
@@ -67,16 +70,17 @@ pub fn getDocument(self: *Window) *Document {
|
||||
return self._document;
|
||||
}
|
||||
|
||||
pub fn getConsole(_: *const Window) Console {
|
||||
return .{};
|
||||
pub fn getConsole(self: *Window) *Console {
|
||||
std.debug.print("getConsole\n", .{});
|
||||
return &self._console;
|
||||
}
|
||||
|
||||
pub fn getNavigator(_: *const Window) Navigator {
|
||||
return .{};
|
||||
pub fn getNavigator(self: *Window) *Navigator {
|
||||
return &self._navigator;
|
||||
}
|
||||
|
||||
pub fn getCrypto(_: *const Window) Crypto {
|
||||
return .{};
|
||||
pub fn getCrypto(self: *Window) *Crypto {
|
||||
return &self._crypto;
|
||||
}
|
||||
|
||||
pub fn getPerformance(self: *Window) *Performance {
|
||||
@@ -210,6 +214,10 @@ pub fn matchMedia(_: *const Window, query: []const u8, page: *Page) !*MediaQuery
|
||||
});
|
||||
}
|
||||
|
||||
pub fn getComputedStyle(_: *const Window, _: *Element, page: *Page) !@import("css/CSSStyleDeclaration.zig") {
|
||||
return CSSStyleDeclaration.init(null, page);
|
||||
}
|
||||
|
||||
pub fn btoa(_: *const Window, input: []const u8, page: *Page) ![]const u8 {
|
||||
const encoded_len = std.base64.standard.Encoder.calcSize(input.len);
|
||||
const encoded = try page.call_arena.alloc(u8, encoded_len);
|
||||
@@ -223,6 +231,7 @@ pub fn atob(_: *const Window, input: []const u8, page: *Page) ![]const u8 {
|
||||
return decoded;
|
||||
}
|
||||
|
||||
|
||||
const ScheduleOpts = struct {
|
||||
repeat: bool,
|
||||
params: []js.Object,
|
||||
@@ -384,6 +393,7 @@ pub const JsApi = struct {
|
||||
return 1080;
|
||||
}
|
||||
}.wrap, null, .{ .cache = "innerHeight" });
|
||||
pub const getComputedStyle = bridge.function(Window.getComputedStyle, .{});
|
||||
};
|
||||
|
||||
const testing = @import("../../testing.zig");
|
||||
|
||||
@@ -20,6 +20,7 @@ const std = @import("std");
|
||||
const js = @import("../../js/js.zig");
|
||||
|
||||
const TextEncoder = @This();
|
||||
_pad: bool = false,
|
||||
|
||||
pub fn init() TextEncoder {
|
||||
return .{};
|
||||
|
||||
Reference in New Issue
Block a user