Sat, 03 Jan 2015 20:18:00 +0100
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="Bug 371798" |
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 | <script type="application/javascript" |
michael@0 | 9 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 10 | |
michael@0 | 11 | <body xmlns="http://www.w3.org/1999/xhtml" /> |
michael@0 | 12 | |
michael@0 | 13 | <script type="application/javascript"> |
michael@0 | 14 | <![CDATA[ |
michael@0 | 15 | // Test the asynchronous live-updating of bookmarks query results |
michael@0 | 16 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 17 | |
michael@0 | 18 | const Cc = Components.classes; |
michael@0 | 19 | const Ci = Components.interfaces; |
michael@0 | 20 | const Cr = Components.results; |
michael@0 | 21 | |
michael@0 | 22 | var iosvc = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); |
michael@0 | 23 | |
michael@0 | 24 | function uri(spec) { |
michael@0 | 25 | return iosvc.newURI(spec, null, null); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"]. |
michael@0 | 29 | getService(Ci.nsINavHistoryService); |
michael@0 | 30 | var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. |
michael@0 | 31 | getService(Ci.nsINavBookmarksService); |
michael@0 | 32 | |
michael@0 | 33 | // add 2 bookmarks to the toolbar, same URI, different titles (set later) |
michael@0 | 34 | var toolbarFolderId = bmsvc.toolbarFolder; |
michael@0 | 35 | var testURI = uri("http://foo.com"); |
michael@0 | 36 | var bm1 = bmsvc.insertBookmark(toolbarFolderId, testURI, bmsvc.DEFAULT_INDEX, ""); |
michael@0 | 37 | var bm2 = bmsvc.insertBookmark(toolbarFolderId, testURI, bmsvc.DEFAULT_INDEX, ""); |
michael@0 | 38 | |
michael@0 | 39 | // query for bookmarks |
michael@0 | 40 | var options = histsvc.getNewQueryOptions(); |
michael@0 | 41 | var query = histsvc.getNewQuery(); |
michael@0 | 42 | query.setFolders([toolbarFolderId], 1); |
michael@0 | 43 | var result = histsvc.executeQuery(query, options); |
michael@0 | 44 | var rootNode = result.root; |
michael@0 | 45 | rootNode.containerOpen = true; |
michael@0 | 46 | |
michael@0 | 47 | // set up observer |
michael@0 | 48 | var observer = |
michael@0 | 49 | { |
michael@0 | 50 | QueryInterface: function(iid) { |
michael@0 | 51 | if (iid.equals(Ci.nsINavBookmarkObserver) || |
michael@0 | 52 | iid.equals(Ci.nsISupports)) |
michael@0 | 53 | return this; |
michael@0 | 54 | throw Cr.NS_ERROR_NO_INTERFACE; |
michael@0 | 55 | }, |
michael@0 | 56 | |
michael@0 | 57 | // nsINavBookmarkObserver |
michael@0 | 58 | onBeginUpdateBatch: function(){}, |
michael@0 | 59 | onEndUpdateBatch: function(){}, |
michael@0 | 60 | onItemAdded: function(){}, |
michael@0 | 61 | onItemRemoved: function(){}, |
michael@0 | 62 | onItemChanged: function(bookmarkId, property, isAnnotationProperty, value, |
michael@0 | 63 | lastModified, itemType){ |
michael@0 | 64 | runTest(); |
michael@0 | 65 | bmsvc.removeObserver(this); |
michael@0 | 66 | }, |
michael@0 | 67 | onItemVisited: function(){}, |
michael@0 | 68 | onItemMoved: function(){} |
michael@0 | 69 | }; |
michael@0 | 70 | bmsvc.addObserver(observer, false); |
michael@0 | 71 | |
michael@0 | 72 | // modify the bookmark's title |
michael@0 | 73 | var newTitle = "foo"; |
michael@0 | 74 | bmsvc.setItemTitle(bm2, newTitle); |
michael@0 | 75 | |
michael@0 | 76 | /* |
michael@0 | 77 | this gets called after our observer gets notified of onItemChanged |
michael@0 | 78 | which is triggered by updating the item's title. |
michael@0 | 79 | after receiving the notification, our original query should also |
michael@0 | 80 | have been live-updated, so we can iterate through its children, |
michael@0 | 81 | to check that only the modified bookmark has changed. |
michael@0 | 82 | */ |
michael@0 | 83 | function runTest() { |
michael@0 | 84 | // result node should be updated |
michael@0 | 85 | var cc = rootNode.childCount; |
michael@0 | 86 | for (var i=0; i < cc; ++i) { |
michael@0 | 87 | var node = rootNode.getChild(i); |
michael@0 | 88 | // test that bm1 does not have new title |
michael@0 | 89 | if (node.itemId == bm1) |
michael@0 | 90 | ok(node.title != newTitle, |
michael@0 | 91 | "Changing a bookmark's title did not affect the title of other bookmarks with the same URI"); |
michael@0 | 92 | } |
michael@0 | 93 | rootNode.containerOpen = false; |
michael@0 | 94 | |
michael@0 | 95 | // clean up finish test |
michael@0 | 96 | bmsvc.removeItem(bm1); |
michael@0 | 97 | bmsvc.removeItem(bm2); |
michael@0 | 98 | SimpleTest.finish(); |
michael@0 | 99 | } |
michael@0 | 100 | |
michael@0 | 101 | ]]> |
michael@0 | 102 | </script> |
michael@0 | 103 | |
michael@0 | 104 | </window> |