LibWeb/CSP: Introduce the ability to create and report a violation

A violation provides several details about an enforcement failing, such
as the URL of the document, the directive that returned "Blocked", etc.
This commit is contained in:
Luke Wilde
2024-11-25 17:22:08 +00:00
committed by Alexander Kalenik
parent 02236be737
commit 86170f4bfd
Notes: github-actions[bot] 2025-03-18 23:56:26 +00:00
12 changed files with 982 additions and 0 deletions

View File

@@ -12,9 +12,18 @@
namespace Web::Infra {
using JSONBaseValue = Variant<Empty, u16, u32, bool, String>;
using JSONValue = Variant<JSONBaseValue, Vector<JSONBaseValue>>;
struct JSONObject {
OrderedHashMap<String, Variant<JSONValue, JSONObject>> value;
};
using JSONTopLevel = Variant<JSONValue, JSONObject>;
WebIDL::ExceptionOr<JS::Value> parse_json_string_to_javascript_value(JS::Realm&, StringView);
WebIDL::ExceptionOr<JS::Value> parse_json_bytes_to_javascript_value(JS::Realm&, ReadonlyBytes);
WebIDL::ExceptionOr<String> serialize_javascript_value_to_json_string(JS::VM&, JS::Value);
WebIDL::ExceptionOr<ByteBuffer> serialize_javascript_value_to_json_bytes(JS::VM&, JS::Value);
String serialize_an_infra_value_to_a_json_string(JS::Realm&, JSONTopLevel const&);
ByteBuffer serialize_an_infra_value_to_json_bytes(JS::Realm&, JSONTopLevel const&);
}