Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <?xml version="1.0"?>
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/. -->
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. -->
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"?>
15 <?xml-stylesheet href="chrome://browser/content/places/places.css"?>
16 <?xml-stylesheet href="chrome://browser/skin/places/places.css"?>
18 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
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();">
24 <script type="application/javascript"
25 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
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>
33 <script type="application/javascript">
34 <![CDATA[
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 );
44 var fakeLeftPanes = [];
45 var as = PlacesUtils.annotations;
46 var bs = PlacesUtils.bookmarks;
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);
60 // Initialize the left pane queries.
61 PlacesUIUtils.leftPaneFolderId;
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");
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 });
78 }
79 ]]>
80 </script>
82 </window>