tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_selectItems_on_nested_tree.xhtml (2974B)


      1 <?xml version="1.0"?>
      2 
      3 <!--
      4    Any copyright is dedicated to the Public Domain.
      5    http://creativecommons.org/licenses/publicdomain/
      6   -->
      7 
      8 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
      9 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
     10                 type="text/css"?>
     11 
     12 <?xml-stylesheet href="chrome://browser/content/places/places.css"?>
     13 <?xml-stylesheet href="chrome://browser/skin/places/tree-icons.css"?>
     14 
     15 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     16        title="549192:  History view not updated after deleting entry"
     17        onload="runTest();">
     18 
     19  <script type="application/javascript"
     20          src="chrome://browser/content/places/places-tree.js"/>
     21  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
     22  <script type="application/javascript" src="head.js" />
     23 
     24  <body xmlns="http://www.w3.org/1999/xhtml" />
     25 
     26  <tree id="tree"
     27        is="places-tree"
     28        flex="1">
     29    <treecols>
     30      <treecol label="Title" id="title" anonid="title" primary="true" style="order: 1;" flex="1"/>
     31    </treecols>
     32    <treechildren flex="1"/>
     33  </tree>
     34 
     35  <script type="application/javascript"><![CDATA[
     36    /**
     37     * Ensure that selectItems doesn't recurse infinitely in nested trees.
     38     */
     39 
     40    function runTest() {
     41      SimpleTest.waitForExplicitFinish();
     42 
     43      (async function() {
     44        await PlacesUtils.bookmarks.insert({
     45          parentGuid: PlacesUtils.bookmarks.unfiledGuid,
     46          index: PlacesUtils.bookmarks.DEFAULT_INDEX,
     47          type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
     48          url: `place:parent=${PlacesUtils.bookmarks.unfiledGuid}`,
     49          title: "shortcut"
     50        });
     51 
     52        await PlacesUtils.bookmarks.insert({
     53          parentGuid: PlacesUtils.bookmarks.unfiledGuid,
     54          index: PlacesUtils.bookmarks.DEFAULT_INDEX,
     55          type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
     56          url: `place:parent=${PlacesUtils.bookmarks.unfiledGuid}&maxResults=10`,
     57          title: "query"
     58        });
     59 
     60        let folder = await PlacesUtils.bookmarks.insert({
     61          parentGuid: PlacesUtils.bookmarks.unfiledGuid,
     62          index: PlacesUtils.bookmarks.DEFAULT_INDEX,
     63          type: PlacesUtils.bookmarks.TYPE_FOLDER,
     64          title: "folder"
     65        });
     66 
     67        let bm = await PlacesUtils.bookmarks.insert({
     68          parentGuid: folder.guid,
     69          index: PlacesUtils.bookmarks.DEFAULT_INDEX,
     70          type: PlacesUtils.bookmarks.TYPE_BOOKMARK,
     71          url: "https://www.mozilla.org/",
     72          title: "bookmark"
     73        });
     74 
     75        // Setup the places tree contents.
     76        let tree = document.getElementById("tree");
     77        tree.place = `place:parent=${PlacesUtils.bookmarks.unfiledGuid}`;
     78 
     79        // Select the last bookmark.
     80        tree.selectItems([bm.guid]);
     81        is (tree.selectedNode.bookmarkGuid, bm.guid, "The right node was selected");
     82      })().then(SimpleTest.finish);
     83    }
     84  ]]></script>
     85 </window>