browser_945739_showInPrivateBrowsing_customize_mode.js (1385B)
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 const kWidgetId = "test-private-browsing-customize-mode-widget"; 8 9 // Add a widget via the API with showInPrivateBrowsing set to false 10 // and ensure it does not appear in the list of unused widgets in private 11 // windows. 12 add_task(async function testPrivateBrowsingCustomizeModeWidget() { 13 CustomizableUI.createWidget({ 14 id: kWidgetId, 15 showInPrivateBrowsing: false, 16 }); 17 18 let normalWidgetArray = CustomizableUI.getUnusedWidgets(gNavToolbox.palette); 19 normalWidgetArray = normalWidgetArray.map(w => w.id); 20 Assert.greater( 21 normalWidgetArray.indexOf(kWidgetId), 22 -1, 23 "Widget should appear as unused in non-private window" 24 ); 25 26 let privateWindow = await openAndLoadWindow({ private: true }); 27 let privateWidgetArray = CustomizableUI.getUnusedWidgets( 28 privateWindow.gNavToolbox.palette 29 ); 30 privateWidgetArray = privateWidgetArray.map(w => w.id); 31 is( 32 privateWidgetArray.indexOf(kWidgetId), 33 -1, 34 "Widget should not appear as unused in private window" 35 ); 36 await promiseWindowClosed(privateWindow); 37 38 CustomizableUI.destroyWidget(kWidgetId); 39 }); 40 41 add_task(async function asyncCleanup() { 42 await resetCustomization(); 43 });