application/javascript;version=1.8

View: New views
11 Messages — Rating Filter:   Alert me  

application/javascript;version=1.8

by John J Barton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On m.d.platform Boris suggests reposting here:

How can Firebug determine the language version used by a web page?

There seems to be no documentation of the mimetype for 'type' in script
tags on MDC:
https://developer.mozilla.org/En/HTML/Element/Script

The mime type "application/javascript" does not define version:
http://www.iana.org/assignments/media-types/application/
which points to:
http://www.rfc-editor.org/rfc/rfc4329.txt

jsdIScript has a very likely property:
http://www.oxymoronical.com/experiments/apidocs/interface/jsdIScript
--------
  Last version set on this context.
  Scripts typically select this with the "language" attribute.
  See the VERSION_* consts on jsdIDebuggerService.

readonly attribute long version
--------
except that the VERSION_* constants only go up to 1.5 and we are up to
at least 1.8 right?

If we go with heuristics we can read the version off each tag. Then the
likely outcomes include:
   No version info on any tag.
   One tag has version specified, rest not.
   Different versions on different tags.
   An eval() in a function with a version specified.

Reading between the lines of the comment above "Last version", I guess
the version is set by order of compilation.

Any other resources to augment my guesses?
jjb
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Re: application/javascript;version=1.8

by Nickolay Ponomarev :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Oct 14, 2009 at 8:21 AM, John J. Barton <johnjbarton@...
> wrote:

> jsdIScript has a very likely property:
> http://www.oxymoronical.com/experiments/apidocs/interface/jsdIScript
> --------
>  Last version set on this context.
>  Scripts typically select this with the "language" attribute.
>  See the VERSION_* consts on jsdIDebuggerService.
>
> readonly attribute long version
> --------
> except that the VERSION_* constants only go up to 1.5 and we are up to at
> least 1.8 right?
>

Which is filed as https://bugzilla.mozilla.org/show_bug.cgi?id=473055

I guess you could use the actual number constants until that bug is fixed.

Nickolay
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Re: application/javascript;version=1.8

by Alexandre Morgaut-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In Firefox, JavaScript version used depends on Firefox version and the
deprecated language attribute of script tags
If the test is also for firebug Lite, it should take care about other
user-agents like IE, Opera, ...

First, for culture you can look at :
 - use of script tag with version specification :
http://devedge-temp.mozilla.org/library/manuals/2000/javascript/1.3/guide/embed.html
 - interesting test: http://www.browsertests.org/tests/LayoutTests/fast/tokenizer/004.html/
 - example of how different version of JavaScript are used :
http://strivinglife.com/words/post/Browser-support-for-different-versions-of-JavaScript.aspx
 -

There is 2 ways of detecting the default version used :
 - detect the User-Agent version (Baaaad)
- use, as recommended by John Resig, capacity test

Example of capacity test

function javaScriptVersion () {
    try {
        // use a 1.1 available javascrip feature
    } catch (e) {
        return '1.0';
    }
    try {
        // use a 1.2 available javascrip feature
    } catch (e) {
        return '1.1';
    }
    /*
        (...)
        until last version
    */
}

For each script tag found in your HTML DOM (server & javascript
generated), create an a script tag with the same language and type
attribute values, and insert this code inside so you'll potentially be
able to know which JavaScript version is used

I said potentially because official versions are defined by Brendan
Eich from Mozilla and then respected in old Netscape and actual
Firefox User Agents (and some Mozilla browser). But any other
JavaScript engines can implement only partial features of each
versions making the realization of this script more difficult (in
finding the best features to test and eventually adding exeptions for
these browsers)

A Good example of this complexity is the list given by wikipedia of
browsers supporting the 1.5 version. IE is said supporting it in
versions 5.5 to 8 with JScript versions from 5.6 to 6
http://en.wikipedia.org/wiki/JavaScript#Versions
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Re: application/javascript;version=1.8

by Donny Viszneki :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Oct 14, 2009 at 5:29 AM, Alexandre Morgaut
<Alexandre.Morgaut@...> wrote:
> In Firefox, JavaScript version used depends on Firefox version and the
> deprecated language attribute of script tags

You can also use the type= attribute on Firefox, à la
type="text/javascript;version=whatever"

This works up to version 1.8 so far.

--
http://codebad.com/
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Re: application/javascript;version=1.8

by Donny Viszneki :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Oct 14, 2009 at 10:52 AM, Donny Viszneki
<donny.viszneki@...> wrote:
> You can also use the type= attribute on Firefox, à la
> type="text/javascript;version=whatever"

Which is obviously what the thread is named after. Didn't notice that
as it wasn't mentioned anywhere else in OP! Sorry!

--
http://codebad.com/
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Re: application/javascript;version=1.8

by Wes Garland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Right, John is looking for a way to let firebug detect what version of JS
the interpreter is using.

On Wed, Oct 14, 2009 at 10:53 AM, Donny Viszneki
<donny.viszneki@...>wrote:

> On Wed, Oct 14, 2009 at 10:52 AM, Donny Viszneki
> <donny.viszneki@...> wrote:
> > You can also use the type= attribute on Firefox, à la
> > type="text/javascript;version=whatever"
>
> Which is obviously what the thread is named after. Didn't notice that
> as it wasn't mentioned anywhere else in OP! Sorry!
>
> --
> http://codebad.com/
> _______________________________________________
> dev-tech-js-engine mailing list
> dev-tech-js-engine@...
> https://lists.mozilla.org/listinfo/dev-tech-js-engine
>



--
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Parent Message unknown Re: application/javascript;version=1.8

by Alexandre Morgaut-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 14 oct, 16:59, Wes Garland <w...@...> wrote:
> Right, John is looking for a way to let firebug detect what version of JS
> the interpreter is using.
>

The way I just gave should work either for firebug & firebug lite with
most browsers ;-)
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Parent Message unknown Re: application/javascript;version=1.8

by John J Barton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Wes Garland wrote:
> Right, John is looking for a way to let firebug detect what version of JS
> the interpreter is using.

Yes, though to be clear I need to know the rules for version selection.
Firebug injects script tags and evaluates command line expressions in
web pages. Do we need to adapt our script tag to the page? Do we need to
adjust the environment of the evaluation?  Some idea of the rules for
mixed version tags would help.

jjb
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Re: application/javascript;version=1.8

by Alexandre Morgaut-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok, looking more attentively to this problem, several things comes up:
 - specifying a version number of JavaScript in the "language"
attribute doesn't ask the browser to run it with a specific version
subset and behavior but to execute it only if this version is at least
supported
    -> <script language="javascript1.6">alert('foo');</script> will be
only executed by Browsers supporting at least the 1.6 version, but
with 1.x version supported by its engine (ex: 1.7)
         The browsers doesn't allow to switch from engine version to
another, but it might switch from a strict engine to a quirk one
- the try catch solution will only work from version 1.5 of JavaScript

So a simple code like this one

<script language="JavaScript">firebug = firebug || {};
firebug.JSversion = 1.0; </script>
<script language="JavaScript1.1">  firebug.JSversion = 1.1; </script>
<script language="JavaScript1.2">  firebug.JSversion = 1.2; </script>
<script language="JavaScript1.3">  firebug.JSversion = 1.3; </script>
<script language="JavaScript1.4">  firebug.JSversion = 1.4; </script>
<script language="JavaScript1.5">  firebug.JSversion = 1.5; </script>
<script language="JavaScript1.6">  firebug.JSversion = 1.6; </script>
<script language="JavaScript1.7">  firebug.JSversion = 1.7; </script>
<script language="JavaScript1.8">  firebug.JSversion = 1.8; </script>
<script language="JavaScript1.9">  firebug.JSversion = 1.9; </script>
<script language="JavaScript2.0">  firebug.JSversion = 2.0; </script>

Should be ok to know which JavaScript version is used in Firefox and
next to able to determine which script tags will be executed

Example:

firebug.scriptTags = document.getElementsByTagName('script');
Array.prototype.foreach.call(
    firebug.scriptTags,
    function (element, index, array) {
        var value = element.language && element.language.value;
        element.executed = (value && value.toLowerCase().indexOf
('javascript') === 0 && Number(value.substr(10)) >= firebug.JSversion)
|| true;
    }
);

// it can be extended to support version specification in the type
attribute
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Re: application/javascript;version=1.8

by Mike Shaver :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Oct 15, 2009 at 10:06 AM, Alexandre Morgaut
<Alexandre.Morgaut@...> wrote:
> Ok, looking more attentively to this problem, several things comes up:
>  - specifying a version number of JavaScript in the "language"
> attribute doesn't ask the browser to run it with a specific version
> subset and behavior but to execute it only if this version is at least
> supported
>    -> <script language="javascript1.6">alert('foo');</script> will be
> only executed by Browsers supporting at least the 1.6 version, but
> with 1.x version supported by its engine (ex: 1.7)

That is not true, or has not been historically.  Try using yield in a
javascript1.5 script, for example.

Mike
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine

Parent Message unknown Re: application/javascript;version=1.8

by Alexandre Morgaut-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> >    -> <script language="javascript1.6">alert('foo');</script> will be
> > only executed by Browsers supporting at least the 1.6 version, but
> > with 1.x version supported by its engine (ex: 1.7)
>
> That is not true, or has not been historically.  Try using yield in a
> javascript1.5 script, for example.

Well, you're probably right as the language attribute is now
deprecated, it may be ignored.
I should have used the example for an older version

So, I don't know of is handled the version parameter in the type
attribute for the moment...
_______________________________________________
dev-tech-js-engine mailing list
dev-tech-js-engine@...
https://lists.mozilla.org/listinfo/dev-tech-js-engine