[webkit-dev] Javascript and WebCore
Alexander Cohen
naftaly at me.com
Sun Oct 25 16:30:47 PDT 2009
On Oct 25, 2009, at 7:09 PM, Maciej Stachowiak wrote:
>
> On Oct 25, 2009, at 2:36 PM, Alexander Cohen wrote:
>
>>
>> On Oct 25, 2009, at 5:23 PM, Maciej Stachowiak wrote:
>>
>>>
>>> On Oct 25, 2009, at 2:01 PM, Alexander Cohen wrote:
>>>
>>>>
>>>> In the events of a tag, i needed to add checks to see what type
>>>> of script was being called. A lot if not all of the time, we will
>>>> usually find a "javascript:" in the event code so i can also look
>>>> there for my defined scripting language and call into the right
>>>> code.
>>>
>>> Attribute event listeners do not usually have "javascript:" in
>>> them. Here is an example from Google's home page:
>>> <a href="http://images.google.com/imghp?hl=en&tab=wi"
>>> onclick=gbar.qs(this) class=gb1>Images</a>
>>> Notice that the onclick value doesn't start with javascript:. You
>>> are probably thinking of javascript: URLs in links, like this:
>>>
>>> <a href="javascript:callSomething()">
>>>
>>> You could invent a new URL scheme that runs your scripting
>>> language instead of JavaScript, but I don't think there is
>>> anything you can do about onclick handlers, unless you're willing
>>> to break compatibility with existing Web content.
>>
>> You're right. But this does give an opportunity for my scripting
>> language to get through since executing mine as javascript will
>> probably result in an error. I can definitely catch that and check
>> for another language.
>
> I think that would be fragile, especially if polyglot or near-
> polyglot programs are possible. Unfortunately, inline event
> listeners were never designed with the idea of multiple scripting
> languages in mind. Fortunately, you can add event listeners just
> fine using code in a <script> element, so you don't lose much by not
> supporting them for a new scripting language.
Agreed that it could be fragile. Fortunately, at least for the time
being, i'm just working on a proof of concept and it does make the
transition easier from javascript to another scripting language. I'm
also learning a lot about WebCore this way which is really nice but
not relevant to our current discussion. :)
>
>> Just by curiosity, would it be bad to do something like this
>> (notice the "newscriptinglang:" in the onload ):
>>
>> <a href="http://images.google.com/imghp?hl=en&tab=wi"
>> onclick=newscriptinglang:gbar.qs(this) class=gb1>Images</a
>
> That onclick handler is a valid JavaScript program,
> "newscriptlanglang:" is interpreted as a goto label. Whether there
> is Web content out there accidentally doing that, I don't know.
So i would actually need to look at the event handler code scheme
before it gets directly passed on to javascript. I could check for my
scripting language scheme and handle it if needed. I do how see this
could be a problem if a developer had a goto statement that was the
same as the name of my scripting language, but the possibility of that
is very low, for now.
thx
AC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20091025/a63510e6/attachment.html>
More information about the webkit-dev
mailing list