mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-06-11 09:35:59 -04:00
--inject-script: don't error out if script execution fails
This commit is contained in:
@@ -2147,15 +2147,14 @@ pub fn createElementNS(self: *Frame, namespace: Element.Namespace, name: []const
|
||||
self.js.localScope(&ls);
|
||||
defer ls.deinit();
|
||||
|
||||
var try_catch: JS.TryCatch = undefined;
|
||||
try_catch.init(&ls.local);
|
||||
defer try_catch.deinit();
|
||||
|
||||
for (inject_scripts) |inject_script| {
|
||||
var try_catch: JS.TryCatch = undefined;
|
||||
try_catch.init(&ls.local);
|
||||
defer try_catch.deinit();
|
||||
|
||||
ls.local.eval(inject_script, "inject_script") catch |err| {
|
||||
const caught = try_catch.caughtOrError(self.call_arena, err);
|
||||
log.err(.app, "inject script error", .{ .err = caught });
|
||||
return error.InjectScriptError;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4112,6 +4111,12 @@ test "WebApi: Integration" {
|
||||
try testing.htmlRunner("integration", .{});
|
||||
}
|
||||
|
||||
test "WebApi: inject_script" {
|
||||
try testing.htmlRunner("inject_script.html", .{
|
||||
.inject_script = "window.__injected = true; window.__injectValue = 42;",
|
||||
});
|
||||
}
|
||||
|
||||
test "Page: isSameOrigin" {
|
||||
var arena = std.heap.ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
|
||||
Reference in New Issue
Block a user