diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/components/places/tests/browser/browser_bug399606.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/places/tests/browser/browser_bug399606.js')
-rw-r--r-- | toolkit/components/places/tests/browser/browser_bug399606.js | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/toolkit/components/places/tests/browser/browser_bug399606.js b/toolkit/components/places/tests/browser/browser_bug399606.js new file mode 100644 index 000000000..b5eee0f92 --- /dev/null +++ b/toolkit/components/places/tests/browser/browser_bug399606.js @@ -0,0 +1,77 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +gBrowser.selectedTab = gBrowser.addTab(); + +function test() { + waitForExplicitFinish(); + + var URIs = [ + "http://example.com/tests/toolkit/components/places/tests/browser/399606-window.location.href.html", + "http://example.com/tests/toolkit/components/places/tests/browser/399606-history.go-0.html", + "http://example.com/tests/toolkit/components/places/tests/browser/399606-location.replace.html", + "http://example.com/tests/toolkit/components/places/tests/browser/399606-location.reload.html", + "http://example.com/tests/toolkit/components/places/tests/browser/399606-httprefresh.html", + "http://example.com/tests/toolkit/components/places/tests/browser/399606-window.location.html", + ]; + var hs = Cc["@mozilla.org/browser/nav-history-service;1"]. + getService(Ci.nsINavHistoryService); + + // Create and add history observer. + var historyObserver = { + visitCount: Array(), + onBeginUpdateBatch: function () {}, + onEndUpdateBatch: function () {}, + onVisit: function (aURI, aVisitID, aTime, aSessionID, aReferringID, + aTransitionType) { + info("Received onVisit: " + aURI.spec); + if (aURI.spec in this.visitCount) + this.visitCount[aURI.spec]++; + else + this.visitCount[aURI.spec] = 1; + }, + onTitleChanged: function () {}, + onDeleteURI: function () {}, + onClearHistory: function () {}, + onPageChanged: function () {}, + onDeleteVisits: function () {}, + QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryObserver]) + }; + hs.addObserver(historyObserver, false); + + function confirm_results() { + gBrowser.removeCurrentTab(); + hs.removeObserver(historyObserver, false); + for (let aURI in historyObserver.visitCount) { + is(historyObserver.visitCount[aURI], 1, + "onVisit has been received right number of times for " + aURI); + } + PlacesTestUtils.clearHistory().then(finish); + } + + var loadCount = 0; + function handleLoad(aEvent) { + loadCount++; + info("new load count is " + loadCount); + + if (loadCount == 3) { + gBrowser.removeEventListener("DOMContentLoaded", handleLoad, true); + gBrowser.loadURI("about:blank"); + executeSoon(check_next_uri); + } + } + + function check_next_uri() { + if (URIs.length) { + let uri = URIs.shift(); + loadCount = 0; + gBrowser.addEventListener("DOMContentLoaded", handleLoad, true); + gBrowser.loadURI(uri); + } + else { + confirm_results(); + } + } + executeSoon(check_next_uri); +} |