Bug 1036449 - Introduce a noreload flag for csscoverage start. r=harth
authorJoe Walker <jwalker@mozilla.com>
Fri, 11 Jul 2014 07:57:00 -0400
changeset 215697 33f1bc57b49c65d4393e9852f03647da8fc28b01
parent 215696 38bcfb3960c3296de7a0418299365389c82d58c1
child 215698 8673477f5fc29ced4fcd486e844796cd1ca7d42a
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)
reviewersharth
bugs1036449
milestone33.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 1036449 - Introduce a noreload flag for csscoverage start. r=harth
toolkit/devtools/gcli/commands/csscoverage.js
toolkit/devtools/server/actors/csscoverage.js
toolkit/locales/en-US/chrome/global/devtools/csscoverage.properties
--- a/toolkit/devtools/gcli/commands/csscoverage.js
+++ b/toolkit/devtools/gcli/commands/csscoverage.js
@@ -25,23 +25,31 @@ exports.items = [
     name: "csscoverage",
     hidden: true,
     description: l10n.lookup("csscoverageDesc"),
   },
   {
     name: "csscoverage start",
     hidden: true,
     description: l10n.lookup("csscoverageStartDesc2"),
+    params: [
+      {
+        name: "noreload",
+        type: "boolean",
+        description: l10n.lookup("csscoverageStartNoReloadDesc"),
+        manual: l10n.lookup("csscoverageStartNoReloadManual")
+      }
+    ],
     exec: function*(args, context) {
       let usage = yield csscoverage.getUsage(context.environment.target);
       if (usage == null) {
         throw new Error(l10n.lookup("csscoverageNoRemoteError"));
       }
       yield usage.start(context.environment.chromeWindow,
-                        context.environment.target);
+                        context.environment.target, args.noreload);
     }
   },
   {
     name: "csscoverage stop",
     hidden: true,
     description: l10n.lookup("csscoverageStopDesc2"),
     exec: function*(args, context) {
       let target = context.environment.target;
--- a/toolkit/devtools/server/actors/csscoverage.js
+++ b/toolkit/devtools/server/actors/csscoverage.js
@@ -103,18 +103,22 @@ let CSSUsageActor = protocol.ActorClass(
     delete this._onTabLoad;
     delete this._onChange;
 
     protocol.Actor.prototype.destroy.call(this);
   },
 
   /**
    * Begin recording usage data
+   * @param noreload It's best if we start by reloading the current page
+   * because that starts the test at a known point, but there could be reasons
+   * why we don't want to do that (e.g. the page contains state that will be
+   * lost across a reload)
    */
-  start: method(function() {
+  start: method(function(noreload) {
     if (this._running) {
       throw new Error(l10n.lookup("csscoverageRunningError"));
     }
 
     this._isOneShot = false;
     this._visitedPages = new Set();
     this._knownRules = new Map();
     this._running = true;
@@ -139,20 +143,28 @@ let CSSUsageActor = protocol.ActorClass(
       onStatusChange: () => {},
       destroy: () => {}
     };
 
     this._progress = this._tabActor.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
                                             .getInterface(Ci.nsIWebProgress);
     this._progress.addProgressListener(this._progressListener, this._notifyOn);
 
-    this._populateKnownRules(this._tabActor.window.document);
-    this._updateUsage(this._tabActor.window.document, false);
+    if (noreload) {
+      // If we're not starting by reloading the page, then pretend that onload
+      // has just happened.
+      this._onTabLoad(this._tabActor.window.document);
+    }
+    else {
+      this._tabActor.window.location.reload();
+    }
 
     events.emit(this, "state-change", { isRunning: true });
+  }, {
+    request: { url: Arg(0, "boolean") }
   }),
 
   /**
    * Cease recording usage data
    */
   stop: method(function() {
     if (!this._running) {
       throw new Error(l10n.lookup("csscoverageNotRunningError"));
@@ -778,21 +790,21 @@ const CSSUsageFront = protocol.FrontClas
       gDevTools.showToolbox(target, "styleeditor");
       target = undefined;
     }
   }),
 
   /**
    * Server-side start is above. Client-side start adds a notification box
    */
-  start: custom(function(newChromeWindow, newTarget) {
+  start: custom(function(newChromeWindow, newTarget, noreload=false) {
     target = newTarget;
     chromeWindow = newChromeWindow;
 
-    return this._start();
+    return this._start(noreload);
   }, {
     impl: "_start"
   }),
 
   /**
    * Server-side start is above. Client-side start adds a notification box
    */
   toggle: custom(function(newChromeWindow, newTarget) {
--- a/toolkit/locales/en-US/chrome/global/devtools/csscoverage.properties
+++ b/toolkit/locales/en-US/chrome/global/devtools/csscoverage.properties
@@ -9,16 +9,18 @@
 # csscoverageStopDesc2, csscoverageOneShotDesc2, csscoverageToggleDesc2,
 # csscoverageReportDesc2): Short descriptions of the csscoverage commands
 csscoverageDesc=Control CSS coverage analysis
 csscoverageStartDesc2=Begin collecting CSS coverage data
 csscoverageStopDesc2=Stop collecting CSS coverage data
 csscoverageOneShotDesc2=Collect instantaneous CSS coverage data
 csscoverageToggleDesc2=Toggle collecting CSS coverage data
 csscoverageReportDesc2=Show CSS coverage report
+csscoverageStartNoReloadDesc=Don't start with a page reload
+csscoverageStartNoReloadManual=It's best if we start by reloading the current page because that starts the test at a known point, but there could be reasons why we don't want to do that (e.g. the page contains state that will be lost across a reload)
 
 # LOCALIZATION NOTE (csscoverageRunningReply, csscoverageDoneReply): Text that
 # describes the current state of the css coverage system
 csscoverageRunningReply=Running CSS coverage analysis
 csscoverageDoneReply=CSS Coverage analysis completed
 
 # LOCALIZATION NOTE (csscoverageRunningError, csscoverageNotRunningError,
 # csscoverageNotRunError): Error message that describe things that can go wrong