Skip to content

Truly independent web browser

LibWeb: Report blocked javascript: navigations as inline violations

Andreas Kling33eff477c1e7
diff --git a/Libraries/LibWeb/ContentSecurityPolicy/BlockingAlgorithms.cpp b/Libraries/LibWeb/ContentSecurityPolicy/BlockingAlgorithms.cpp
index 43e00f9b1bf..632943726f2 100644
--- a/Libraries/LibWeb/ContentSecurityPolicy/BlockingAlgorithms.cpp
+++ b/Libraries/LibWeb/ContentSecurityPolicy/BlockingAlgorithms.cpp
@@ -286,9 +286,8 @@ Directives::Directive::Result should_navigation_request_of_type_be_blocked_by_co
// just which directive is reported to have been violated.
auto directive_name = Directives::get_the_effective_directive_for_inline_checks(Directives::Directive::InlineType::Navigation);
- // 2. If directive’s inline check returns "Allowed" when executed upon null, "navigation" and
+ // 2. If directive’s inline check returns "Allowed" when executed upon null, "navigation", policy, and
// navigation request’s current URL, skip to the next directive.
- // FIXME: File spec issue that they forgot to pass in "policy" here.
// FIXME: File spec issue that current URL is a URL object and not a string, therefore they must use a
// spec operation to serialize the URL.
auto& realm = navigation_request->client()->realm();
@@ -301,8 +300,8 @@ Directives::Directive::Result should_navigation_request_of_type_be_blocked_by_co
// policy, and directive on navigation request’s client’s global object, policy, and directive-name.
auto violation = Violation::create_a_violation_object_for_global_policy_and_directive(navigation_request->client()->global_object(), policy, directive_name.view().to_utf8_but_should_be_ported_to_utf16());
- // 4. Set violation’s resource to navigation request’s URL.
- violation->set_resource(navigation_request->url());
+ // 4. Set violation’s resource to "inline".
+ violation->set_resource(Violation::Resource::Inline);
// 5. Execute § 5.5 Report a violation on violation.
violation->report_a_violation(realm);
diff --git a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/script-src/javascript-window-open-blocked.txt b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/script-src/javascript-window-open-blocked.txt
index 4b0ad92cca3..26d45fce19d 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/script-src/javascript-window-open-blocked.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/script-src/javascript-window-open-blocked.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Check that a securitypolicyviolation event is fired
\ No newline at end of file
+1 Pass
+Pass Check that a securitypolicyviolation event is fired
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-href.txt b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-href.txt
index 796ac584969..9fb735c1f5c 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-href.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-href.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail javascript: navigation using <a href> should be refused due to missing unsafe-hashes
\ No newline at end of file
+1 Pass
+Pass javascript: navigation using <a href> should be refused due to missing unsafe-hashes
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-href_blank-script-src-elem.txt b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-href_blank-script-src-elem.txt
index 525bd096c91..c02c3269d63 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-href_blank-script-src-elem.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-href_blank-script-src-elem.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail javascript: navigation using <a href target=_blank> should be refused due to missing unsafe-hashes
\ No newline at end of file
+1 Pass
+Pass javascript: navigation using <a href target=_blank> should be refused due to missing unsafe-hashes
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-href_blank.txt b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-href_blank.txt
index 525bd096c91..c02c3269d63 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-href_blank.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-href_blank.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail javascript: navigation using <a href target=_blank> should be refused due to missing unsafe-hashes
\ No newline at end of file
+1 Pass
+Pass javascript: navigation using <a href target=_blank> should be refused due to missing unsafe-hashes
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-window_open.txt b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-window_open.txt
index ccbeef93241..54110a426f8 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-window_open.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_missing_unsafe_hashes-window_open.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Test that the javascript: src is not allowed to run
\ No newline at end of file
+1 Pass
+Pass Test that the javascript: src is not allowed to run
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-href.txt b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-href.txt
index 7b406b8f6cd..0073ca4a452 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-href.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-href.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail javascript: navigation using <a href> should be refused due to wrong hash
\ No newline at end of file
+1 Pass
+Pass javascript: navigation using <a href> should be refused due to wrong hash
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-href_blank-script-src-elem.txt b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-href_blank-script-src-elem.txt
index 1b8952d1403..f053907ce84 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-href_blank-script-src-elem.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-href_blank-script-src-elem.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail javascript: navigation using <a href target=_blank> should be refused due to wrong hash
\ No newline at end of file
+1 Pass
+Pass javascript: navigation using <a href target=_blank> should be refused due to wrong hash
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-href_blank.txt b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-href_blank.txt
index 1b8952d1403..f053907ce84 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-href_blank.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-href_blank.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail javascript: navigation using <a href target=_blank> should be refused due to wrong hash
\ No newline at end of file
+1 Pass
+Pass javascript: navigation using <a href target=_blank> should be refused due to wrong hash
\ No newline at end of file
diff --git a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-window_open.txt b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-window_open.txt
index ccbeef93241..54110a426f8 100644
--- a/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-window_open.txt
+++ b/Tests/LibWeb/Text/expected/wpt-import/content-security-policy/unsafe-hashes/javascript_src_denied_wrong_hash-window_open.txt
@@ -2,5 +2,5 @@ Harness status: OK
Found 1 tests
-1 Fail
-Fail Test that the javascript: src is not allowed to run
\ No newline at end of file
+1 Pass
+Pass Test that the javascript: src is not allowed to run
\ No newline at end of file