browser/components/places/tests/chrome/test_bug549192.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 <!--
     4     Any copyright is dedicated to the Public Domain.
     5     http://creativecommons.org/licenses/publicdomain/
     6    -->
     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"?>
    12 <?xml-stylesheet href="chrome://browser/content/places/places.css"?>
    13 <?xml-stylesheet href="chrome://browser/skin/places/places.css"?>
    14 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
    16 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    17         title="549192:  History view not updated after deleting entry"
    18         onload="runTest();">
    20   <script type="application/javascript"
    21           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
    22   <script type="application/javascript" src="head.js" />
    24   <body xmlns="http://www.w3.org/1999/xhtml" />
    26   <tree id="tree"
    27         type="places"
    28         flatList="true"
    29         flex="1">
    30     <treecols>
    31       <treecol label="Title" id="title" anonid="title" primary="true" ordinal="1" flex="1"/>
    32     </treecols>
    33     <treechildren flex="1"/>
    34   </tree>
    36   <script type="application/javascript"><![CDATA[
    37     /**
    38      * Bug 874407
    39      * Ensures that history views are updated properly after visits.
    40      * Bug 549192
    41      * Ensures that history views are updated after deleting entries.
    42      */
    44     SimpleTest.waitForExplicitFinish();
    46     function runTest() {
    47       // The mochitest page is added to history.
    48       waitForClearHistory(continue_test);
    49     }
    51     function continue_test() {
    52       // Add some visits.
    53       let vtime = Date.now() * 1000;
    54       const ttype = PlacesUtils.history.TRANSITION_TYPED;
    55       let places =
    56         [{ uri: Services.io.newURI("http://example.tld/", null, null),
    57            visitDate: ++vtime, transition: ttype },
    58          { uri: Services.io.newURI("http://example2.tld/", null, null),
    59            visitDate: ++vtime, transition: ttype },
    60          { uri: Services.io.newURI("http://example3.tld/", null, null),
    61            visitDate: ++vtime, transition: ttype }];
    63       addVisits(places, function() {
    64         // Make a history query.
    65         let query = PlacesUtils.history.getNewQuery();
    66         let opts = PlacesUtils.history.getNewQueryOptions();
    67         opts.sortingMode = opts.SORT_BY_DATE_DESCENDING;
    68         let queryURI = PlacesUtils.history.queriesToQueryString([query], 1, opts);
    70         // Setup the places tree contents.
    71         var tree = document.getElementById("tree");
    72         tree.place = queryURI;
    74         // loop through the rows and check them.
    75         let treeView = tree.view;
    76         let selection = treeView.selection;
    77         let rc = treeView.rowCount;
    79         for (let i = 0; i < rc; i++) {
    80           selection.select(i);
    81           let node = tree.selectedNode;
    82           is(node.uri, places[rc - i - 1].uri.spec,
    83              "Found expected node at position " + i + ".");
    84         }
    86         is(rc, 3, "Found expected number of rows.");
    88         // First check live-update of the view when adding visits.
    89         places.forEach(place => place.visitDate = ++vtime);
    90         addVisits(places, function() {
    91           for (let i = 0; i < rc; i++) {
    92             selection.select(i);
    93             let node = tree.selectedNode;
    94             is(node.uri, places[rc - i - 1].uri.spec,
    95                "Found expected node at position " + i + ".");
    96           }
    98           // Now remove the pages and verify live-update again.
    99           for (let i = 0; i < rc; i++) {
   100             selection.select(0);
   101             let node = tree.selectedNode;
   102             tree.controller.remove("Removing page");
   103             ok(treeView.treeIndexForNode(node) == Ci.nsINavHistoryResultTreeViewer.INDEX_INVISIBLE,
   104               node.uri + " removed.");
   105             ok(treeView.rowCount == rc - i - 1, "Rows count decreased");
   106           }
   108           // Cleanup.
   109           waitForClearHistory(SimpleTest.finish);
   110         });
   111       });
   112     }
   114   ]]></script>
   115 </window>

mercurial