Skip to content

Lightpanda: the headless browser designed for AI and automation

webapi: support sandbox token queries

Guilherme Torres Castro0f67f1645df5
diff --git a/src/browser/tests/element/rel_list.html b/src/browser/tests/element/rel_list.html
index 40ec1e686..7e128518b 100644
--- a/src/browser/tests/element/rel_list.html
+++ b/src/browser/tests/element/rel_list.html
@@ -22,6 +22,16 @@
}
</script>
+<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(false, sandbox.supports('unknown-token'));
+}
+</script>
+
<a id=a1 rel="noopener"></a>
<area id=ar1 rel="noopener">
<output id=o1 for="x"></output>
diff --git a/src/browser/webapi/collections/DOMTokenList.zig b/src/browser/webapi/collections/DOMTokenList.zig
index 8b90e9a48..ee33e608e 100644
--- a/src/browser/webapi/collections/DOMTokenList.zig
+++ b/src/browser/webapi/collections/DOMTokenList.zig
@@ -70,10 +70,12 @@ pub fn item(self: *const DOMTokenList, index: usize, frame: *Frame) !?[]const u8
}
/// https://dom.spec.whatwg.org/#dom-domtokenlist-supports
-/// Only `rel` defines supported tokens here; per spec every other backing
-/// attribute throws. Loaders probe `relList.supports("modulepreload")` and
-/// fall back to fetch()-based legacy loading when it fails.
+/// `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 {
+ if (std.ascii.eqlIgnoreCase(self._attribute_name.str(), "sandbox")) {
+ return false;
+ }
if (!std.ascii.eqlIgnoreCase(self._attribute_name.str(), "rel")) {
return error.TypeError;
}