Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 gBrowser.selectedTab = gBrowser.addTab();
7 function test() {
8 waitForExplicitFinish();
10 var URIs = [
11 "http://example.com/tests/toolkit/components/places/tests/browser/399606-window.location.href.html",
12 "http://example.com/tests/toolkit/components/places/tests/browser/399606-history.go-0.html",
13 "http://example.com/tests/toolkit/components/places/tests/browser/399606-location.replace.html",
14 "http://example.com/tests/toolkit/components/places/tests/browser/399606-location.reload.html",
15 "http://example.com/tests/toolkit/components/places/tests/browser/399606-httprefresh.html",
16 "http://example.com/tests/toolkit/components/places/tests/browser/399606-window.location.html",
17 ];
18 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
19 getService(Ci.nsINavHistoryService);
21 // Create and add history observer.
22 var historyObserver = {
23 visitCount: Array(),
24 onBeginUpdateBatch: function () {},
25 onEndUpdateBatch: function () {},
26 onVisit: function (aURI, aVisitID, aTime, aSessionID, aReferringID,
27 aTransitionType) {
28 info("Received onVisit: " + aURI.spec);
29 if (aURI.spec in this.visitCount)
30 this.visitCount[aURI.spec]++;
31 else
32 this.visitCount[aURI.spec] = 1;
33 },
34 onTitleChanged: function () {},
35 onDeleteURI: function () {},
36 onClearHistory: function () {},
37 onPageChanged: function () {},
38 onDeleteVisits: function () {},
39 QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver])
40 };
41 hs.addObserver(historyObserver, false);
43 function confirm_results() {
44 gBrowser.removeCurrentTab();
45 hs.removeObserver(historyObserver, false);
46 for (let aURI in historyObserver.visitCount) {
47 is(historyObserver.visitCount[aURI], 1,
48 "onVisit has been received right number of times for " + aURI);
49 }
50 promiseClearHistory().then(finish);
51 }
53 var loadCount = 0;
54 function handleLoad(aEvent) {
55 loadCount++;
56 info("new load count is " + loadCount);
58 if (loadCount == 3) {
59 gBrowser.removeEventListener("DOMContentLoaded", handleLoad, true);
60 content.location.href = "about:blank";
61 executeSoon(check_next_uri);
62 }
63 }
65 function check_next_uri() {
66 if (URIs.length) {
67 let uri = URIs.shift();
68 loadCount = 0;
69 gBrowser.addEventListener("DOMContentLoaded", handleLoad, true);
70 content.location.href = uri;
71 }
72 else {
73 confirm_results();
74 }
75 }
76 executeSoon(check_next_uri);
77 }