1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/chrome/test_history_post.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +<?xml version="1.0"?> 1.5 + 1.6 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.7 + - License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + - You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.9 + 1.10 +<window title="Test post pages are not added to history" 1.11 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.12 + onload="test();"> 1.13 + 1.14 + <script type="application/javascript" 1.15 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.16 + <script type="application/javascript" 1.17 + src="chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js"/> 1.18 + <script type="application/javascript" 1.19 + src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 1.20 + 1.21 + <script type="application/javascript"> 1.22 + <![CDATA[ 1.23 + 1.24 + const Cc = Components.classes; 1.25 + const Ci = Components.interfaces; 1.26 + 1.27 + Components.utils.import("resource://gre/modules/PlacesUtils.jsm"); 1.28 + Components.utils.import("resource://gre/modules/NetUtil.jsm"); 1.29 + 1.30 + const SJS_URI = NetUtil.newURI("http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/history_post.sjs"); 1.31 + 1.32 + function test() 1.33 + { 1.34 + SimpleTest.waitForExplicitFinish(); 1.35 + let submit = document.getElementById("submit"); 1.36 + submit.click(); 1.37 + let iframe = document.getElementById("post_iframe"); 1.38 + iframe.addEventListener("load", function onLoad() { 1.39 + iframe.removeEventListener("load", onLoad); 1.40 + let history = Cc["@mozilla.org/browser/history;1"] 1.41 + .getService(Ci.mozIAsyncHistory); 1.42 + history.isURIVisited(SJS_URI, function (aURI, aIsVisited) { 1.43 + ok(!aIsVisited, "The POST page should not be added to history"); 1.44 + 1.45 + let db = PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase) 1.46 + .DBConnection; 1.47 + let stmt = db.createStatement( 1.48 + "SELECT 1 FROM moz_places WHERE url = :page_url" 1.49 + ); 1.50 + stmt.params.page_url = SJS_URI.spec; 1.51 + ok(!stmt.executeStep(), "The page should not be in the database"); 1.52 + stmt.finalize(); 1.53 + SimpleTest.finish(); 1.54 + }); 1.55 + }); 1.56 + } 1.57 + 1.58 + ]]> 1.59 + </script> 1.60 + 1.61 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.62 + <iframe name="post_iframe" id="post_iframe"/> 1.63 + <form method="post" action="http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/history_post.sjs" target="post_iframe"> 1.64 + <input type="submit" id="submit"/> 1.65 + </form> 1.66 + <p id="display"></p> 1.67 + <div id="content" style="display:none;"></div> 1.68 + <pre id="test"></pre> 1.69 + </body> 1.70 +</window>