toolkit/components/places/tests/chrome/test_303567.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
michael@0 3 <?xml-stylesheet
michael@0 4 href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
michael@0 5 <window title="Add Bad Livemarks"
michael@0 6 xmlns:html="http://www.w3.org/1999/xhtml"
michael@0 7 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 8 onload="runTest()">
michael@0 9 <script type="application/javascript"
michael@0 10 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
michael@0 11
michael@0 12 <body xmlns="http://www.w3.org/1999/xhtml" />
michael@0 13
michael@0 14 <script type="application/javascript">
michael@0 15 <![CDATA[
michael@0 16 // Test that for feeds with items that have no link:
michael@0 17 // * the link-less items are present in the database.
michael@0 18 // * the feed's site URI is substituted for each item's link.
michael@0 19 SimpleTest.waitForExplicitFinish();
michael@0 20
michael@0 21 const Cc = Components.classes;
michael@0 22 const Ci = Components.interfaces;
michael@0 23 const Cr = Components.results;
michael@0 24
michael@0 25 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
michael@0 26 Components.utils.import("resource://gre/modules/NetUtil.jsm");
michael@0 27 Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
michael@0 28
michael@0 29 const LIVEMARKS = [
michael@0 30 { feedURI: NetUtil.newURI("http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/link-less-items.rss"),
michael@0 31 siteURI: NetUtil.newURI("http://mochi.test:8888/"),
michael@0 32 urls: [
michael@0 33 "http://feed-item-link.com/",
michael@0 34 "http://feed-link.com/",
michael@0 35 "http://feed-item-link.com/",
michael@0 36 ],
michael@0 37 message: "Ensure link-less livemark item picked up site uri.",
michael@0 38 },
michael@0 39 { feedURI: NetUtil.newURI("http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/link-less-items-no-site-uri.rss"),
michael@0 40 siteURI: null,
michael@0 41 urls: [
michael@0 42 "http://feed-item-link.com/",
michael@0 43 "http://feed-item-link.com/",
michael@0 44 ],
michael@0 45 message: "Ensure livemark item links did not inherit site uri."
michael@0 46 },
michael@0 47 ];
michael@0 48
michael@0 49 function runTest()
michael@0 50 {
michael@0 51 function testLivemark(aLivemarkData) {
michael@0 52 PlacesUtils.livemarks.addLivemark(
michael@0 53 { title: "foo"
michael@0 54 , parentId: PlacesUtils.toolbarFolderId
michael@0 55 , index: PlacesUtils.bookmarks.DEFAULT_INDEX
michael@0 56 , feedURI: aLivemarkData.feedURI
michael@0 57 , siteURI: aLivemarkData.siteURI
michael@0 58 })
michael@0 59 .then(function (aLivemark) {
michael@0 60 is (aLivemark.feedURI.spec, aLivemarkData.feedURI.spec,
michael@0 61 "Get correct feedURI");
michael@0 62 if (aLivemarkData.siteURI) {
michael@0 63 is (aLivemark.siteURI.spec, aLivemarkData.siteURI.spec,
michael@0 64 "Get correct siteURI");
michael@0 65 }
michael@0 66 else {
michael@0 67 is (aLivemark.siteURI, null, "Get correct siteURI");
michael@0 68 }
michael@0 69
michael@0 70 waitForLivemarkLoad(aLivemark, function (aLivemark) {
michael@0 71 let nodes = aLivemark.getNodesForContainer({});
michael@0 72 is(nodes.length, aLivemarkData.urls.length,
michael@0 73 "Ensure all the livemark items were created.");
michael@0 74 aLivemarkData.urls.forEach(function (aUrl, aIndex) {
michael@0 75 let node = nodes[aIndex];
michael@0 76 is(node.uri, aUrl, aLivemarkData.message);
michael@0 77 });
michael@0 78
michael@0 79 PlacesUtils.bookmarks.removeItem(aLivemark.id);
michael@0 80
michael@0 81 if (aLivemark.feedURI.equals(LIVEMARKS[LIVEMARKS.length - 1].feedURI)) {
michael@0 82 SimpleTest.finish();
michael@0 83 }
michael@0 84 });
michael@0 85 }, function () {
michael@0 86 is(true, false, "Should not fail adding a livemark");
michael@0 87 }
michael@0 88 );
michael@0 89 }
michael@0 90
michael@0 91 LIVEMARKS.forEach(testLivemark);
michael@0 92 }
michael@0 93
michael@0 94 function waitForLivemarkLoad(aLivemark, aCallback) {
michael@0 95 // Don't need a real node here.
michael@0 96 let node = {};
michael@0 97 let resultObserver = {
michael@0 98 nodeInserted: function() {},
michael@0 99 nodeRemoved: function() {},
michael@0 100 nodeAnnotationChanged: function() {},
michael@0 101 nodeTitleChanged: function() {},
michael@0 102 nodeHistoryDetailsChanged: function() {},
michael@0 103 nodeMoved: function() {},
michael@0 104 ontainerStateChanged: function () {},
michael@0 105 sortingChanged: function() {},
michael@0 106 batching: function() {},
michael@0 107 invalidateContainer: function(node) {
michael@0 108 isnot(aLivemark.status, Ci.mozILivemark.STATUS_FAILED,
michael@0 109 "Loading livemark should success");
michael@0 110 if (aLivemark.status == Ci.mozILivemark.STATUS_READY) {
michael@0 111 aLivemark.unregisterForUpdates(node, resultObserver);
michael@0 112 aCallback(aLivemark);
michael@0 113 }
michael@0 114 }
michael@0 115 };
michael@0 116 aLivemark.registerForUpdates(node, resultObserver);
michael@0 117 aLivemark.reload();
michael@0 118 }
michael@0 119
michael@0 120 ]]>
michael@0 121 </script>
michael@0 122 </window>

mercurial