Strange things happens with LL.runScript():
Strange things happens with LL.runScript():
Steps:
Make two scripts, set a custom script tag for both (“scriptA” and “scriptB” respectively, this won’t change)
The script A is:
LL.runScript(“script B”,””);
alert(LL.getScriptTag());
alert(LL.getScriptTag());
The script B is:
var flag = true//false
if(flag)alert(“dummy alert”);
If flag=false
There is shown two alerts with title ‘script A’ and content ‘scriptA’. All ok.
If flag=true
There is shown two alerts, the first with title ‘script A’ and content ‘scriptA’ … but the second with title ‘script B’ and content ‘script B’!!!
The rest of the script is executed as if it were the script B, even thought it is the script A. And what happened with the dummy alert?
Can you reproduce this?
]]>
< ![CDATA[
Reproducing is easy but a fix not. This is due to script execution interleaving, some context is shared.
I am thinking at either killing this runScript method as it cannot function properly, or fully change its semantic. Something like an include such as the one discussed previously with +gerd reuter may work better
]]>
< ![CDATA[
But, if you decide the include option, it will happen the opposite, I mean, the context will be the script A, so if the script B has the LL.getScriptTag() it will return the tag from the script A instead.
Well, I’m sure you will find the best way to do this.
]]>
< ![CDATA[
I think the one problem on runScript’s sharing context is scriptTag, am I wrong?
Then,
get/setScriptTag(‘scriptA’, ‘tag’) could solve it, although it doesnt look tidy. Specifiy a context explicitly. I couldnt find other APIs that can cause sharing context.
The other problem on runScript is to use blocking function like alert/prompt..
For example, in above scripts, if we use makeNewToast(nonblocking) not alert(blocking), we can see
scriptB’s dummy message.
I found the blocking functions(etc. alert) in a child thread(setTimeout/runScript…) didnt block the routines.
I don’t know exactly what I am saying 🙁 anyway hope it be a small help.
]]>