42 const BOOKMARKS_SIDEBAR_ID =
"viewBookmarksSidebar";
43 const BOOKMARKS_SIDEBAR_TREE_ID =
"bookmarks-view";
44 const HISTORY_SIDEBAR_ID =
"viewHistorySidebar";
45 const HISTORY_SIDEBAR_TREE_ID =
"historyTree";
48 let
ww =
Cc[
"@mozilla.org/embedcomp/window-watcher;1"].
50 let
bs = PlacesUtils.bookmarks;
51 let
hs = PlacesUtils.history;
52 let sidebarBox = document.getElementById(
"sidebar-box");
53 let
sidebar = document.getElementById(
"sidebar");
57 if (!sidebarBox.hidden) {
58 info(
"Unexpected sidebar found - a previous test failed to cleanup correctly");
62 const TEST_URL =
"javascript:alert(\"test\");";
69 this._itemID = bs.insertBookmark(bs.unfiledBookmarksFolder,
71 bs.DEFAULT_INDEX,
"test");
75 selectNode:
function(tree) {
76 tree.selectItems([this._itemID]);
79 bs.removeFolderChildren(bs.unfiledBookmarksFolder);
81 sidebarName: BOOKMARKS_SIDEBAR_ID,
82 treeName: BOOKMARKS_SIDEBAR_TREE_ID,
83 desc:
"Bookmarks sidebar test"
90 hs.addVisit(PlacesUtils._uri(
TEST_URL), Date.now() * 1000,
91 null, hs.TRANSITION_TYPED,
false, 0);
94 sidebar.contentDocument.getElementById(
"byvisited").doCommand();
96 selectNode:
function(tree) {
97 tree.selectNode(tree.view.nodeForTreeIndex(0));
98 is(tree.selectedNode.uri,
TEST_URL,
"The correct visit has been selected");
99 is(tree.selectedNode.itemId, -1,
"The selected node is not bookmarked");
102 hs.QueryInterface(
Ci.nsIBrowserHistory)
105 sidebarName: HISTORY_SIDEBAR_ID,
106 treeName: HISTORY_SIDEBAR_TREE_ID,
107 desc:
"History sidebar test"
112 function testPlacesPanel(preFunc, postFunc) {
115 sidebar.addEventListener(
"load",
function() {
116 sidebar.removeEventListener(
"load",
arguments.callee,
true);
118 let
doc = sidebar.contentDocument;
119 let tree = doc.getElementById(currentTest.treeName);
120 let tbo = tree.treeBoxObject;
122 executeSoon(
function() {
123 currentTest.prepare();
129 if (aTopic ===
"domwindowopened") {
130 ww.unregisterNotification(
this);
131 let alertDialog = aSubject.QueryInterface(
Ci.nsIDOMWindow);
132 alertDialog.addEventListener(
"load",
function() {
133 alertDialog.removeEventListener(
"load",
arguments.callee,
false);
134 info(
"alert dialog observed as expected");
135 executeSoon(
function() {
137 toggleSidebar(currentTest.sidebarName);
138 currentTest.cleanup();
145 ww.registerNotification(observer);
148 currentTest.selectNode(tree);
149 is(tbo.view.selection.count, 1,
150 "The test node should be successfully selected");
152 let
min = {}, max = {};
153 tbo.view.selection.getRangeAt(0, min, max);
154 let rowID = min.value;
155 tbo.ensureRowIsVisible(rowID);
159 tbo.getCoordsForCellItem(rowID, tree.columns[0],
"text",
161 x = x.value +
width.value / 2;
164 EventUtils.synthesizeMouse(tree.body, x,
y, {}, doc.defaultView);
173 toggleSidebar(currentTest.sidebarName);
176 function changeSidebarDirection(aDirection) {
177 document.getElementById(
"sidebar")
180 .style.direction = aDirection;
184 if (
tests.length == 0)
187 currentTest =
tests.shift();
188 testPlacesPanel(
function() {
189 changeSidebarDirection(
"ltr");
190 info(
"Running " + currentTest.desc +
" in LTR mode");
192 executeSoon(
function() {
193 testPlacesPanel(
function() {
195 changeSidebarDirection(
"rtl");
196 info(
"Running " + currentTest.desc +
" in RTL mode");
function doc() browser.contentDocument
getService(Ci.sbIFaceplateManager)
return!aWindow arguments!aWindow arguments[0]
_updateTextAndScrollDataForFrame aData
sbDeviceFirmwareAutoCheckForUpdate prototype observe