Bug 897697 - The start button in the profiler needs a label or at least a tooltip, r=anton
authorSrinath N <irtmail-bugzilla@yahoo.in>
Mon, 09 Sep 2013 00:05:45 +0300
changeset 146123 944426b6b680b85c66ad929d303cdc572e0b1c89
parent 146122 3fd62a46f15489c1b5d2870b3ba914bf8b6e995c
child 146124 86b5d8778fc4a5dc978351962c1ce8da096a01b3
push id25242
push useremorley@mozilla.com
push dateMon, 09 Sep 2013 12:13:52 +0000
treeherdermozilla-central@218d4334d29e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersanton
bugs897697
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 897697 - The start button in the profiler needs a label or at least a tooltip, r=anton
browser/devtools/profiler/profiler.xul
browser/devtools/profiler/sidebar.js
browser/devtools/profiler/test/browser_profiler_run.js
browser/locales/en-US/chrome/browser/devtools/profiler.dtd
browser/locales/en-US/chrome/browser/devtools/profiler.properties
--- a/browser/devtools/profiler/profiler.xul
+++ b/browser/devtools/profiler/profiler.xul
@@ -11,21 +11,23 @@
 <?xml-stylesheet href="chrome://browser/content/devtools/widgets.css"?>
 
 <!DOCTYPE window [
 <!ENTITY % profilerDTD SYSTEM "chrome://browser/locale/devtools/profiler.dtd">
   %profilerDTD;
 ]>
 
 <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <script type="text/javascript" src="sidebar.js"/>
   <box flex="1" id="profiler-chrome" class="devtools-responsive-container">
     <vbox class="profiler-sidebar">
       <toolbar class="devtools-toolbar">
         <hbox id="profiler-controls">
           <toolbarbutton id="profiler-start"
+            tooltiptext="&startProfiler.tooltip;"
             class="devtools-toolbarbutton"
             disabled="true"/>
           <toolbarbutton id="profiler-import"
             class="devtools-toolbarbutton"
             disabled="true"
             label="&importProfile.label;"/>
         </hbox>
       </toolbar>
--- a/browser/devtools/profiler/sidebar.js
+++ b/browser/devtools/profiler/sidebar.js
@@ -14,16 +14,19 @@ const {
   PROFILE_IDLE,
   PROFILE_COMPLETED,
   PROFILE_RUNNING,
   L10N_BUNDLE
 } = require("devtools/profiler/consts");
 
 loader.lazyGetter(this, "L10N", () => new ViewHelpers.L10N(L10N_BUNDLE));
 
+let stopProfilingString = L10N.getStr("profiler.stopProfilerString");
+let startProfilingString = L10N.getStr("profiler.startProfilerString");
+
 function Sidebar(el) {
   EventEmitter.decorate(this);
 
   this.document = el.ownerDocument;
   this.widget = new SideMenuWidget(el, { showArrows: true });
   this.widget.notice = L10N.getStr("profiler.sidebarNotice");
 
   this.widget.addEventListener("select", (ev) => {
@@ -88,30 +91,34 @@ Sidebar.prototype = Heritage.extend(Widg
   },
 
   getItemByProfile: function (profile) {
     return this.getItemByValue(profile.uid.toString());
   },
 
   setProfileState: function (profile, state) {
     let item = this.getItemByProfile(profile);
+    let doc = this.document;
     let label = item.target.querySelector(".profiler-sidebar-item > hbox > span");
+    let toggleButton = doc.getElementById("profiler-start");
 
     switch (state) {
       case PROFILE_IDLE:
         item.target.setAttribute("state", "idle");
         label.textContent = L10N.getStr("profiler.stateIdle");
         break;
       case PROFILE_RUNNING:
         item.target.setAttribute("state", "running");
         label.textContent = L10N.getStr("profiler.stateRunning");
+        toggleButton.setAttribute("tooltiptext",stopProfilingString);
         break;
       case PROFILE_COMPLETED:
         item.target.setAttribute("state", "completed");
         label.textContent = L10N.getStr("profiler.stateCompleted");
+        toggleButton.setAttribute("tooltiptext",startProfilingString);
         break;
       default: // Wrong state, do nothing.
         return;
     }
 
     item.attachment.state = state;
     this.emit("stateChanged", item);
   }
--- a/browser/devtools/profiler/test/browser_profiler_run.js
+++ b/browser/devtools/profiler/test/browser_profiler_run.js
@@ -35,33 +35,36 @@ function startRecording() {
   let record = gPanel.controls.record;
   ok(record, "Record button exists.");
   ok(!record.getAttribute("checked"), "Record button is unchecked");
 
   gPanel.once("started", () => {
     let item = gPanel.sidebar.getItemByProfile(gPanel.recordingProfile);
     is(item.attachment.name, "Profile 1");
     is(item.attachment.state, PROFILE_RUNNING);
+    is(record.getAttribute("tooltiptext"), "Stop profiling");
 
     gPanel.controller.isActive(function (err, isActive) {
       ok(isActive, "Profiler is running");
       deferred.resolve();
     });
   });
 
   record.click();
   return deferred.promise;
 }
 
 function stopRecording() {
   let deferred = promise.defer();
+  let record = gPanel.controls.record;
 
   gPanel.once("parsed", () => {
     let item = gPanel.sidebar.getItemByProfile(gPanel.activeProfile);
     is(item.attachment.state, PROFILE_COMPLETED);
+    is(record.getAttribute("tooltiptext"), "Start profiling");
 
     function assertSample() {
       let [ win, doc ] = getProfileInternals();
       let sample = doc.getElementsByClassName("samplePercentage");
 
       if (sample.length <= 0) {
         return void setTimeout(assertSample, 100);
       }
@@ -86,16 +89,17 @@ function startRecordingAgain() {
   ok(!record.getAttribute("checked"), "Record button is unchecked");
 
   gPanel.once("started", () => {
     ok(gPanel.activeProfile !== gPanel.recordingProfile);
 
     let item = gPanel.sidebar.getItemByProfile(gPanel.recordingProfile);
     is(item.attachment.name, "Profile 2");
     is(item.attachment.state, PROFILE_RUNNING);
+    is(record.getAttribute("tooltiptext"), "Stop profiling");
 
     deferred.resolve();
   });
 
   record.click();
   return deferred.promise;
 }
 
--- a/browser/locales/en-US/chrome/browser/devtools/profiler.dtd
+++ b/browser/locales/en-US/chrome/browser/devtools/profiler.dtd
@@ -7,9 +7,13 @@
 <!-- LOCALIZATION NOTE : FILE The correct localization of this file might be to
   - keep it in English, or another language commonly spoken among web developers.
   - You want to make that choice consistent across the developer tools.
   - A good criteria is the language in which you'd find the best
   - documentation on web development on the web. -->
 
 <!-- LOCALIZATION NOTE (profiler.importProfile): This string is displayed
   -  on a button that opens a dialog to import a saved profile data file. -->
-<!ENTITY importProfile.label "Import…">
\ No newline at end of file
+<!ENTITY importProfile.label "Import…">
+
+<!-- LOCALIZATION NOTE (profiler.startProfiler): This string is displayed
+  -  on a button that starts a new profile  -->
+<!ENTITY startProfiler.tooltip "Start profiling">
--- a/browser/locales/en-US/chrome/browser/devtools/profiler.properties
+++ b/browser/locales/en-US/chrome/browser/devtools/profiler.properties
@@ -84,20 +84,30 @@ profiler.stateRunning=Running
 profiler.stateCompleted=Completed
 
 # LOCALIZATION NOTE (profiler.sidebarNotice)
 # This string is displayed in the profiler sidebar when there are no
 # existing profiles to show (usually happens when the user opens the
 # profiler for the first time).
 profiler.sidebarNotice=There are no profiles yet.
 
+# LOCALIZATION NOTE (profiler.startProfilerString)
+# This string is displayed on the profiler button when no active
+# profiling sessions are running
+profiler.startProfilerString=Start profiling
+
+# LOCALIZATION NOTE (profiler.stopProfilerString)
+# This string is displayed on the profiler button when an active
+# profiling session is running
+profiler.stopProfilerString=Stop profiling
+
 # LOCALIZATION NOTE (profiler.save)
 # This string is displayed as a label for a button that opens a Save File
 # dialog where user can save generated profiler to a file.
 profiler.save=Save
 
 # LOCALIZATION NOTE (profiler.saveFileAs)
 # This string as a title for a Save File dialog.
 profiler.saveFileAs=Save Profile As
 
 # LOCALIZATION NOTE (profiler.openFile)
 # This string as a title for a Open File dialog.
-profiler.openFile=Import Profile
\ No newline at end of file
+profiler.openFile=Import Profile