Bug 1333428 - Wait for loads on new tabs to avoid double-counting.
MozReview-Commit-ID: 6O0L9A6qtUR
--- a/browser/base/content/test/general/browser_trackingUI_telemetry.js
+++ b/browser/base/content/test/general/browser_trackingUI_telemetry.js
@@ -61,17 +61,17 @@ add_task(function* setup() {
// Enable TP so the next browser to open will log 'enabled'
Services.prefs.setBoolPref(PREF, true);
});
add_task(function* testNewWindow() {
let newWin = yield promiseOpenAndLoadWindow({}, true);
- let tab = newWin.gBrowser.selectedTab = newWin.gBrowser.addTab();
+ let tab = yield BrowserTestUtils.openNewForegroundTab(newWin.gBrowser);
let TrackingProtection = newWin.TrackingProtection;
ok(TrackingProtection, "TP is attached to the browser window");
is(getEnabledCounts()[0], 1, "TP was disabled once on start up");
is(getEnabledCounts()[1], 1, "TP was enabled once on start up");
// Reset these to make counting easier
getEventsHistogram().clear();
@@ -117,17 +117,17 @@ add_task(function* testNewWindow() {
// Reset these to make counting easier for the next test
getEventsHistogram().clear();
getShieldHistogram().clear();
getEnabledHistogram().clear();
});
add_task(function* testPrivateBrowsing() {
let privateWin = yield promiseOpenAndLoadWindow({private: true}, true);
- let tab = privateWin.gBrowser.selectedTab = privateWin.gBrowser.addTab();
+ let tab = yield BrowserTestUtils.openNewForegroundTab(privateWin.gBrowser);
let TrackingProtection = privateWin.TrackingProtection;
ok(TrackingProtection, "TP is attached to the browser window");
// Do a bunch of actions and make sure that no telemetry data is gathered
yield promiseTabLoadEvent(tab, BENIGN_PAGE);
yield promiseTabLoadEvent(tab, TRACKING_PAGE);
let tabReloadPromise = promiseTabLoadEvent(tab);
privateWin.document.querySelector("#tracking-action-unblock").doCommand();