|
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> |
|
11 |
|
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> |
|
16 |
|
17 <div id="content" style="display: none"> |
|
18 |
|
19 </div> |
|
20 <pre id="test"> |
|
21 <script class="testbody" type="text/javascript"> |
|
22 |
|
23 SimpleTest.waitForExplicitFinish(); |
|
24 |
|
25 var startURI = "http://mochi.test:8888/tests/toolkit/components/places/tests/bug94514-postpage.html"; |
|
26 var postedURI = startURI + "?posted=1"; |
|
27 |
|
28 const Cc = Components.classes; |
|
29 const Ci = Components.interfaces; |
|
30 |
|
31 Components.utils.import("resource://gre/modules/PlacesUtils.jsm"); |
|
32 |
|
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; |
|
38 |
|
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); |
|
54 |
|
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 }); |
|
63 |
|
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 } |
|
75 |
|
76 </script> |
|
77 </pre> |
|
78 </body> |
|
79 </html> |