Bug 381357. Live bookmarks for feeds served as text/html don't load. r=gavin

This commit is contained in:
sayrer@gmail.com 2008-03-11 13:05:09 -07:00
parent e36a115c19
commit 197ffe4af0
5 changed files with 115 additions and 0 deletions

View File

@ -1421,6 +1421,9 @@ FeedProcessor.prototype = {
// The XMLReader will throw sensible exceptions if these get called
// out of order.
onStartRequest: function FP_onStartRequest(request, context) {
var channel = request.QueryInterface(Ci.nsIChannel);
if (channel)
channel.contentType = "application/xml";
this._reader.onStartRequest(request, context);
},

View File

@ -47,12 +47,15 @@ include $(topsrcdir)/config/rules.mk
_HTTP_FILES = \
sample_feed.atom \
bad_links.atom \
rss_as_html.rss \
rss_as_html.rss^headers^ \
$(NULL)
_CHROME_FILES = \
test_371798.xul \
test_342484.xul \
test_341972a.xul \
test_381357.xul \
$(NULL)
libs:: $(_HTTP_FILES)

View File

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
<title>sadfasdfasdfasfasdf</title>
<link>http://www.example.com</link>
<description>asdfasdfasdf.example.com</description>
<language>de</language>
<copyright>asdfasdfasdfasdf</copyright>
<lastBuildDate>Tue, 11 Mar 2008 18:52:52 +0100</lastBuildDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<ttl>10</ttl>
<item>
<title>The First Title</title>
<link>http://www.example.com/index.html</link>
<pubDate>Tue, 11 Mar 2008 18:24:43 +0100</pubDate>
<content:encoded>
<![CDATA[
<p>
askdlfjas;dfkjas;fkdj
</p>
]]>
</content:encoded>
<description>aklsjdhfasdjfahasdfhj</description>
<guid>http://foo.example.com/asdfasdf</guid>
</item>
</channel>
</rss>

View File

@ -0,0 +1,2 @@
HTTP 200 OK
Content-Type: text/html

View File

@ -0,0 +1,80 @@
<?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 Livemarks from RSS feed served as text/html"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"></script>
<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 text/html
*/
SimpleTest.waitForExplicitFinish();
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
var iosvc = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
function uri(spec) {
return iosvc.newURI(spec, null, null);
}
var lmsvc = Cc["@mozilla.org/browser/livemark-service;2"].
getService(Ci.nsILivemarkService);
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
getService(Ci.nsINavBookmarksService);
var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var toolbarFolderId = bmsvc.toolbarFolder;
var observer =
{
QueryInterface: function(iid) {
if (iid.equals(Ci.nsINavBookmarkObserver) ||
iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
// nsINavBookmarkObserve
onBeginUpdateBatch: function(){},
onEndUpdateBatch: function(){
},
onItemAdded: function(itemId, folder, index) {
var title = bmsvc.getItemTitle(itemId);
if (title == "The First Title") {
ok(true, "Item with title loaded");
bmsvc.removeObserver(this);
SimpleTest.finish();
}
},
onItemRemoved: function(itemId, folder, index){},
onItemChanged: function(itemId, property, isAnnotationProperty, value){},
onItemVisited: function(itemId, aVisitID, time){},
onItemMoved: function(itemId, oldParent, oldIndex, newParent, newIndex){},
};
var root = bmsvc.bookmarksRoot;
const FEEDSPEC = "http://localhost:8888/tests/toolkit/components/places/tests/chrome/rss_as_html.rss";
gLivemarkId = lmsvc.createLivemarkFolderOnly(toolbarFolderId, "foo",
uri("http:/localhost/"),
uri(FEEDSPEC), -1);
bmsvc.addObserver(observer, false);
lmsvc.reloadLivemarkFolder(gLivemarkId);
]]>
</script>
</window>