Bug 1028004 - UI Telemetry events with null methods are ignored. r=rnewman, a=lmandel
--- a/mobile/android/base/tests/testUITelemetry.java
+++ b/mobile/android/base/tests/testUITelemetry.java
@@ -38,17 +38,18 @@ public class testUITelemetry extends Jav
Telemetry.sendUIEvent(Event._TEST3, Method._TEST1, "foobarextras");
Telemetry.stopUISession(Session._TEST_STARTED_TWICE, Reason._TEST1);
Telemetry.sendUIEvent(Event._TEST4, Method._TEST1, "barextras");
Telemetry.stopUISession(Session._TEST_STOPPED_TWICE, Reason._TEST2);
// This session is already stopped, so this call should be ignored.
Telemetry.stopUISession(Session._TEST_STOPPED_TWICE, Reason._TEST_IGNORED);
- Telemetry.sendUIEvent(Event._TEST1, Method._TEST1);
+ // Method defaults to Method.NONE
+ Telemetry.sendUIEvent(Event._TEST1);
} catch (Exception e) {
Log.e("GeckoTest", "Oops.", e);
}
Log.i("GeckoTest", "Running remaining JS test code.");
super.testJavascript();
}
}
--- a/mobile/android/base/tests/testUITelemetry.js
+++ b/mobile/android/base/tests/testUITelemetry.js
@@ -12,16 +12,19 @@ Cu.import("resource://gre/modules/Servic
const EVENT_TEST1 = "_test_event_1.1";
const EVENT_TEST2 = "_test_event_2.1";
const EVENT_TEST3 = "_test_event_3.1";
const EVENT_TEST4 = "_test_event_4.1";
const METHOD_TEST1 = "_test_method_1";
const METHOD_TEST2 = "_test_method_2";
+// Method.NONE is converted to an empty string after a few JSON stringifications
+const METHOD_NONE = "";
+
const REASON_TEST1 = "_test_reason_1";
const REASON_TEST2 = "_test_reason_2";
const SESSION_STARTED_TWICE = "_test_session_started_twice.1";
const SESSION_STOPPED_TWICE = "_test_session_stopped_twice.1";
function do_check_array_eq(a1, a2) {
do_check_eq(a1.length, a2.length);
@@ -78,31 +81,35 @@ add_test(function test_telemetry_events(
let expected = expectedArraysToObjs([
["event", EVENT_TEST1, METHOD_TEST1, [], undefined],
["event", EVENT_TEST2, METHOD_TEST1, [SESSION_STARTED_TWICE], undefined],
["event", EVENT_TEST2, METHOD_TEST2, [SESSION_STARTED_TWICE], undefined],
["event", EVENT_TEST3, METHOD_TEST1, [SESSION_STARTED_TWICE, SESSION_STOPPED_TWICE], "foobarextras"],
["session", SESSION_STARTED_TWICE, REASON_TEST1],
["event", EVENT_TEST4, METHOD_TEST1, [SESSION_STOPPED_TWICE], "barextras"],
["session", SESSION_STOPPED_TWICE, REASON_TEST2],
- ["event", EVENT_TEST1, METHOD_TEST1, [], undefined],
+ ["event", EVENT_TEST1, METHOD_NONE, [], undefined],
]);
let obs = getObserver();
let measurements = removeNonTestMeasurements(obs.getUIMeasurements());
measurements.forEach(function (m, i) {
if (m.type === "event") {
m.sessions = removeNonTestSessions(m.sessions);
m.sessions.sort(); // Mutates.
}
do_check_measurement_eq(expected[i], m);
});
+ expected.forEach(function (m, i) {
+ do_check_measurement_eq(m, measurements[i]);
+ });
+
run_next_test();
});
/**
* Converts the expected value arrays to objects,
* for less typing when initializing the expected arrays.
*/
function expectedArraysToObjs(expectedArrays) {
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -417,17 +417,17 @@ nsAppShell::ProcessNextNativeEvent(bool
obs->StartSession(
nsString(curEvent->Characters()).get(),
curEvent->Time()
);
break;
}
case AndroidGeckoEvent::TELEMETRY_UI_EVENT: {
- if (curEvent->Characters().Length() == 0)
+ if (curEvent->Data().Length() == 0)
break;
nsCOMPtr<nsIUITelemetryObserver> obs;
mBrowserApp->GetUITelemetryObserver(getter_AddRefs(obs));
if (!obs)
break;
obs->AddEvent(