|
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(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 ok(normalWidgetArray.indexOf(kWidgetId) > -1, |
|
21 "Widget should appear as unused in non-private window"); |
|
22 |
|
23 let privateWindow = yield openAndLoadWindow({private: true}); |
|
24 let privateWidgetArray = CustomizableUI.getUnusedWidgets(privateWindow.gNavToolbox.palette); |
|
25 privateWidgetArray = privateWidgetArray.map((w) => w.id); |
|
26 is(privateWidgetArray.indexOf(kWidgetId), -1, |
|
27 "Widget should not appear as unused in private window"); |
|
28 yield promiseWindowClosed(privateWindow); |
|
29 |
|
30 CustomizableUI.destroyWidget(kWidgetId); |
|
31 }); |
|
32 |
|
33 add_task(function asyncCleanup() { |
|
34 yield resetCustomization(); |
|
35 }); |