@@ -162,3 +162,85 @@ add_task(async function test_disabled_locked() {
162162
163163 restore_prefs ( ) ;
164164} ) ;
165+
166+ add_task ( async function test_locked_blocks_inpage_allow_paths ( ) {
167+ await SpecialPowers . pushPrefEnv ( {
168+ set : [ [ "dom.disable_open_click_delay" , 0 ] ] ,
169+ } ) ;
170+ await setupPolicyEngineWithJson ( {
171+ policies : {
172+ PopupBlocking : {
173+ Default : true ,
174+ Locked : true ,
175+ } ,
176+ } ,
177+ } ) ;
178+
179+ const POPUP_PAGE =
180+ "https://example.com/browser/browser/base/content/test/popups/popup_blocker2.html" ;
181+
182+ let tab = await BrowserTestUtils . openNewForegroundTab ( gBrowser , POPUP_PAGE ) ;
183+
184+ await SpecialPowers . spawn ( gBrowser . selectedBrowser , [ ] , async ( ) => {
185+ content . document . getElementById ( "pop" ) . click ( ) ;
186+ } ) ;
187+
188+ await TestUtils . waitForCondition ( ( ) =>
189+ gBrowser . getNotificationBox ( ) . getNotificationWithValue ( "popup-blocked" )
190+ ) ;
191+
192+ // Open the notification's "Options" menu and confirm the "Allow pop-ups
193+ // for <host>" item stays hidden when the policy is locked.
194+ let blockedPopupOptions = document . getElementById ( "blockedPopupOptions" ) ;
195+ let popupShown = BrowserTestUtils . waitForEvent (
196+ window ,
197+ "popupshown" ,
198+ true ,
199+ event => event . target == blockedPopupOptions
200+ ) ;
201+ let notification = gBrowser
202+ . getNotificationBox ( )
203+ . getNotificationWithValue ( "popup-blocked" ) ;
204+ notification . _buttons [ 0 ] . click ( ) ;
205+ await popupShown ;
206+
207+ let allowSite = document . getElementById ( "blockedPopupAllowSite" ) ;
208+ ok (
209+ allowSite . hidden ,
210+ "blockedPopupAllowSite stays hidden when PopupBlocking is locked"
211+ ) ;
212+
213+ let popupHidden = BrowserTestUtils . waitForEvent (
214+ blockedPopupOptions ,
215+ "popuphidden"
216+ ) ;
217+ blockedPopupOptions . hidePopup ( ) ;
218+ await popupHidden ;
219+
220+ // Open the URL-bar permission panel and confirm the popup row is
221+ // rendered as a locked policy permission (no editable menulist).
222+ let permissionShown = BrowserTestUtils . waitForEvent (
223+ window ,
224+ "popupshown" ,
225+ true ,
226+ event => event . target == gPermissionPanel . _permissionPopup
227+ ) ;
228+ gPermissionPanel . _identityPermissionBox . click ( ) ;
229+ await permissionShown ;
230+
231+ let menulist = document . getElementById ( "permission-popup-menulist" ) ;
232+ ok (
233+ menulist && menulist . getAttribute ( "disabled" ) == "true" ,
234+ "Popup permission menulist is disabled when policy is locked"
235+ ) ;
236+
237+ let permissionHidden = BrowserTestUtils . waitForEvent (
238+ gPermissionPanel . _permissionPopup ,
239+ "popuphidden"
240+ ) ;
241+ gPermissionPanel . _permissionPopup . hidePopup ( ) ;
242+ await permissionHidden ;
243+
244+ BrowserTestUtils . removeTab ( tab ) ;
245+ restore_prefs ( ) ;
246+ } ) ;
0 commit comments