Bug 1028004 - UI Telemetry events with null methods are ignored r=rnewman
authorMark Finkle <mfinkle@mozilla.com>
Fri, 20 Jun 2014 13:39:33 -0400
changeset 211736 776f6d341b3f013672a861a4ee0283c120e3e46f
parent 211735 b0b5ad421d671bc30eda3f28d091681578994db2
child 211737 aa40e443767e0a3aac13e090f4a79c47fefea13c
child 211739 ffaf206fd0189e6c88ec4b773996b4e64448f7f8
child 211811 6da364bc0e3ec25e0783c25f6f186ba572cb6cf4
child 211948 9065e88e2b1007872bdabc5216b1ef5b8d5fa576
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman
bugs1028004
milestone33.0a1
first release with
nightly linux32
776f6d341b3f / 33.0a1 / 20140621030204 / files
nightly linux64
776f6d341b3f / 33.0a1 / 20140621030204 / files
nightly mac
776f6d341b3f / 33.0a1 / 20140621030204 / files
nightly win32
776f6d341b3f / 33.0a1 / 20140621030204 / files
nightly win64
776f6d341b3f / 33.0a1 / 20140621030204 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1028004 - UI Telemetry events with null methods are ignored r=rnewman
mobile/android/base/tests/testUITelemetry.java
mobile/android/base/tests/testUITelemetry.js
widget/android/nsAppShell.cpp
--- 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
@@ -416,17 +416,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(