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