browser/components/places/tests/chrome/test_bug549491.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.

michael@0 1 <?xml version="1.0"?>
michael@0 2
michael@0 3 <!--
michael@0 4 Any copyright is dedicated to the Public Domain.
michael@0 5 http://creativecommons.org/licenses/publicdomain/
michael@0 6 -->
michael@0 7
michael@0 8 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 9 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
michael@0 10 type="text/css"?>
michael@0 11
michael@0 12 <?xml-stylesheet href="chrome://browser/content/places/places.css"?>
michael@0 13 <?xml-stylesheet href="chrome://browser/skin/places/places.css"?>
michael@0 14 <?xul-overlay href="chrome://browser/content/places/placesOverlay.xul"?>
michael@0 15
michael@0 16 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 17 title="549491: 'The root node is never visible' exception when details of the root node are modified "
michael@0 18 onload="runTest();">
michael@0 19
michael@0 20 <script type="application/javascript"
michael@0 21 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
michael@0 22 <script type="application/javascript" src="head.js" />
michael@0 23
michael@0 24 <body xmlns="http://www.w3.org/1999/xhtml" />
michael@0 25
michael@0 26 <tree id="tree"
michael@0 27 type="places"
michael@0 28 flatList="true"
michael@0 29 flex="1">
michael@0 30 <treecols>
michael@0 31 <treecol label="Title" id="title" anonid="title" primary="true" ordinal="1" flex="1"/>
michael@0 32 <splitter class="tree-splitter"/>
michael@0 33 <treecol label="Date" anonid="date" flex="1"/>
michael@0 34 </treecols>
michael@0 35 <treechildren flex="1"/>
michael@0 36 </tree>
michael@0 37
michael@0 38 <script type="application/javascript"><![CDATA[
michael@0 39 /**
michael@0 40 * Bug 549491
michael@0 41 * https://bugzilla.mozilla.org/show_bug.cgi?id=549491
michael@0 42 *
michael@0 43 * Ensures that changing the details of places tree's root-node doesn't
michael@0 44 * throw.
michael@0 45 */
michael@0 46
michael@0 47 SimpleTest.waitForExplicitFinish();
michael@0 48
michael@0 49 function runTest() {
michael@0 50 // The mochitest page is added to history.
michael@0 51 waitForClearHistory(continue_test);
michael@0 52 }
michael@0 53
michael@0 54 function continue_test() {
michael@0 55 addVisits(
michael@0 56 {uri: Services.io.newURI("http://example.tld/", null, null),
michael@0 57 transition: PlacesUtils.history.TRANSITION_TYPED},
michael@0 58 function() {
michael@0 59 // Make a history query.
michael@0 60 let query = PlacesUtils.history.getNewQuery();
michael@0 61 let opts = PlacesUtils.history.getNewQueryOptions();
michael@0 62 let queryURI = PlacesUtils.history.queriesToQueryString([query], 1, opts);
michael@0 63
michael@0 64 // Setup the places tree contents.
michael@0 65 let tree = document.getElementById("tree");
michael@0 66 tree.place = queryURI;
michael@0 67
michael@0 68 let rootNode = tree.result.root;
michael@0 69 let obs = tree.view.QueryInterface(Ci.nsINavHistoryResultObserver);
michael@0 70 obs.nodeHistoryDetailsChanged(rootNode, rootNode.time, rootNode.accessCount);
michael@0 71 obs.nodeTitleChanged(rootNode, rootNode.title);
michael@0 72 ok(true, "No exceptions thrown");
michael@0 73
michael@0 74 // Cleanup.
michael@0 75 waitForClearHistory(SimpleTest.finish);
michael@0 76 });
michael@0 77 }
michael@0 78
michael@0 79 /**
michael@0 80 * Clears history invoking callback when done.
michael@0 81 */
michael@0 82 function waitForClearHistory(aCallback) {
michael@0 83 const TOPIC_EXPIRATION_FINISHED = "places-expiration-finished";
michael@0 84 let observer = {
michael@0 85 observe: function(aSubject, aTopic, aData) {
michael@0 86 Services.obs.removeObserver(this, TOPIC_EXPIRATION_FINISHED);
michael@0 87 aCallback();
michael@0 88 }
michael@0 89 };
michael@0 90 Services.obs.addObserver(observer, TOPIC_EXPIRATION_FINISHED, false);
michael@0 91 let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
michael@0 92 getService(Ci.nsINavHistoryService);
michael@0 93 hs.QueryInterface(Ci.nsIBrowserHistory).removeAllPages();
michael@0 94 }
michael@0 95
michael@0 96 ]]></script>
michael@0 97 </window>

mercurial