toolkit/components/places/tests/chrome/test_history_post.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"?>
     3 <!-- This Source Code Form is subject to the terms of the Mozilla Public
     4    - License, v. 2.0. If a copy of the MPL was not distributed with this file,
     5    - You can obtain one at http://mozilla.org/MPL/2.0/.  -->
     7 <window title="Test post pages are not added to history"
     8         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
     9         onload="test();">
    11   <script type="application/javascript"
    12           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
    13   <script type="application/javascript"
    14           src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"/>
    15   <script type="application/javascript"
    16           src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
    18   <script type="application/javascript">
    19   <![CDATA[
    21     const Cc = Components.classes;
    22     const Ci = Components.interfaces;
    24     Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
    25     Components.utils.import("resource://gre/modules/NetUtil.jsm");
    27     const SJS_URI = NetUtil.newURI("http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/history_post.sjs");
    29     function test()
    30     {
    31       SimpleTest.waitForExplicitFinish();
    32       let submit = document.getElementById("submit");
    33       submit.click();
    34       let iframe = document.getElementById("post_iframe");
    35       iframe.addEventListener("load", function onLoad() {
    36         iframe.removeEventListener("load", onLoad);
    37         let history = Cc["@mozilla.org/browser/history;1"]
    38                         .getService(Ci.mozIAsyncHistory);
    39         history.isURIVisited(SJS_URI, function (aURI, aIsVisited) {
    40           ok(!aIsVisited, "The POST page should not be added to history");
    42           let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase)
    43                                   .DBConnection;
    44           let stmt = db.createStatement(
    45             "SELECT 1 FROM moz_places WHERE url = :page_url"
    46           );
    47           stmt.params.page_url = SJS_URI.spec;
    48           ok(!stmt.executeStep(), "The page should not be in the database");
    49           stmt.finalize();
    50           SimpleTest.finish();
    51         });
    52       });
    53     }
    55   ]]>
    56   </script>
    58   <body xmlns="http://www.w3.org/1999/xhtml">
    59     <iframe name="post_iframe" id="post_iframe"/>
    60     <form method="post" action="http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/history_post.sjs" target="post_iframe">
    61       <input type="submit" id="submit"/>
    62     </form>
    63     <p id="display"></p>
    64     <div id="content" style="display:none;"></div>
    65     <pre id="test"></pre>
    66   </body>
    67 </window>

mercurial