File tree Expand file tree Collapse file tree 3 files changed +39
-4
lines changed Expand file tree Collapse file tree 3 files changed +39
-4
lines changed Original file line number Diff line number Diff line change 1+ * The ` speaker ` , ` vibrate ` , and ` vr ` permissions policy directives are now
2+ deprecated.
3+
4+ There is no browser support for these directives, and no plan for browser
5+ support in the future. You can just remove these directives from your
6+ application.
7+
8+ * Jonathan Hefner*
9+
110* Added the ` :status ` option to ` assert_redirected_to ` to specify the precise
211 HTTP status of the redirect. Defaults to ` :redirect ` for backwards
312 compatibility.
Original file line number Diff line number Diff line change @@ -104,11 +104,8 @@ def permissions_policy=(policy)
104104 picture_in_picture : "picture-in-picture" ,
105105 screen_wake_lock : "screen-wake-lock" ,
106106 serial : "serial" ,
107- speaker : "speaker" ,
108107 sync_xhr : "sync-xhr" ,
109108 usb : "usb" ,
110- vibrate : "vibrate" ,
111- vr : "vr" ,
112109 web_share : "web-share" ,
113110 } . freeze
114111
@@ -135,6 +132,25 @@ def initialize_copy(other)
135132 end
136133 end
137134
135+ %w[ speaker vibrate vr ] . each do |directive |
136+ define_method ( directive ) do |*sources |
137+ ActiveSupport ::Deprecation . warn ( <<~MSG )
138+ The `#{ directive } ` permissions policy directive is deprecated
139+ and will be removed in Rails 7.2.
140+
141+ There is no browser support for this directive, and no plan
142+ for browser support in the future. You can just remove this
143+ directive from your application.
144+ MSG
145+
146+ if sources . first
147+ @directives [ directive ] = apply_mappings ( sources )
148+ else
149+ @directives . delete ( directive )
150+ end
151+ end
152+ end
153+
138154 def build ( context = nil )
139155 build_directives ( context ) . compact . join ( "; " )
140156 end
Original file line number Diff line number Diff line change @@ -34,11 +34,21 @@ def test_multiple_directives_for_multiple_directives
3434
3535 def test_invalid_directive_source
3636 exception = assert_raises ( ArgumentError ) do
37- @policy . vr [ :non_existent ]
37+ @policy . geolocation [ :non_existent ]
3838 end
3939
4040 assert_equal "Invalid HTTP permissions policy source: [:non_existent]" , exception . message
4141 end
42+
43+ def test_deprecated_directives
44+ assert_deprecated { @policy . speaker :self }
45+ assert_deprecated { @policy . vibrate :self }
46+ assert_deprecated { @policy . vr :self }
47+
48+ assert_not_deprecated do
49+ assert_equal "speaker 'self'; vibrate 'self'; vr 'self'" , @policy . build
50+ end
51+ end
4252end
4353
4454class PermissionsPolicyIntegrationTest < ActionDispatch ::IntegrationTest
You can’t perform that action at this time.
0 commit comments