Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: chrome/content/tests/ui/icon_position.js

Issue 5390879414026240: Issue 101 - Fix icon tests (Closed)
Left Patch Set: Created July 28, 2014, 10:19 a.m.
Right Patch Set: fixed comments Created July 31, 2014, 12:13 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 try 9 try
9 { 10 {
10 ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm", nul l); 11 ({CustomizableUI}) = Cu.import("resource:///modules/CustomizableUI.jsm", nul l);
11 } 12 }
12 catch (e) 13 catch (e)
13 { 14 {
14 return; 15 usingShim = true;
Wladimir Palant 2014/07/30 06:04:52 I wonder whether we can have a solution that works
16 // No built-in CustomizableUI API, use our own implementation.
17 ({CustomizableUI}) = require("customizableUI");
15 } 18 }
16 19
17 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 }
18 31
19 module("Icon position", { 32 module("Icon position", {
20 setup: function() 33 setup: function()
21 { 34 {
35 // Force default position
36 if (usingShim)
37 toolbox.removeAttribute("abp-iconposition");
38
22 if (UI.isToolbarIconVisible(wnd)) 39 if (UI.isToolbarIconVisible(wnd))
23 UI.toggleToolbarIcon(); 40 UI.toggleToolbarIcon();
24 }, 41 },
25 teardown: function() 42 teardown: function()
26 { 43 {
27 UI.toggleToolbarIcon(); 44 UI.toggleToolbarIcon();
28 UI.toggleToolbarIcon(); 45 UI.toggleToolbarIcon();
29 } 46 }
30 }); 47 });
31 48
32 test("Put icon at default position", function() 49 test("Put icon at default position", function()
33 { 50 {
34 UI.toggleToolbarIcon(); 51 UI.toggleToolbarIcon();
35 let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); 52 let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton");
36 ok(placement, "Button is visible"); 53 ok(placement, "Button is visible");
37 if (placement) 54 if (placement)
38 equal(placement.area, CustomizableUI.AREA_NAVBAR, "Button is at the right position"); 55 equal(placement.area, defaultParent, "Button is at the right position");
39 56
40 UI.toggleToolbarIcon(); 57 UI.toggleToolbarIcon();
41 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); 58 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton");
42 ok(!placement, "Button is invisible"); 59 ok(!placement, "Button is invisible");
43 60
44 UI.toggleToolbarIcon(); 61 UI.toggleToolbarIcon();
45 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); 62 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton");
46 ok(placement, "Button is visible"); 63 ok(placement, "Button is visible");
47 if (placement) 64 if (placement)
48 equal(placement.area, CustomizableUI.AREA_NAVBAR, "Button is at the right position again"); 65 equal(placement.area, defaultParent, "Button is at the right position agai n");
49 }); 66 });
50 67
51 test("Move icon into tabs bar and restore", function() 68 test("Move icon into tabs bar and restore", function()
52 { 69 {
70 // The shim doesn't have proper support for addToWidgetArea
71 if (usingShim) {
72 ok(true, "Can't test");
73 return;
74 }
75
53 UI.toggleToolbarIcon(); 76 UI.toggleToolbarIcon();
54 77
55 CustomizableUI.addWidgetToArea("abp-toolbarbutton", CustomizableUI.AREA_TABS TRIP); 78 CustomizableUI.addWidgetToArea("abp-toolbarbutton", CustomizableUI.AREA_TABS TRIP);
56 let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); 79 let placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton");
57 ok(placement, "Button is visible"); 80 ok(placement, "Button is visible");
58 if (placement) 81 if (placement)
59 equal(placement.area, CustomizableUI.AREA_TABSTRIP, "Button is in tabstrip "); 82 equal(placement.area, CustomizableUI.AREA_TABSTRIP, "Button is in tabstrip ");
60 83
61 UI.toggleToolbarIcon(); 84 UI.toggleToolbarIcon();
62 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); 85 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton");
63 ok(!placement, "Button is invisible"); 86 ok(!placement, "Button is invisible");
64 87
65 UI.toggleToolbarIcon(); 88 UI.toggleToolbarIcon();
66 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton"); 89 placement = CustomizableUI.getPlacementOfWidget("abp-toolbarbutton");
67 ok(placement, "Button is visible"); 90 ok(placement, "Button is visible");
68 if (placement) 91 if (placement)
69 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");
70 }); 93 });
71 94
72 })(); 95 })();
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld