browser_framebusting_identity.js (2448B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 add_setup(async function () { 8 await SpecialPowers.pushPrefEnv({ 9 set: [ 10 ["dom.disable_open_during_load", true], 11 ["dom.security.framebusting_intervention.enabled", true], 12 ["dom.disable_open_click_delay", 0], 13 ], 14 }); 15 }); 16 17 add_task(async function () { 18 const tab = await BrowserTestUtils.openNewForegroundTab( 19 gBrowser, 20 "about:blank" 21 ); 22 23 await triggerFramebustingIntervention(tab); 24 await openIdentityPopup(); 25 26 // Run actual checks. 27 await checkLocalization(); 28 await checkGoToRedirect(tab); 29 30 info("Cleaning up..."); 31 await closeIdentityPopup(); 32 BrowserTestUtils.removeTab(tab); 33 }); 34 35 async function openIdentityPopup() { 36 info("Waiting for box..."); 37 await TestUtils.waitForCondition(() => 38 gPermissionPanel._identityPermissionBox.checkVisibility() 39 ); 40 41 info("Clicking button..."); 42 const promise = BrowserTestUtils.waitForEvent( 43 window, 44 "popupshown", 45 true, 46 event => event.target == gPermissionPanel._permissionPopup 47 ); 48 gPermissionPanel._identityPermissionBox.click(); 49 50 info("Waiting for popup to show..."); 51 await promise; 52 } 53 54 async function closeIdentityPopup() { 55 info("Hiding identity popup..."); 56 const promise = BrowserTestUtils.waitForEvent( 57 gPermissionPanel._permissionPopup, 58 "popuphidden" 59 ); 60 gPermissionPanel._permissionPopup.hidePopup(); 61 62 info("Waiting for popup to hide..."); 63 await promise; 64 } 65 66 async function checkLocalization() { 67 const indicatorItem = document.getElementById("blocked-popup-indicator-item"); 68 is(indicatorItem.children.length, 1, "Indicator item has exactly one child"); 69 70 is( 71 indicatorItem.children[0].dataset.l10nId, 72 "site-permissions-unblock-redirect" 73 ); 74 } 75 76 async function checkGoToRedirect(tab) { 77 const indicatorItem = document.getElementById("blocked-popup-indicator-item"); 78 is(indicatorItem.children.length, 1, "Indicator item has exactly one child"); 79 80 info("Going to blocked redirect..."); 81 indicatorItem.children[0].click(); 82 await BrowserTestUtils.browserLoaded( 83 tab.linkedBrowser, 84 /*includeSubFrames=*/ false, 85 FRAMEBUSTING_FRAME_URL 86 ); 87 88 info("Resetting to initial state..."); 89 await triggerFramebustingIntervention(tab); 90 await openIdentityPopup(); 91 }