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.

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

mercurial