Closed Bug 1129155 Opened 9 years ago Closed 9 years ago

Add system for opening a new tab from the console

Categories

(DevTools :: Console, defect)

defect
Not set
normal

Tracking

(firefox37 fixed, firefox38 fixed)

RESOLVED FIXED
Firefox 38
Tracking Status
firefox37 --- fixed
firefox38 --- fixed

People

(Reporter: jwalker, Assigned: bgrins)

Details

Attachments

(1 file, 2 obsolete files)

      No description provided.
Attached patch new-console-method.patch (obsolete) — Splinter Review
Boris, we want to add a simple new console method that just logs out a string as an easter egg.  Here is a patch that adds this method in the same manner I've seen for other ones.

Do you know of a way to make it non-enumerable and/or do you have any ideas about how to define a method on the console object that basically just calls console.log("Some string") regardless of any arguments that were passed in?  For example, is there somewhere in JS that we could run something like this:

Object.defineProperty(console, 'foo', {
  value: function() { console.log('bar'); }
});
Attachment #8559443 - Flags: review?(bzbarsky)
> Do you know of a way to make it non-enumerable

Not right now, but we could add something like this to our bindings.  I've been considering doing that anyway.

> For example, is there somewhere in JS that we could run something like this:

You could do it on window creation, but that has some undesirable performance implications, right?  Or we could add some notification the console sends when it's created.  Do you want this method in workers too?

I'm having a bit of trouble reconciling the summary of this bug and comment 1, and hence evaluating how much complexity we should take on here and which sort.
Comment on attachment 8559443 [details] [diff] [review]
new-console-method.patch

This is fine as far as it goes, except I doubt we're planning to actually ship it with this name, yes?  ;)
Attachment #8559443 - Flags: review?(bzbarsky) → review+
(In reply to Boris Zbarsky [:bz] from comment #2)
> > Do you know of a way to make it non-enumerable
> 
> Not right now, but we could add something like this to our bindings.  I've
> been considering doing that anyway.
> 
> > For example, is there somewhere in JS that we could run something like this:
> 
> You could do it on window creation, but that has some undesirable
> performance implications, right?  Or we could add some notification the
> console sends when it's created.  Do you want this method in workers too?
> 
> I'm having a bit of trouble reconciling the summary of this bug and comment
> 1, and hence evaluating how much complexity we should take on here and which
> sort.

We don't need it in workers. In fact, we only need it if the command was run from the webconsole input prompt.  We shouldn't take on any extra complexity for this bug.  It's really just going to be an easter egg, printing out a string whenever someone types the command.

In fact, when going over your review comments I realized that there is a way we can handle these requirements without any platform changes by just matching the input string in the evalWithDebugger[0] function in JS similar to how we detect the "help" command.

[0]: https://dxr.mozilla.org/mozilla-central/source/toolkit/devtools/server/actors/webconsole.js#1064
OK.  Or you could define something on the Console object when the console is opened.
Attached patch console-mihai.patch (obsolete) — Splinter Review
New approach as explained in Comment 4
Assignee: nobody → bgrinstead
Attachment #8559443 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #8562227 - Flags: review?(past)
Comment on attachment 8562227 [details] [diff] [review]
console-mihai.patch

Review of attachment 8562227 [details] [diff] [review]:
-----------------------------------------------------------------

::: toolkit/devtools/server/actors/webconsole.js
@@ +1065,5 @@
>        aString = "help()";
>      }
>  
> +    // Add easter egg for console.mihai().
> +    if (aString.trim() == "console.mihai()" || aString.trim() == "console.mihai();") {

Nit: we now have to needlessly trim the string 4 times in the common case, which seems excessive. I think it would be better to calculate a trimmedString once and later use it in these 4 checks instead.
Attachment #8562227 - Flags: review?(past) → review+
Updated for comment 7
Attachment #8562227 - Attachment is obsolete: true
Attachment #8562858 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/fdcb26aac28c
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 38
Comment on attachment 8562858 [details] [diff] [review]
console-mihai.patch

Approval Request Comment
[Feature/regressing bug #]: console.mihai method
[User impact if declined]: new method will not be available in Dev Edition
[Describe test coverage new/current, TreeHerder]:
[Risks and why]: Super low risk, just modifies the webconsole frontend to change the output when a particular string was passed in
[String/UUID change made/needed]:
Attachment #8562858 - Flags: approval-mozilla-aurora?
Attachment #8562858 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: