Closed Bug 1605327 Opened 4 years ago Closed 4 years ago

Deprecate cd() command


(DevTools :: Console, enhancement, P1)



(Fission Milestone:Future, firefox74 fixed)

Firefox 74
Fission Milestone Future
Tracking Status
firefox74 --- fixed


(Reporter: Honza, Assigned: nchevobbe)


(Blocks 1 open bug)


(Whiteboard: dt-fission-m2-mvp)


(2 files)

We have the Context Selector UI now so, we might deprecate and remove this command.

Implementing cd() that would cross origin boundary does not seem feasible. I.e. we can't support "cd(foo); log(window);" universally. I.e. cd is more of a UI switch rather than a console command.

See more:


Fission Milestone: --- → Future

Honza, were you thinking of having a warning message before deprecating the command?
If so, should we I guess it should point to this bug?

Flags: needinfo?(odvarko)

Jumping in for Honza, but would love to hear his thoughts as well: A console warning when executing the command would be nice, but just with minimal effort as we don't have any indication that this is widely used and because context switching UI will serve most use cases that cd() covered.

Agreed, let's start with a warning (pointing to this bug report) and perhaps also collect some feedback related to this decision.


Flags: needinfo?(odvarko)
Attached image image.png

we can have something very easily.
the patch is quite small:

diff --git a/devtools/server/actors/webconsole/utils.js b/devtools/server/actors/webconsole/utils.js
--- a/devtools/server/actors/webconsole/utils.js
+++ b/devtools/server/actors/webconsole/utils.js
@@ -4,7 +4,7 @@
 "use strict";
-const { Ci, Cu } = require("chrome");
+const { Ci, Cu, Cc } = require("chrome");
 // Note that this is only used in WebConsoleCommands, see $0, screenshot and pprint().
 if (!isWorker) {
@@ -557,6 +557,22 @@ WebConsoleCommands._registerOriginal("he
  *        eval scope is cleared back to its default (the top window).
 WebConsoleCommands._registerOriginal("cd", function(owner, window) {
+  // Log a deprecation warning.
+  const scriptErrorClass = Cc[";1"];
+  const scriptError = scriptErrorClass.createInstance(Ci.nsIScriptError);
+  scriptError.initWithWindowID(
+    "The `cd` command will be deprecated in future version of Firefox. See for more information",
+    null,
+    null,
+    0,
+    0,
+    1,
+    "content javascript",
+    owner.window.windowUtils.currentInnerWindowID
+  );
+  const Services = require("Services");
+  Services.console.logMessage(scriptError);
   if (!window) {
     owner.consoleActor.evalWindow = null;
     owner.helperResult = { type: "cd" };

we might want to localize the message (or not), but this shouldn't be too hard.

great, I'll clean this up and push the patch

Assignee: nobody → nchevobbe
Priority: P2 → P1
Blocks: 1607741

This is a simple patch that logs a message in the console
when the cd command is called.
The localized string is added into the
file because there's no file dedicated to the console that
can be loaded from the server, and the message will only be
here for a cycle before being removed, so it's not really
worth it adding a new file.

LGTM. Localization is probably not needed.

Pushed by
Add a deprecation warning when the cd command is called. r=Honza.
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 74
You need to log in before you can comment on or make changes to this bug.