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.
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=94514
5 Specifically, this tests that a page that is obtained via a post request does
6 not get added to global history.
7 -->
8 <head>
9 <title>Test for Bug 94515</title>
10 <script type="text/javascript" src="http://mochi.test:8888/tests/SimpleTest/SimpleTest.js"></script>
12 <link rel="stylesheet" type="text/css" href="http://mochi.test:8888/tests/SimpleTest/test.css" />
13 </head>
14 <body>
15 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=94514">Mozilla Bug 94514</a>
17 <div id="content" style="display: none">
19 </div>
20 <pre id="test">
21 <script class="testbody" type="text/javascript">
23 SimpleTest.waitForExplicitFinish();
25 var startURI = "http://mochi.test:8888/tests/toolkit/components/places/tests/bug94514-postpage.html";
26 var postedURI = startURI + "?posted=1";
28 const Cc = Components.classes;
29 const Ci = Components.interfaces;
31 Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
33 var ios = Cc["@mozilla.org/network/io-service;1"].
34 getService(Ci.nsIIOService);
35 var startPage = ios.newURI(startURI, null, null);
36 var postedPage = ios.newURI(postedURI, null, null);
37 var w = null;
39 // Because adding visits is async, we will not be notified imemdiately.
40 var os = Cc["@mozilla.org/observer-service;1"].
41 getService(Ci.nsIObserverService);
42 var visitObserver = {
43 _visitCount: 0,
44 observe: function(aSubject, aTopic, aData) {
45 if (!startPage.equals(aSubject.QueryInterface(Ci.nsIURI)) ||
46 ++this._visitCount < 2) {
47 return;
48 }
49 os.removeObserver(this, aTopic);
50 finishTest();
51 },
52 };
53 os.addObserver(visitObserver, "uri-visit-saved", false);
55 PlacesUtils.asyncHistory.isURIVisited(startPage, function(aURI, aIsVisited) {
56 SimpleTest.ok(!aIsVisited, "Initial page does not start in global history. " +
57 "Note: this will also fail if you run the test twice.");
58 PlacesUtils.asyncHistory.isURIVisited(postedPage, function(aURI, aIsVisited) {
59 SimpleTest.ok(!aIsVisited, "Posted page does not start in global history.");
60 w = window.open(startURI, "", "width=10,height=10");
61 });
62 });
64 function finishTest() {
65 // We need to check that this was not added to global history.
66 PlacesUtils.asyncHistory.isURIVisited(startPage, function(aURI, aIsVisited) {
67 SimpleTest.ok(aIsVisited, "Initial page was added to global history.");
68 PlacesUtils.asyncHistory.isURIVisited(postedPage, function(aURI, aIsVisited) {
69 SimpleTest.ok(!aIsVisited, "Posted page was not added to global history.");
70 w.close();
71 SimpleTest.finish();
72 });
73 });
74 }
76 </script>
77 </pre>
78 </body>
79 </html>