|
1 <?xml version="1.0"?> |
|
2 |
|
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/. --> |
|
6 |
|
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();"> |
|
10 |
|
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"/> |
|
17 |
|
18 <script type="application/javascript"> |
|
19 <![CDATA[ |
|
20 |
|
21 const Cc = Components.classes; |
|
22 const Ci = Components.interfaces; |
|
23 |
|
24 Components.utils.import("resource://gre/modules/PlacesUtils.jsm"); |
|
25 Components.utils.import("resource://gre/modules/NetUtil.jsm"); |
|
26 |
|
27 const SJS_URI = NetUtil.newURI("http://mochi.test:8888/tests/toolkit/components/places/tests/chrome/history_post.sjs"); |
|
28 |
|
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"); |
|
41 |
|
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 } |
|
54 |
|
55 ]]> |
|
56 </script> |
|
57 |
|
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> |