| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 (function() | 1 (function() |
| 2 { | 2 { |
| 3 let {application} = require("info"); | 3 let {application} = require("info"); |
| 4 if (application != "firefox") | 4 if (application != "firefox") |
| 5 return; | 5 return; |
| 6 | 6 |
| 7 let CustomizableUI = null; | 7 let CustomizableUI = null; |
| 8 let usingShim = false; | 8 let usingShim = false; |
| 9 try | 9 try |
| 10 { | 10 { |
| 11 ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm", nul l); | 11 ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm", nul l); |
| 12 } | 12 } |
| 13 catch (e) | 13 catch (e) |
| 14 { | 14 { |
| 15 usingShim = true; | 15 usingShim = true; |
| 16 // No built-in CustomizableUI API, use our own implementation. | 16 // No built-in CustomizableUI API, use our own implementation. |
| 17 ({CustomizableUI}) = require("customizableUI"); | 17 ({CustomizableUI}) = require("customizableUI"); |
| 18 } | 18 } |
| 19 | 19 |
| 20 let wnd = Utils.getChromeWindow(window); | 20 let wnd = Utils.getChromeWindow(window); |
| 21 let defaultParent = require("appSupport").defaultToolbarPosition.parent; | |
| 22 | |
| 23 let toolbox; | |
| 24 if (usingShim) | |
| 25 { | |
| 26 let toolbar = wnd.document.getElementById(defaultParent); | |
| 27 if (!toolbar) | |
| 28 return; | |
| 29 toolbox = toolbar.toolbox; | |
| 30 } | |
| 21 | 31 |
| 22 module("Icon position", { | 32 module("Icon position", { |
| 23 setup: function() | 33 setup: function() |
| 24 { | 34 { |
| 35 // Force default position | |
| 36 if (usingShim) | |
| 37 toolbox.removeAttribute("abp-iconposition"); | |
| 38 | |
| 25 if (UI.isToolbarIconVisible(wnd)) | 39 if (UI.isToolbarIconVisible(wnd)) |
| 26 UI.toggleToolbarIcon(); | 40 UI.toggleToolbarIcon(); |
| 27 }, | 41 }, |
| 28 teardown: function() | 42 teardown: function() |
| 29 { | 43 { |
| 30 UI.toggleToolbarIcon(); | 44 UI.toggleToolbarIcon(); |
| 31 UI.toggleToolbarIcon(); | 45 UI.toggleToolbarIcon(); |
| 32 } | 46 } |
| 33 }); | 47 }); |
| 34 | 48 |
| 35 test("Put icon at default position", function() | 49 test("Put icon at default position", function() |
| 36 { | 50 { |
| 37 const AREA_NAVBAR = usingShim ? "PersonalToolbar" : CustomizableUI.AREA_NAVB AR; | |
|
Wladimir Palant
2014/07/31 10:40:36
Personal toolbar, seriously? I think this should b
| |
| 38 | |
| 39 UI.toggleToolbarIcon(); | 51 UI.toggleToolbarIcon(); |
| 40 let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); | 52 let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); |
| 41 ok(placement, "Button is visible"); | 53 ok(placement, "Button is visible"); |
| 42 if (placement) | 54 if (placement) |
| 43 equal(placement.area, AREA_NAVBAR, "Button is at the right position"); | 55 equal(placement.area, defaultParent, "Button is at the right position"); |
| 44 | 56 |
| 45 UI.toggleToolbarIcon(); | 57 UI.toggleToolbarIcon(); |
| 46 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); | 58 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); |
| 47 ok(!placement, "Button is invisible"); | 59 ok(!placement, "Button is invisible"); |
| 48 | 60 |
| 49 UI.toggleToolbarIcon(); | 61 UI.toggleToolbarIcon(); |
| 50 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); | 62 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); |
| 51 ok(placement, "Button is visible"); | 63 ok(placement, "Button is visible"); |
| 52 if (placement) | 64 if (placement) |
| 53 equal(placement.area, AREA_NAVBAR, "Button is at the right position again" ); | 65 equal(placement.area, defaultParent, "Button is at the right position agai n"); |
| 54 }); | 66 }); |
| 55 | 67 |
| 56 test("Move icon into tabs bar and restore", function() | 68 test("Move icon into tabs bar and restore", function() |
| 57 { | 69 { |
| 58 // The shim doesn't have proper support for addToWidgetArea | 70 // The shim doesn't have proper support for addToWidgetArea |
| 59 if (usingShim) { | 71 if (usingShim) { |
| 60 ok(true, "Can not test"); | 72 ok(true, "Can't test"); |
|
Wladimir Palant
2014/07/31 10:40:36
Nit: this should be "Cannot"
| |
| 61 return; | 73 return; |
| 62 } | 74 } |
| 63 | 75 |
| 64 UI.toggleToolbarIcon(); | 76 UI.toggleToolbarIcon(); |
| 65 | 77 |
| 66 CustomizableUI.addWidgetToArea("abp-toolbarbutton", CustomizableUI.AREA_TABS TRIP); | 78 CustomizableUI.addWidgetToArea("abp-toolbarbutton", CustomizableUI.AREA_TABS TRIP); |
| 67 let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); | 79 let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); |
| 68 ok(placement, "Button is visible"); | 80 ok(placement, "Button is visible"); |
| 69 if (placement) | 81 if (placement) |
| 70 equal(placement.area, CustomizableUI.AREA_TABSTRIP, "Button is in tabstrip "); | 82 equal(placement.area, CustomizableUI.AREA_TABSTRIP, "Button is in tabstrip "); |
| 71 | 83 |
| 72 UI.toggleToolbarIcon(); | 84 UI.toggleToolbarIcon(); |
| 73 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); | 85 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); |
| 74 ok(!placement, "Button is invisible"); | 86 ok(!placement, "Button is invisible"); |
| 75 | 87 |
| 76 UI.toggleToolbarIcon(); | 88 UI.toggleToolbarIcon(); |
| 77 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); | 89 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); |
| 78 ok(placement, "Button is visible"); | 90 ok(placement, "Button is visible"); |
| 79 if (placement) | 91 if (placement) |
| 80 equal(placement.area, CustomizableUI.AREA_NAVBAR, "Button is at default po sition"); | 92 equal(placement.area, CustomizableUI.AREA_NAVBAR, "Button is at default po sition"); |
| 81 }); | 93 }); |
| 82 | 94 |
| 83 })(); | 95 })(); |
| LEFT | RIGHT |