1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/places/tests/chrome/test_0_bug510634.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,100 @@ 1.4 +<?xml version="1.0"?> 1.5 + 1.6 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.7 + - License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.9 + 1.10 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.11 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 1.12 + type="text/css"?> 1.13 + 1.14 +<?xml-stylesheet href="chrome://browser/content/places/places.css"?> 1.15 +<?xml-stylesheet href="chrome://browser/skin/places/places.css"?> 1.16 +<?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?> 1.17 + 1.18 +<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.19 + title="510634: Wrong icons on bookmarks sidebar" 1.20 + onload="runTest();"> 1.21 + 1.22 + <script type="application/javascript" 1.23 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> 1.24 + 1.25 + <body xmlns="http://www.w3.org/1999/xhtml" /> 1.26 + 1.27 + <tree id="tree" 1.28 + type="places" 1.29 + flex="1"> 1.30 + <treecols> 1.31 + <treecol label="Title" id="title" anonid="title" primary="true" ordinal="1" flex="1"/> 1.32 + </treecols> 1.33 + <treechildren flex="1"/> 1.34 + </tree> 1.35 + 1.36 + <script type="application/javascript"> 1.37 + <![CDATA[ 1.38 + 1.39 + /** 1.40 + * Bug 510634 - Wrong icons on bookmarks sidebar 1.41 + * https://bugzilla.mozilla.org/show_bug.cgi?id=510634 1.42 + * 1.43 + * Ensures that properties for special queries are set on their tree nodes, 1.44 + * even if PlacesUIUtils.leftPaneFolderId was not initialized. 1.45 + */ 1.46 + 1.47 + SimpleTest.waitForExplicitFinish(); 1.48 + 1.49 + // converts nsISupportsArray of atoms to a simple JS-strings array 1.50 + function runTest() { 1.51 + // We need to cache and restore this getter in order to simulate 1.52 + // Bug 510634 1.53 + let cachedLeftPaneFolderIdGetter = 1.54 + PlacesUIUtils.__lookupGetter__("leftPaneFolderId"); 1.55 + // Must also cache and restore this getter as it is affected by 1.56 + // leftPaneFolderId, from bug 564900. 1.57 + let cachedAllBookmarksFolderIdGetter = 1.58 + PlacesUIUtils.__lookupGetter__("allBookmarksFolderId"); 1.59 + 1.60 + let leftPaneFolderId = PlacesUIUtils.leftPaneFolderId; 1.61 + 1.62 + // restore the getter 1.63 + PlacesUIUtils.__defineGetter__("leftPaneFolderId", cachedLeftPaneFolderIdGetter); 1.64 + 1.65 + // Setup the places tree contents. 1.66 + let tree = document.getElementById("tree"); 1.67 + tree.place = "place:queryType=1&folder=" + leftPaneFolderId; 1.68 + 1.69 + // The query-property is set on the title column for each row. 1.70 + let titleColumn = tree.treeBoxObject.columns.getColumnAt(0); 1.71 + 1.72 + // Open All Bookmarks 1.73 + tree.selectItems([PlacesUIUtils.leftPaneQueries["AllBookmarks"]]); 1.74 + PlacesUtils.asContainer(tree.selectedNode).containerOpen = true; 1.75 + is(PlacesUIUtils.allBookmarksFolderId, tree.selectedNode.itemId, 1.76 + "Opened All Bookmarks"); 1.77 + 1.78 + ["History", "Downloads", "Tags", "AllBookmarks", "BookmarksToolbar", 1.79 + "BookmarksMenu", "UnfiledBookmarks"].forEach( 1.80 + function(aQueryName, aRow) { 1.81 + let found = false; 1.82 + for (let i = 0; i < tree.view.rowCount && !found; i++) { 1.83 + rowProperties = tree.view.getCellProperties(i, titleColumn).split(" "); 1.84 + found = rowProperties.indexOf("OrganizerQuery_" + aQueryName) != -1; 1.85 + } 1.86 + ok(found, "OrganizerQuery_" + aQueryName + " is set"); 1.87 + } 1.88 + ); 1.89 + 1.90 + // Close the root node 1.91 + tree.result.root.containerOpen = false; 1.92 + 1.93 + // Restore the getters for the next test. 1.94 + PlacesUIUtils.__defineGetter__("leftPaneFolderId", cachedLeftPaneFolderIdGetter); 1.95 + PlacesUIUtils.__defineGetter__("allBookmarksFolderId", 1.96 + cachedAllBookmarksFolderIdGetter); 1.97 + 1.98 + SimpleTest.finish(); 1.99 + } 1.100 + 1.101 + ]]> 1.102 + </script> 1.103 +</window>