|
1 <?xml version="1.0"?> |
|
2 |
|
3 <!-- This Source Code Form is subject to the terms of the Mozilla Public |
|
4 - License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
|
6 |
|
7 <!-- Bug 466422: |
|
8 - Check that we replace the left pane with a correct one if it gets corrupted |
|
9 - and we end up having more than one. --> |
|
10 |
|
11 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
12 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" |
|
13 type="text/css"?> |
|
14 |
|
15 <?xml-stylesheet href="chrome://browser/content/places/places.css"?> |
|
16 <?xml-stylesheet href="chrome://browser/skin/places/places.css"?> |
|
17 |
|
18 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?> |
|
19 |
|
20 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
21 title="Test handling of multiple left pane folders" |
|
22 onload="runTest();"> |
|
23 |
|
24 <script type="application/javascript" |
|
25 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" /> |
|
26 |
|
27 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
28 <p id="display"></p> |
|
29 <div id="content" style="display: none"></div> |
|
30 <pre id="test"></pre> |
|
31 </body> |
|
32 |
|
33 <script type="application/javascript"> |
|
34 <![CDATA[ |
|
35 |
|
36 function runTest() { |
|
37 // Sanity checks. |
|
38 ok(PlacesUtils, "PlacesUtils is running in chrome context"); |
|
39 ok(PlacesUIUtils, "PlacesUIUtils is running in chrome context"); |
|
40 ok(PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION > 0, |
|
41 "Left pane version in chrome context, " + |
|
42 "current version is: " + PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION ); |
|
43 |
|
44 var fakeLeftPanes = []; |
|
45 var as = PlacesUtils.annotations; |
|
46 var bs = PlacesUtils.bookmarks; |
|
47 |
|
48 // We need 2 left pane folders to simulate a corrupt profile. |
|
49 do { |
|
50 let leftPaneItems = as.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO); |
|
51 // Create a fake left pane folder. |
|
52 let fakeLeftPaneRoot = bs.createFolder(PlacesUtils.placesRootId, "", |
|
53 bs.DEFAULT_INDEX); |
|
54 as.setItemAnnotation(fakeLeftPaneRoot, PlacesUIUtils.ORGANIZER_FOLDER_ANNO, |
|
55 PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION, 0, |
|
56 as.EXPIRE_NEVER); |
|
57 fakeLeftPanes.push(fakeLeftPaneRoot); |
|
58 } while (fakeLeftPanes.length < 2); |
|
59 |
|
60 // Initialize the left pane queries. |
|
61 PlacesUIUtils.leftPaneFolderId; |
|
62 |
|
63 // Check left pane. |
|
64 ok(PlacesUIUtils.leftPaneFolderId > 0, |
|
65 "Left pane folder correctly created"); |
|
66 var leftPaneItems = as.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO); |
|
67 is(leftPaneItems.length, 1, |
|
68 "We correctly have only 1 left pane folder"); |
|
69 |
|
70 // Check that all old left pane items have been removed. |
|
71 fakeLeftPanes.forEach(function(aItemId) { |
|
72 try { |
|
73 bs.getItemTitle(aItemId); |
|
74 throw("This folder should have been removed"); |
|
75 } catch (ex) {} |
|
76 }); |
|
77 |
|
78 } |
|
79 ]]> |
|
80 </script> |
|
81 |
|
82 </window> |