Lightpanda: the headless browser designed for AI and automation
support all known sandbox values (since we don't sandbox anything)
Karl Seguinf3df515d9d9d
diff --git a/src/browser/tests/element/rel_list.html b/src/browser/tests/element/rel_list.htmlindex 7e128518b..50c7c5449 100644--- a/src/browser/tests/element/rel_list.html+++ b/src/browser/tests/element/rel_list.html@@ -25,9 +25,10 @@<script id=sandbox_supports>{const sandbox = document.createElement('iframe').sandbox;- testing.expectEqual(false, sandbox.supports('allow-modals'));- testing.expectEqual(false, sandbox.supports('allow-popups-to-escape-sandbox'));- testing.expectEqual(false, sandbox.supports('allow-storage-access-by-user-activation'));+ testing.expectEqual(true, sandbox.supports('allow-modals'));+ testing.expectEqual(true, sandbox.supports('ALLOW-SCRIPTS'));+ testing.expectEqual(true, sandbox.supports('allow-popups-to-escape-sandbox'));+ testing.expectEqual(true, sandbox.supports('allow-storage-access-by-user-activation'));testing.expectEqual(false, sandbox.supports('unknown-token'));}</script>diff --git a/src/browser/webapi/collections/DOMTokenList.zig b/src/browser/webapi/collections/DOMTokenList.zigindex ee33e608e..8d16dc695 100644--- a/src/browser/webapi/collections/DOMTokenList.zig+++ b/src/browser/webapi/collections/DOMTokenList.zig@@ -70,17 +70,31 @@ pub fn item(self: *const DOMTokenList, index: usize, frame: *Frame) !?[]const u8}/// https://dom.spec.whatwg.org/#dom-domtokenlist-supports-/// `sandbox` defines supported tokens, but none of its permissions are-/// implemented here. Other attributes without supported tokens throw.pub fn supports(self: *const DOMTokenList, token: []const u8, frame: *Frame) !bool {+ const lower = try std.ascii.allocLowerString(frame.local_arena, token);+if (std.ascii.eqlIgnoreCase(self._attribute_name.str(), "sandbox")) {- return false;+ const supported = [_][]const u8{+ "allow-downloads", "allow-forms", "allow-modals", "allow-orientation-lock",+ "allow-pointer-lock", "allow-popups", "allow-popups-to-escape-sandbox",+ "allow-presentation", "allow-same-origin", "allow-scripts",+ "allow-storage-access-by-user-activation", "allow-top-navigation",+ "allow-top-navigation-by-user-activation", "allow-top-navigation-to-custom-protocols",+ };+ for (supported) |s| {+ if (std.mem.eql(u8, lower, s)) {+ // we don't currently sandbox anything, so everything is allowed+ // (except an unknown value)+ return true;+ }+ }+ return false;}+if (!std.ascii.eqlIgnoreCase(self._attribute_name.str(), "rel")) {return error.TypeError;}const supported = [_][]const u8{ "stylesheet", "preload", "modulepreload" };- const lower = try std.ascii.allocLowerString(frame.local_arena, token);for (supported) |s| {if (std.mem.eql(u8, lower, s)) return true;}