toolkit/components/places/tests/chrome/test_342484.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 /*
    17  Test loading feeds with items that aren't allowed
    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/bad_links.atom";
    31   const GOOD_URLS = ["http://example.org/first", "http://example.org/last"];
    33   PlacesUtils.livemarks.addLivemark(
    34     { title: "foo"
    35     , parentId: PlacesUtils.toolbarFolderId
    36     , index: PlacesUtils.bookmarks.DEFAULT_INDEX
    37     , feedURI: NetUtil.newURI(FEEDSPEC)
    38     , siteURI: NetUtil.newURI("http:/mochi.test/")
    39     })
    40     .then(function (aLivemark) {
    41       waitForLivemarkLoad(aLivemark, function (aLivemark) {
    42         let nodes = aLivemark.getNodesForContainer({});
    44         is(nodes.length, 2, "Created the two good livemark items");
    45         for (let i = 0; i < nodes.length; ++i) {
    46           let node = nodes[i];
    47           ok(GOOD_URLS.indexOf(node.uri) != -1, "livemark item created with bad uri " + node.uri);
    48         }
    50         PlacesUtils.bookmarks.removeItem(aLivemark.id);
    51         SimpleTest.finish();
    52       });
    53     }, function () {
    54       is(true, false, "Should not fail adding a livemark");
    55     }
    56   );
    57 }
    59 function waitForLivemarkLoad(aLivemark, aCallback) {
    60   // Don't need a real node here.
    61   let node = {};
    62   let resultObserver = {
    63     nodeInserted: function() {},
    64     nodeRemoved: function() {},
    65     nodeAnnotationChanged: function() {},
    66     nodeTitleChanged: function() {},
    67     nodeHistoryDetailsChanged: function() {},
    68     nodeMoved: function() {},
    69     ontainerStateChanged: function () {},
    70     sortingChanged: function() {},
    71     batching: function() {},
    72     invalidateContainer: function(node) {
    73       isnot(aLivemark.status, Ci.mozILivemark.STATUS_FAILED,
    74             "Loading livemark should success");
    75       if (aLivemark.status == Ci.mozILivemark.STATUS_READY) {
    76         aLivemark.unregisterForUpdates(node, resultObserver);
    77         aCallback(aLivemark);
    78       }
    79     }
    80   };
    81   aLivemark.registerForUpdates(node, resultObserver);
    82   aLivemark.reload();
    83 }
    85 ]]>
    86 </script>
    88 </window>

mercurial