summaryrefslogtreecommitdiffstats
path: root/toolkit/components/places/tests/chrome/test_303567.xul
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/components/places/tests/chrome/test_303567.xul
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/places/tests/chrome/test_303567.xul')
-rw-r--r--toolkit/components/places/tests/chrome/test_303567.xul122
1 files changed, 122 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/chrome/test_303567.xul b/toolkit/components/places/tests/chrome/test_303567.xul
new file mode 100644
index 000000000..37ae77cbb
--- /dev/null
+++ b/toolkit/components/places/tests/chrome/test_303567.xul
@@ -0,0 +1,122 @@
+<?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"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="runTest()">
+ <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 that for feeds with items that have no link:
+// * the link-less items are present in the database.
+// * the feed's site URI is substituted for each item's link.
+SimpleTest.waitForExplicitFinish();
+
+var Cc = Components.classes;
+var Ci = Components.interfaces;
+var Cr = Components.results;
+
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/NetUtil.jsm");
+Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
+
+const LIVEMARKS = [
+ { feedURI: NetUtil.newURI("http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/link-less-items.rss"),
+ siteURI: NetUtil.newURI("http://mochi.test:8888/"),
+ urls: [
+ "http://feed-item-link.com/",
+ "http://feed-link.com/",
+ "http://feed-item-link.com/",
+ ],
+ message: "Ensure link-less livemark item picked up site uri.",
+ },
+ { feedURI: NetUtil.newURI("http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/link-less-items-no-site-uri.rss"),
+ siteURI: null,
+ urls: [
+ "http://feed-item-link.com/",
+ "http://feed-item-link.com/",
+ ],
+ message: "Ensure livemark item links did not inherit site uri."
+ },
+];
+
+function runTest()
+{
+ let loadCount = 0;
+
+ function testLivemark(aLivemarkData) {
+ PlacesUtils.livemarks.addLivemark(
+ { title: "foo"
+ , parentGuid: PlacesUtils.bookmarks.toolbarGuid
+ , feedURI: aLivemarkData.feedURI
+ , siteURI: aLivemarkData.siteURI
+ })
+ .then(function (aLivemark) {
+ is (aLivemark.feedURI.spec, aLivemarkData.feedURI.spec,
+ "Get correct feedURI");
+ if (aLivemarkData.siteURI) {
+ is (aLivemark.siteURI.spec, aLivemarkData.siteURI.spec,
+ "Get correct siteURI");
+ }
+ else {
+ is (aLivemark.siteURI, null, "Get correct siteURI");
+ }
+
+ waitForLivemarkLoad(aLivemark, function (aLivemark) {
+ let nodes = aLivemark.getNodesForContainer({});
+ is(nodes.length, aLivemarkData.urls.length,
+ "Ensure all the livemark items were created.");
+ aLivemarkData.urls.forEach(function (aUrl, aIndex) {
+ let node = nodes[aIndex];
+ is(node.uri, aUrl, aLivemarkData.message);
+ });
+
+ PlacesUtils.livemarks.removeLivemark(aLivemark).then(() => {
+ if (++loadCount == LIVEMARKS.length)
+ SimpleTest.finish();
+ });
+ });
+ }, function () {
+ is(true, false, "Should not fail adding a livemark");
+ }
+ );
+ }
+
+ LIVEMARKS.forEach(testLivemark);
+}
+
+function waitForLivemarkLoad(aLivemark, aCallback) {
+ // Don't need a real node here.
+ let node = {};
+ let resultObserver = {
+ nodeInserted: function() {},
+ nodeRemoved: function() {},
+ nodeAnnotationChanged: function() {},
+ nodeTitleChanged: function() {},
+ nodeHistoryDetailsChanged: function() {},
+ nodeMoved: function() {},
+ ontainerStateChanged: function () {},
+ sortingChanged: function() {},
+ batching: function() {},
+ invalidateContainer: function(node) {
+ isnot(aLivemark.status, Ci.mozILivemark.STATUS_FAILED,
+ "Loading livemark should success");
+ if (aLivemark.status == Ci.mozILivemark.STATUS_READY) {
+ aLivemark.unregisterForUpdates(node, resultObserver);
+ aCallback(aLivemark);
+ }
+ }
+ };
+ aLivemark.registerForUpdates(node, resultObserver);
+ aLivemark.reload();
+}
+
+]]>
+</script>
+</window>