mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-14 15:28:57 +00:00
Page.reset msut create context and window once
This commit is contained in:
@@ -205,15 +205,21 @@ fn reset(self: *Page, comptime initializing: bool) !void {
|
||||
|
||||
self.document = (try self._factory.document(Node.Document.HTMLDocument{ ._proto = undefined })).asDocument();
|
||||
|
||||
const storage_bucket = try self._factory.create(storage.Bucket{});
|
||||
self.window = try self._factory.eventTarget(Window{
|
||||
._document = self.document,
|
||||
._storage_bucket = storage_bucket,
|
||||
._history = History.init(self),
|
||||
._performance = Performance.init(),
|
||||
._proto = undefined,
|
||||
._location = &default_location,
|
||||
});
|
||||
if (comptime initializing == true) {
|
||||
const storage_bucket = try self._factory.create(storage.Bucket{});
|
||||
self.window = try self._factory.eventTarget(Window{
|
||||
._document = self.document,
|
||||
._storage_bucket = storage_bucket,
|
||||
._history = History.init(self),
|
||||
._performance = Performance.init(),
|
||||
._proto = undefined,
|
||||
._location = &default_location,
|
||||
});
|
||||
} else {
|
||||
self.window._document = self.document;
|
||||
self.window._location = &default_location;
|
||||
// TODO reset _custom_elements?
|
||||
}
|
||||
|
||||
self._parse_state = .pre;
|
||||
self._load_state = .parsing;
|
||||
@@ -224,8 +230,10 @@ fn reset(self: *Page, comptime initializing: bool) !void {
|
||||
self._script_manager = ScriptManager.init(self);
|
||||
errdefer self._script_manager.deinit();
|
||||
|
||||
self.js = try self._session.executor.createContext(self, true, JS.GlobalMissingCallback.init(&self._polyfill_loader));
|
||||
errdefer self.js.deinit();
|
||||
if (comptime initializing == true) {
|
||||
self.js = try self._session.executor.createContext(self, true, JS.GlobalMissingCallback.init(&self._polyfill_loader));
|
||||
errdefer self.js.deinit();
|
||||
}
|
||||
|
||||
self._element_styles = .{};
|
||||
self._element_datasets = .{};
|
||||
|
||||
Reference in New Issue
Block a user