ActionPack: fix BrowserBlocker versions

css-nesting is not fully supported until Chrome 120, Opera 106:
https://caniuse.com/css-nesting
https://developer.mozilla.org/en-US/docs/Web/CSS/Nesting_selector#browser_compatibility
This commit is contained in:
Jamie McCarthy 2024-02-18 10:34:13 -06:00 committed by Rafael Mendonça França
parent cff6b2cd8d
commit dc34e293e0
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
2 changed files with 7 additions and 7 deletions

@ -20,7 +20,7 @@ module ClassMethods
# In addition to specifically named browser versions, you can also pass
# `:modern` as the set to restrict support to browsers natively supporting webp
# images, web push, badges, import maps, CSS nesting, and CSS :has. This
# includes Safari 17.2+, Chrome 119+, Firefox 121+, Opera 104+.
# includes Safari 17.2+, Chrome 120+, Firefox 121+, Opera 106+.
#
# You can use https://caniuse.com to check for browser versions supporting the
# features you use.
@ -31,7 +31,7 @@ module ClassMethods
# Examples:
#
# class ApplicationController < ActionController::Base
# # Allow only browsers natively supporting webp images, web push, badges, import maps, CSS nesting + :has
# # Allow only browsers natively supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has
# allow_browser versions: :modern
# end
#
@ -62,7 +62,7 @@ def allow_browser(versions:, block:)
class BrowserBlocker
SETS = {
modern: { safari: 17.2, chrome: 119, firefox: 121, opera: 104, ie: false }
modern: { safari: 17.2, chrome: 120, firefox: 121, opera: 106, ie: false }
}
attr_reader :request, :versions

@ -3,7 +3,7 @@
require "abstract_unit"
class AllowBrowserController < ActionController::Base
allow_browser versions: { safari: "16.4", chrome: "119", firefox: "123", opera: "104", ie: false }, block: -> { head :upgrade_required }, only: :hello
allow_browser versions: { safari: "16.4", chrome: "119", firefox: "123", opera: "106", ie: false }, block: -> { head :upgrade_required }, only: :hello
def hello
head :ok
end
@ -22,7 +22,7 @@ class AllowBrowserTest < ActionController::TestCase
SAFARI_17_2_0 = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.0 Safari/605.1.15"
FIREFOX_114 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0"
IE_11 = "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko"
OPERA_104 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 OPR/104.0.4638.54"
OPERA_106 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 OPR/106.0.0.0"
test "blocked browser below version limit" do
get_with_agent :hello, FIREFOX_114
@ -41,7 +41,7 @@ class AllowBrowserTest < ActionController::TestCase
get_with_agent :hello, CHROME_120
assert_response :ok
get_with_agent :hello, OPERA_104
get_with_agent :hello, OPERA_106
assert_response :ok
end
@ -55,7 +55,7 @@ class AllowBrowserTest < ActionController::TestCase
get_with_agent :modern, CHROME_120
assert_response :ok
get_with_agent :modern, OPERA_104
get_with_agent :modern, OPERA_106
assert_response :ok
end