I am making a firefox component using javascript.
But i am always confused about what is the global scope of the current javascript function, which results in the following questions?
I understand some basic concept about global scope of js function in normal case, but i want to know, when is the global scope of a function determined? The time when function is created(defined), or the time when the function is called?
Is there a way to show(print some information) the current global scope of a javascript function?
following question is firefox component specific
For firefox component, does each component have a global scope itself? (which means each function of the component will be run in itself global scope ), or every components have the same global scope?
If same, what's that?For example, in such case
sorry for this boring example, i just make it as clear as possible.
I make a sandbox viaComponents.utils.Sandbox(<scope1>)
. I define some function in a ff component( i called<scope2>
) ,and inject a variable in to sandbox by :sandbox.external = this;
( "this" is just a component itself, which in a scope2 )
After these step, i run some code in sandbox byComponents.utils.evalInSandbox( <code> , sandbox);
, and<code>
contains afunction sandboxFoo()
that callexternal.foo()
1). what's the global scope of
sandboxFoo
when it is running? I think it should be2). what's the global scope of
external.foo
when it is called bysandboxFoo
? Is it the<scope1>
or<scope2>
? Any documentation?