toolkit/components/places/tests/test_bug_94514.html

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.

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

mercurial