tor-browser

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

test_bug1163447_selectItems_through_shortcut.xhtml (2955B)


      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="1163447:  selectItems in Places no longer selects items within Toolbar or Sidebar folders"
     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    /**
     38     * Bug 1163447: places-tree should be able to select an item within the toolbar, and
     39     * unfiled bookmarks. Yet not follow recursive folder-shortcuts infinitely.
     40     */
     41 
     42    function runTest() {
     43      SimpleTest.waitForExplicitFinish();
     44 
     45      (async function() {
     46        let bmu = PlacesUtils.bookmarks;
     47 
     48        await bmu.insert({
     49          parentGuid: bmu.toolbarGuid,
     50          index: bmu.DEFAULT_INDEX,
     51          type: bmu.TYPE_BOOKMARK,
     52          url: `place:parent=${PlacesUtils.bookmarks.toolbarGuid}`,
     53          title: "shortcut to self - causing infinite recursion if not handled properly"
     54        });
     55 
     56        await bmu.insert({
     57          parentGuid: bmu.toolbarGuid,
     58          index: bmu.DEFAULT_INDEX,
     59          type: bmu.TYPE_BOOKMARK,
     60          url: `place:parent=${PlacesUtils.bookmarks.unfiledGuid}`,
     61          title: "shortcut to unfiled, within toolbar"
     62        });
     63 
     64        let folder = await bmu.insert({
     65          parentGuid: bmu.unfiledGuid,
     66          index: bmu.DEFAULT_INDEX,
     67          type: bmu.TYPE_FOLDER,
     68          title: "folder within unfiled"
     69        });
     70 
     71        // Setup the places tree contents.
     72        let tree = document.getElementById("tree");
     73        tree.place = `place:parent=${PlacesUtils.bookmarks.toolbarGuid}`;
     74 
     75        // Select the folder via the selectItems(folder.guid) API being tested
     76        tree.selectItems([folder.guid]);
     77 
     78        is(tree.selectedNode && tree.selectedNode.bookmarkGuid, folder.guid, "The node was selected through the shortcut");
     79 
     80        // Cleanup
     81        await bmu.eraseEverything();
     82 
     83      })().catch(err => {
     84        ok(false, `Uncaught error: ${err}`);
     85      }).then(SimpleTest.finish);
     86    }
     87  ]]></script>
     88 </window>