2007-12-13 20:01:05 -08:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
|
|
<?xml-stylesheet
|
|
|
|
href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
|
|
|
|
<window title="Add Bad Livemarks"
|
|
|
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
2011-04-15 14:58:36 -07:00
|
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
|
|
onload="runTest()">
|
2007-12-13 20:01:05 -08:00
|
|
|
<script type="application/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
|
|
|
|
<body xmlns="http://www.w3.org/1999/xhtml" />
|
|
|
|
|
|
|
|
<script type="application/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
/*
|
|
|
|
Test loading feeds with items that aren't allowed
|
|
|
|
*/
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
const Cr = Components.results;
|
|
|
|
|
2011-04-15 14:58:36 -07:00
|
|
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
|
|
|
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
|
2007-12-13 20:01:05 -08:00
|
|
|
|
2011-04-15 14:58:36 -07:00
|
|
|
let gLivemarkId = -1;
|
2007-12-13 20:01:05 -08:00
|
|
|
|
2011-04-15 14:58:36 -07:00
|
|
|
function runTest() {
|
|
|
|
const FEEDSPEC = "http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/bad_links.atom";
|
|
|
|
|
|
|
|
let bookmarksObserver = {
|
|
|
|
QueryInterface: XPCOMUtils.generateQI([
|
|
|
|
Ci.nsINavBookmarkObserver
|
|
|
|
]),
|
|
|
|
|
|
|
|
onItemAdded: function (aItemId, aParentId, aIndex, aItemType, aURI) {
|
|
|
|
if (aURI.spec == "http://example.org/last")
|
|
|
|
this._updateFinished = true;
|
|
|
|
},
|
|
|
|
onEndUpdateBatch: function () {
|
|
|
|
if (this._updateFinished) {
|
|
|
|
PlacesUtils.bookmarks.removeObserver(this);
|
|
|
|
setTimeout(continueTest, 0);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onBeginUpdateBatch: function () {},
|
|
|
|
onBeforeItemRemoved: function () {},
|
|
|
|
onItemRemoved: function () {},
|
|
|
|
onItemChanged: function () {},
|
|
|
|
onItemVisited: function () {},
|
|
|
|
onItemMoved: function () {},
|
|
|
|
};
|
|
|
|
|
|
|
|
gLivemarkId = PlacesUtils.livemarks.createLivemarkFolderOnly(
|
|
|
|
PlacesUtils.toolbarFolderId, "foo", NetUtil.newURI("http://mochi.test/"),
|
|
|
|
NetUtil.newURI(FEEDSPEC), PlacesUtils.bookmarks.DEFAULT_INDEX
|
|
|
|
);
|
|
|
|
PlacesUtils.bookmarks.addObserver(bookmarksObserver, false);
|
|
|
|
PlacesUtils.livemarks.reloadLivemarkFolder(gLivemarkId);
|
|
|
|
}
|
2007-12-13 20:01:05 -08:00
|
|
|
|
2011-04-15 14:58:36 -07:00
|
|
|
function continueTest() {
|
|
|
|
const GOOD_URLS = ["http://example.org/first", "http://example.org/last"];
|
2007-12-13 20:01:05 -08:00
|
|
|
|
2011-04-15 14:58:36 -07:00
|
|
|
let options = PlacesUtils.history.getNewQueryOptions();
|
|
|
|
let query = PlacesUtils.history.getNewQuery();
|
2007-12-13 20:01:05 -08:00
|
|
|
query.setFolders([gLivemarkId], 1);
|
2011-04-15 14:58:36 -07:00
|
|
|
let root = PlacesUtils.history.executeQuery(query, options).root;
|
|
|
|
root.containerOpen = true;
|
|
|
|
|
|
|
|
let cc = root.childCount;
|
|
|
|
is(cc, 2, "failed to create the two good livemark items");
|
|
|
|
for (let i = 0; i < cc; ++i) {
|
|
|
|
let node = root.getChild(i);
|
|
|
|
ok(GOOD_URLS.indexOf(node.uri) != -1, "livemark item created with bad uri " + node.uri);
|
2007-12-13 20:01:05 -08:00
|
|
|
}
|
|
|
|
|
2011-04-15 14:58:36 -07:00
|
|
|
root.containerOpen = false;
|
|
|
|
PlacesUtils.bookmarks.removeItem(gLivemarkId);
|
2007-12-13 20:01:05 -08:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
</window>
|