toolkit/components/places/tests/chrome/test_381357.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 Livemarks from RSS feed served as text/html"
     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 /*
    17  Test loading feeds with text/html 
    18  */
    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 function runTest() {
    30   const FEEDSPEC = "http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/rss_as_html.rss";
    32   PlacesUtils.livemarks.addLivemark(
    33     { title: "foo"
    34     , parentId: PlacesUtils.toolbarFolderId
    35     , index: PlacesUtils.bookmarks.DEFAULT_INDEX
    36     , feedURI: NetUtil.newURI(FEEDSPEC)
    37     , siteURI: NetUtil.newURI("http:/mochi.test/")
    38     })
    39     .then(function (aLivemark) {
    40       waitForLivemarkLoad(aLivemark, function (aLivemark) {
    41         let nodes = aLivemark.getNodesForContainer({});
    43         is(nodes[0].title, "The First Title",
    44            "livemark site URI set to value in feed");
    46         PlacesUtils.bookmarks.removeItem(aLivemark.id);
    47         SimpleTest.finish();
    48       });
    49     }, function () {
    50       is(true, false, "Should not fail adding a livemark");
    51       SimpleTest.finish();
    52     }
    53   );
    54 }
    56 function waitForLivemarkLoad(aLivemark, aCallback) {
    57   // Don't need a real node here.
    58   let node = {};
    59   let resultObserver = {
    60     nodeInserted: function() {},
    61     nodeRemoved: function() {},
    62     nodeAnnotationChanged: function() {},
    63     nodeTitleChanged: function() {},
    64     nodeHistoryDetailsChanged: function() {},
    65     nodeMoved: function() {},
    66     ontainerStateChanged: function () {},
    67     sortingChanged: function() {},
    68     batching: function() {},
    69     invalidateContainer: function(node) {
    70       isnot(aLivemark.status, Ci.mozILivemark.STATUS_FAILED,
    71             "Loading livemark should success");
    72       if (aLivemark.status == Ci.mozILivemark.STATUS_READY) {
    73         aLivemark.unregisterForUpdates(node, resultObserver);
    74         aCallback(aLivemark);
    75       }
    76     }
    77   };
    78   aLivemark.registerForUpdates(node, resultObserver);
    79   aLivemark.reload();
    80 }
    82 ]]>
    83 </script>
    85 </window>

mercurial