How access to the command line in the console panel from my extension?

200 views
Skip to first unread message

Ebrahim

unread,
Jul 12, 2013, 7:46:48 AM7/12/13
to fir...@googlegroups.com
Hi everybody,

Could you please help me how can I access to the command line in the console panel from my extension? 

I want to programmatically copy a script within my extension in the command line, run it, when is done, clear the editor. 

Thanks for any help,

Ebrahim

Jan Honza Odvarko

unread,
Jul 12, 2013, 8:10:07 AM7/12/13
to fir...@googlegroups.com

Ebrahim

unread,
Jul 12, 2013, 9:40:24 AM7/12/13
to fir...@googlegroups.com
Thanks Honza for your reply.

I am not sure I am right, but I use the following code to set value in the editor. 
-----------------------------------------------------------------------

context.commandLineText = "MY_SCRIPT_COMES_HERE";

-----------------------------------------------------------------------



My another question is that how can I trigger the "Run" button from my extension? 

Thanks again, 

Ebrahim

Jan Honza Odvarko

unread,
Jul 12, 2013, 10:36:51 AM7/12/13
to fir...@googlegroups.com


On Friday, July 12, 2013 3:40:24 PM UTC+2, Ebrahim wrote:
Thanks Honza for your reply.

I am not sure I am right, but I use the following code to set value in the editor. 
-----------------------------------------------------------------------

context.commandLineText = "MY_SCRIPT_COMES_HERE";

-----------------------------------------------------------------------
I don't think this would work correctly .

Take yet a look at our automated test framework here:
typeCommand:
https://github.com/firebug/firebug/blob/master/tests/FBTest/content/FBTestFirebug.js#L1313
 

My another question is that how can I trigger the "Run" button from my extension? 

Again you can see our test harness here, executeCommand:
Honza

Ebrahim

unread,
Jul 12, 2013, 11:55:58 AM7/12/13
to fir...@googlegroups.com
Thank you very much Honza, your resources really helped me. I fixed the problem. 

Ebrahim

Simon Lindholm

unread,
Jul 12, 2013, 3:16:19 PM7/12/13
to fir...@googlegroups.com
Rather than emulate UI actions, you might also be able to use eval or CommandLine.evaluate (the latter if you need support for command line API, evaluating code in debugger frames, etc., but it's a more complex API).

Ebrahim

unread,
Jul 13, 2013, 12:41:54 PM7/13/13
to fir...@googlegroups.com
It would be nice if I can use these functions. I tried this function:

Firebug.Debugger.evaluate(expr, context, scope); //  thisValue : null

but does not work for me. I also could not find the eval function. 

Ebrahim

Simon Lindholm

unread,
Jul 13, 2013, 4:08:34 PM7/13/13
to fir...@googlegroups.com
What error is thrown? Are you sure you want to use Firebug.Debugger.evaluate? It should only work when stopped in the debugger, I believe. As a proof-of-concept with CommandLine.evaluate, you can evaluate the following in a chrome-scope scratchpad, with Firebug open:

        Firebug.CommandLine.evaluate("1+1", Firebug.currentContext, null, null, function(res) { alert("result: " + res); }, function failure() { /* won't happen */ });

(obviously, in real code, "1+1" and Firebug.currentContext would be more generic, the second null parameter might be a specific window).

With eval I mean the window.eval function built into the JavaScript language - try e.g. content.eval("1+1") in a scratchpad.

Ebrahim

unread,
Jul 15, 2013, 9:04:56 AM7/15/13
to fir...@googlegroups.com
Thanks Simon. I tried this function for some scripts and it works as I need. In my case, the expression to be evaluated is a bit complicated (scripts for user simulation purposes), but I expect no problem. 

Thanks again,
Ebrahim 

liuping

unread,
Jul 29, 2013, 4:19:40 AM7/29/13
to fir...@googlegroups.com
it's also useful for my question, thank you! but i'm not clear about the Firebug.currentContext, can you help me?

在 2013年7月14日星期日UTC+8上午4时08分34秒,Simon Lindholm写道:

Sebastian Zartner

unread,
Jul 31, 2013, 2:54:50 AM7/31/13
to fir...@googlegroups.com
Firebug.currentContext represents the data shared within Firebug. It is the context Firebug is running in.

Sebastian

Ebrahim

unread,
Aug 16, 2013, 11:43:14 AM8/16/13
to fir...@googlegroups.com
I have noticed something strange. I use the following command to simulate click event of a radio button in my Firebug extension:

targetClickableElement.setAttribute('data-id','1'); //targetClickableElement is a radio button element


var str =  "var element = jQuery('[data-id=1]',document).get(0);"+"\n";

str = str + "jQuery(element).trigger('click');";

Firebug.CommandLine.evaluate(str, Firebug.currentContext, null, null, function(res) {}, function failure() { /* won't happen */ });


It works for some Websites (e.g., http://www.dressbydesign.com/dress/design) but not for all (e.g., http://www.mydogtag.com/#). 


Ebrahim


Simon Lindholm

unread,
Aug 16, 2013, 1:57:34 PM8/16/13
to Firebug Groups
Obvious guess: the second page doesn't have jQuery.


2013/8/16 Ebrahim <ebrahim.kh...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "Firebug" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebug/DDCxlrXsC-c/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebug+u...@googlegroups.com.
To post to this group, send email to fir...@googlegroups.com.
Visit this group at http://groups.google.com/group/firebug.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebug/62edb571-f9c5-43a8-b7f0-e2fd8a223729%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages