Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | "use strict"; |
michael@0 | 7 | |
michael@0 | 8 | function test() { |
michael@0 | 9 | runTests(); |
michael@0 | 10 | } |
michael@0 | 11 | |
michael@0 | 12 | function getTelemetryPayload() { |
michael@0 | 13 | return Cu.import("resource://gre/modules/TelemetryPing.jsm", {}). |
michael@0 | 14 | TelemetryPing.getPayload(); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | gTests.push({ |
michael@0 | 18 | desc: "Test browser-ui telemetry", |
michael@0 | 19 | run: function testBrowserUITelemetry() { |
michael@0 | 20 | // startup should have registered simple measures function |
michael@0 | 21 | is(getTelemetryPayload().info.appName, "MetroFirefox"); |
michael@0 | 22 | |
michael@0 | 23 | let simpleMeasurements = getTelemetryPayload().simpleMeasurements; |
michael@0 | 24 | ok(simpleMeasurements, "simpleMeasurements are truthy"); |
michael@0 | 25 | ok(simpleMeasurements.UITelemetry["metro-ui"]["window-width"], "window-width measurement was captured"); |
michael@0 | 26 | ok(simpleMeasurements.UITelemetry["metro-ui"]["window-height"], "window-height measurement was captured"); |
michael@0 | 27 | } |
michael@0 | 28 | }); |
michael@0 | 29 | |
michael@0 | 30 | gTests.push({ |
michael@0 | 31 | desc: "Test tab count telemetry", |
michael@0 | 32 | run: function() { |
michael@0 | 33 | // Wait for Session Manager to be initialized. |
michael@0 | 34 | yield waitForCondition(() => window.__SSID); |
michael@0 | 35 | |
michael@0 | 36 | Services.obs.notifyObservers(null, "reset-telemetry-vars", null); |
michael@0 | 37 | yield waitForCondition(function () { |
michael@0 | 38 | let simpleMeasurements = getTelemetryPayload().simpleMeasurements; |
michael@0 | 39 | return simpleMeasurements.UITelemetry["metro-tabs"]["currTabCount"] == 1; |
michael@0 | 40 | }); |
michael@0 | 41 | |
michael@0 | 42 | let simpleMeasurements = getTelemetryPayload().simpleMeasurements; |
michael@0 | 43 | is(simpleMeasurements.UITelemetry["metro-tabs"]["currTabCount"], 1); |
michael@0 | 44 | is(simpleMeasurements.UITelemetry["metro-tabs"]["maxTabCount"], 1); |
michael@0 | 45 | |
michael@0 | 46 | let tab2 = Browser.addTab("about:mozilla"); |
michael@0 | 47 | simpleMeasurements = getTelemetryPayload().simpleMeasurements; |
michael@0 | 48 | is(simpleMeasurements.UITelemetry["metro-tabs"]["currTabCount"], 2); |
michael@0 | 49 | is(simpleMeasurements.UITelemetry["metro-tabs"]["maxTabCount"], 2); |
michael@0 | 50 | |
michael@0 | 51 | let tab3 = Browser.addTab("about:config"); |
michael@0 | 52 | simpleMeasurements = getTelemetryPayload().simpleMeasurements; |
michael@0 | 53 | is(simpleMeasurements.UITelemetry["metro-tabs"]["currTabCount"], 3); |
michael@0 | 54 | is(simpleMeasurements.UITelemetry["metro-tabs"]["maxTabCount"], 3); |
michael@0 | 55 | |
michael@0 | 56 | Browser.closeTab(tab2, { forceClose: true } ); |
michael@0 | 57 | simpleMeasurements = getTelemetryPayload().simpleMeasurements; |
michael@0 | 58 | is(simpleMeasurements.UITelemetry["metro-tabs"]["currTabCount"], 2); |
michael@0 | 59 | is(simpleMeasurements.UITelemetry["metro-tabs"]["maxTabCount"], 3); |
michael@0 | 60 | |
michael@0 | 61 | Browser.closeTab(tab3, { forceClose: true } ); |
michael@0 | 62 | simpleMeasurements = getTelemetryPayload().simpleMeasurements; |
michael@0 | 63 | is(simpleMeasurements.UITelemetry["metro-tabs"]["currTabCount"], 1); |
michael@0 | 64 | is(simpleMeasurements.UITelemetry["metro-tabs"]["maxTabCount"], 3); |
michael@0 | 65 | } |
michael@0 | 66 | }); |