DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Mercurial (b6057e17f856)

VCS Links

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
<?xml version="1.0"?>

<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<!-- Bug 466422:
   - Check that we replace the left pane with a correct one if it gets corrupted
   - and we end up having more than one. -->

<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
                 type="text/css"?>

<?xml-stylesheet href="chrome://browser/content/places/places.css"?>
<?xml-stylesheet href="chrome://browser/skin/places/places.css"?>

<?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>

<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        title="Test handling of multiple left pane folders"
        onload="runTest();">

  <script type="application/javascript"
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />

  <body xmlns="http://www.w3.org/1999/xhtml">
    <p id="display"></p>
    <div id="content" style="display: none"></div>
    <pre id="test"></pre>
  </body>

  <script type="application/javascript">
  <![CDATA[

    function runTest() {
      // Sanity checks.
      ok(PlacesUtils, "PlacesUtils is running in chrome context");
      ok(PlacesUIUtils, "PlacesUIUtils is running in chrome context");
      ok(PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION > 0,
         "Left pane version in chrome context, " +
           "current version is: " + PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION );

      var fakeLeftPanes = [];
      var as = PlacesUtils.annotations;
      var bs = PlacesUtils.bookmarks;

      // We need 2 left pane folders to simulate a corrupt profile.
      do {
        let leftPaneItems = as.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
        // Create a fake left pane folder.
        let fakeLeftPaneRoot = bs.createFolder(PlacesUtils.placesRootId, "",
                                               bs.DEFAULT_INDEX);
        as.setItemAnnotation(fakeLeftPaneRoot, PlacesUIUtils.ORGANIZER_FOLDER_ANNO,
                             PlacesUIUtils.ORGANIZER_LEFTPANE_VERSION, 0,
                             as.EXPIRE_NEVER);
        fakeLeftPanes.push(fakeLeftPaneRoot);
      } while (fakeLeftPanes.length < 2);

      // Initialize the left pane queries.
      PlacesUIUtils.leftPaneFolderId;

      // Check left pane.
      ok(PlacesUIUtils.leftPaneFolderId > 0,
         "Left pane folder correctly created");
      var leftPaneItems = as.getItemsWithAnnotation(PlacesUIUtils.ORGANIZER_FOLDER_ANNO);
      is(leftPaneItems.length, 1,
         "We correctly have only 1 left pane folder");

      // Check that all old left pane items have been removed.
      fakeLeftPanes.forEach(function(aItemId) {
        try {
          bs.getItemTitle(aItemId);
          throw("This folder should have been removed");
        } catch (ex) {}
      });

    }
  ]]>
  </script>

</window>