From 449fc297c59d756a25889814bf60dcd8350bbd9f Mon Sep 17 00:00:00 2001 From: David Dick Date: Wed, 26 Jun 2024 05:48:13 +1000 Subject: [PATCH] Changing CLEAR_PERMISSIONS and adding CLEAR_SHUTDOWN_EXCEPTIONS and CLEAR_SITE_PERMISSIONS --- lib/Firefox/Marionette/Cache.pm | 22 +++++++++++++++++++--- t/01-marionette.t | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/Firefox/Marionette/Cache.pm b/lib/Firefox/Marionette/Cache.pm index 8f6a679..76c08e5 100644 --- a/lib/Firefox/Marionette/Cache.pm +++ b/lib/Firefox/Marionette/Cache.pm @@ -35,6 +35,7 @@ our @EXPORT_OK = qw( CLEAR_FINGERPRINTING_PROTECTION_STATE CLEAR_BOUNCE_TRACKING_PROTECTION_STATE CLEAR_STORAGE_PERMISSIONS + CLEAR_SHUTDOWN_EXCEPTIONS CLEAR_ALL CLEAR_ALL_CACHES CLEAR_DOM_STORAGES @@ -59,7 +60,7 @@ sub CLEAR_HISTORY { return 1024 } sub CLEAR_SESSION_HISTORY { return 2048 } sub CLEAR_AUTH_TOKENS { return 4096 } sub CLEAR_AUTH_CACHE { return 8192 } -sub CLEAR_PERMISSIONS { return 16_384 } +sub CLEAR_SITE_PERMISSIONS { return 16_384 } sub CLEAR_CONTENT_PREFERENCES { return 32_768 } sub CLEAR_HSTS { return 65_536 } sub CLEAR_EME { return 131_072 } @@ -76,8 +77,13 @@ sub CLEAR_COOKIE_BANNER_EXECUTED_RECORD { return 134_217_728 } sub CLEAR_FINGERPRINTING_PROTECTION_STATE { return 268_435_456 } sub CLEAR_BOUNCE_TRACKING_PROTECTION_STATE { return 536_870_912 } sub CLEAR_STORAGE_PERMISSIONS { return 1_073_741_824 } +sub CLEAR_SHUTDOWN_EXCEPTIONS { return 2_147_483_648 } sub CLEAR_ALL { return 0xFFFFFFFF } +sub CLEAR_PERMISSIONS { + return CLEAR_SITE_PERMISSIONS() | CLEAR_SHUTDOWN_EXCEPTIONS(); +} + sub CLEAR_ALL_CACHES { return CLEAR_NETWORK_CACHE() | CLEAR_IMAGE_CACHE() | CLEAR_CSS_CACHE() | CLEAR_PREFLIGHT_CACHE() | CLEAR_HSTS(); @@ -133,6 +139,8 @@ Version 1.58 This module handles the implementation of the Firefox cache constants. This is sourced from L +Cache settings in Firefox have changed a lot and are still changing in 2024. The ones that have been historically available AND stable (they have at least retained the same number) have been L, L and L. For the other variables, YMMV. + =head1 CONSTANTS =head2 CLEAR_COOKIES @@ -187,9 +195,9 @@ returns the value of CLEAR_AUTH_TOKENS, which is 1 << 12 = 4096 returns the value of CLEAR_AUTH_CACHE, which is 1 << 13 = 8192 (Login cache) -=head2 CLEAR_PERMISSIONS +=head2 CLEAR_SITE_PERMISSIONS -returns the value of CLEAR_PERMISSIONS, which is 1 << 14 = 16384 +returns the value of CLEAR_SITE_PERMISSIONS, which is 1 << 14 = 16384 =head2 CLEAR_CONTENT_PREFERENCES @@ -255,10 +263,18 @@ returns the value of CLEAR_BOUNCE_TRACKING_PROTECTION_STATE, which is 1 << 29 = returns the value of CLEAR_STORAGE_PERMISSIONS, which is 1 << 30 = 1073741824 +=head2 CLEAR_SHUTDOWN_EXCEPTIONS + +returns the value of CLEAR_SHUTDOWN_EXCEPTIONS, which is 1 << 31 = 2147483648 + =head2 CLEAR_ALL returns the value of CLEAR_ALL, which is 4294967295 (0xFFFFFFFF) +=head2 CLEAR_PERMISSIONS + +returns the value of CLEAR_PERMISSIONS, which is 2147500032 (L | L) + =head2 CLEAR_ALL_CACHES returns the value of CLEAR_ALL_CACHES, which is 12648454 (L | L | L | L | L) diff --git a/t/01-marionette.t b/t/01-marionette.t index 1b990c4..17bf899 100755 --- a/t/01-marionette.t +++ b/t/01-marionette.t @@ -1893,6 +1893,7 @@ SKIP: { TODO: { local $TODO = ($major_version < 113 && $name !~ /^(CLEAR_COOKIES|CLEAR_NETWORK_CACHE|CLEAR_IMAGE_CACHE)$/smx) ? "Older firefox (less than 113) can have different values for Firefox::Marionette::Cache constants" : q[]; local $TODO = $TODO || ($major_version < 128 && $name =~ /^(?:CLEAR_CREDENTIAL_MANAGER_STATE|CLEAR_COOKIE_BANNER_EXCEPTION|CLEAR_COOKIE_BANNER_EXECUTED_RECORD|CLEAR_FINGERPRINTING_PROTECTION_STATE|CLEAR_BOUNCE_TRACKING_PROTECTION_STATE|CLEAR_FORGET_ABOUT_SITE|CLEAR_STORAGE_PERMISSIONS|CLEAR_COOKIES_AND_SITE_DATA)$/) ? "Old firefox (less than 128) can have different values for Firefox::Marionette::Cache constants" : q[]; + local $TODO = $TODO || ($major_version < 129 && $name =~ /^(?:CLEAR_PERMISSIONS|CLEAR_FORGET_ABOUT_SITE)$/) ? "Old firefox (less than 129) can have different values for Firefox::Marionette::Cache constants" : q[]; my $result = $firefox->check_cache_key($name); if (($name eq 'CLEAR_FORGET_ABOUT_SITE') && ($major_version < 124)) { ok($result <= &$name(), "\$firefox->check_cache_key($name) eq Firefox::Marionette::Cache::${name} which should less than or equal to $result and is " . &$name());