JavaScript: Same Code, and a Standardized Test Suite


Being all in with HTML5 means being committed to enabling developers to use the Same Markup on the Web, and that includes the same JavaScript code.

The Chakra JavaScript engine in the latest Platform Preview release of Internet Explorer 9 includes significantly improved support for the ECMAScript (ECMA-262) standard, including features new to the recently finalized ECMAScript Fifth Edition (often called ES5 for short). This also includes complete support for JavaScript tests in Bucket 6 of the Acid3 test suite. Microsoft has been a key contributor to the ES5 effort. During the drafting of ES5, Microsoft was the first to provide a private reference implementation of the specification along with conformance tests to the ECMA Technical Committee 39 (TC-39).

Having the same markup work correctly across the web requires comprehensive tests that all browsers can rely on to deliver interoperable implementations. Microsoft has worked with the W3C to provide definitive test suite specifications for HTML, CSS, SVG, and other web standards. In recent months, we’ve contributed nearly 200 new tests to the W3C for these standards.

Unlike specifications governed by W3C, JavaScript does not have a definitive test suite owned and sponsored by ECMA. In the absence of such a suite, browser vendors and others have tried to fill the gap. We have published a suite of tests for new features in ECMAScript 5 through Codeplex, and will soon publish them on the Internet Explorer Testing Center. Other browser vendors have their own test suites. While all these tests are useful, they also have inconsistencies: different coverage of standards, different test harnesses, and implementation issues. Many in the industry have questioned whether we should have a more consistent way to test ECMAScript by working together.

That’s why Microsoft is now working with other browser vendors and other members of TC-39 to create an official test suite for ECMAScript sponsored by ECMA. We plan to help build this test suite, and contribute tests to it. We also welcome other browser vendors’ contributions to this effort.

Ensuring the same script works everywhere is vital to web developers. We look forward to hearing your feedback as we can continue to work on making this a reality.

Thanks,

Shanku Niyogi
General Manager, JavaScript Team

Comments (20)

  1. Matt says:

    I'd like to be a fly on the wall in a room with Microsoft, Google, and Apple "working together."

  2. blah says:

    I still can't believe Microsoft calls their engine "Chakra" with a straight face.

  3. blah says:

    This blog post has three tags. Clearly, the first tag needs to be quadriplicated.

  4. Randall says:

    Unlike other browsers, I know some versions of IE won't accept trailing commas in array and object literals (and maybe other contexts; I'm thinking of {a: 1,} or [0,]).  Other browsers also allow keywords to be used in object literals (like {default: 3}).  Will IE 9 allow any of those those bits of syntax?  Or is there some indication other browsers will reject the syntax as IE does in the future?

    (I don't think I can test for myself with the Platform Preview because I don't have a Vista or better machine or VM.)

    Does Microsoft have anything to say about Google's Sputnik tests?  (Like, "the more test suites the merrier" or "some of those tests look for the wrong behavior"?)

  5. Stifu says:

    "Being all in with HTML5 means being committed to enabling developers to use the Same Markup on the Web, and that includes the same JavaScript code."

    No. For the Nth time, JavaScript is not markup. Neither is CSS. I'd expect experts not to misuse words and miseducate people. Oh well…

    Do the uppercases mean "Same Markup" is now a registered trademark or something? ¬_¬

  6. Randall says:

    Looks like keywords in object literals aren't supported by Chrome (and maybe others), so scratch that.  Still curious whether {a:1,} or [0,] will ever become cross-browser compatible code.

  7. Sputnik? says:

    Have you looked at Google's Sputnik Javascript test? How do your efforts relate to that project?

  8. FremyCompany says:

    Well, I have a question about your ES5 proposal. When calling Object.defineProperty(obj, "prop", {get: function() { return 'value'; }}) and then obj.prop="set?", we face no error. it seems that everything goes as if we add an empty set defined for the property (which seems to be the case, see getOwnPropertyDescriptor (the empty function seems to be native))

    Now, the spec. It says if no "set" has been defined, "UA should use the default value". The problem is that I found no place in the spec that say what's the default value. For me, it should be null, or a function that throw a "Property was readonly error". So, my question is what exactly requires the spec ? why did you implement it that way (no error throw) ?

    Fremy

  9. Bruce says:

    Interesting test:

    Firefox 3.6.4:

    Total tests: 1236 Passed: 568 Failed: 668 Could not load: 0

    Firefox 3.7a6pre

    Total tests: 1236 Passed: 928 Failed: 305 Could not load: 3

    Opera 10.5.1

    Total tests: 1236 Passed: 578 Failed: 658 Could not load: 0

    Safari 5.0 (7533.16)

    Total tests: 1236 Passed: 886 Failed: 350 Could not load: 0

    Chrome 5.0.375.70

    Total tests: 1236 Passed: 874 Failed: 362 Could not load: 0

    IE8 8.0.6001.18702

    Total tests: 1236 Passed: 188 Failed: 1048 Could not load: 0

    IE9 Prerelease 3

    Total tests: 1236 Passed: 386 Failed: 850 Could not load: 0

    Nice to see improvement in IE

  10. blah says:

    Microsoft dares not mention Sputnik. As usual, they're the embarrassed dead last.

    sputnik.googlelabs.com/compare

  11. Saitir says:

    Just checking over the sputnik tests:

    5,246 tests.

    Failure rates:

    78  Opera 10.5

    159 Safari 4.04

    166 IE9 Preview #3

    218 Chrome 4.0

    259 Firefox 3.6

    463 IE8

    I ran the IE9 test myself, the other values come from the sputnik compare results page.

  12. Garrett says:

    Am I the only one having trouble getting the test runner to work?

    Following the download link on: es5conform.codeplex.com

    – and following the directions in the readme, I got nothing but errors.

    Posted:

    groups.google.com/…/e1416d5f9080537a

    Using this site, I get errors in Firefox: WebForm_DoPostBackWithOptions is not defined

    Tsk, you guys, using javascript: URIs? What's with that?

    The button has:

    javascript:WebForm_DoPostBackWithOptions(new%20WebForm_PostBackOptions("ctl00$content$ctl00$fragment_20126$ctl01$ctl00$ctl00$ctl05$bpCommentForm$ctl05$btnSubmit",%20"",%20true,%20"BlogPostCommentForm-ctl00_content_ctl00_fragment_20126_ctl01_ctl00",%20"",%20false,%20true))

    And clicking it results in the error: "WebForm_DoPostBackWithOptions is not defined"

  13. Allen W-B [MSFT] says:

    @Bruce

    It looks like you are running the ES5Conform suite probably from you local machine and the tests are running in a compatibility mode (the intranet zone defaults to compat mode).  You need to explicitly set the mode to IE9 Document Mode and rerun the tests if you want to exercise the ES5 support.

  14. @blah says:

    IE in general, sure. Mostly irrelevant when IE9PP3 is the subject.

  15. Bruce says:

    @Allen W-B

    You're right – my bad.

    Correct numbers for IR9pre3

    Total tests: 1236 Passed: 1002 Failed: 234 Could not load: 0

  16. jabcreations says:

    Sweet! I'm really happy that you guys finally got importNode covered…and the fact that you're trying to cover as much of the standards as possible is great! Also it's nice to see a more objective browser comparison.

    You guys have the resources to make IE totally awesome and the only thing missing is full codec support. When looking at the Wikipedia pages for audio and video element codec support IE only supports proprietary codecs. If you guys really want to truly make us happy let's see that solid green across all those codecs instead of more politics otherwise we'll all be using Flash and/or other plugins well in to the 2020's for media. Okay, cue the Hollywood hack who will criticize my post while he's on lunch break between suing grandmothers because all they care about is milking people for money!

    Lastly if Microsoft wants to truly make amends with the designers IE9 should be released for XP. Of course I doubt that will happen with the whole buy a 7 license. It's politics like these examples that severely limit my enthusiasm for the work being done and should have been done say five years ago. One can't argue against 60%+ market share and a GUI that doesn't work against productivity like Vista and even worse 7.

    As much as I appreciate the hard work being put in to IE9 Microsoft is still ultimately holding the web back and it's ultimately purely for political reasons.

  17. quince says:

    @jabcreations, off-topic

    What makes you think that people using XP/IE6 will suddenly upgrade to IE9? Clearly these people are not interested in cutting edge technology, and will only do so if there are *very* good reasons for it. (i.e.: the sites they visit start breaking – really badly.) Commercial sites won't do this – it has to start with freebie, or amateur sites.

    In this case, XP users can upgrade to Safari, Opera, Chrome or Firefox; Vista/Win7 users can also opt for IE9.

    There is no real need for IE9 on XP, there are alternatives. (Ironic, isn't it? Your biggest competitors bailing you out <grin>)

    Moving the web forward is about content, not the technology how to access that content.

    If people can't access (some of) the content they want they'll switch, otherwise…

  18. Allen W-B [MSFT] says:

    @Randall

    The ES5 standards tells us what we are supposed to do in these situations:

    [1,].length // legal and length should be 1. Works in PPB3, previous versions of IE would have set length to 2

    {a: 1,}  //legal but PPB3 has a bug and is reporting a syntax error

    {default: 3}  //legal but PPB3 has a bug and is reporting a syntax error

    myObj.default=3 //legal and works in PPB3

    This is preview release and it does have bugs.  If you find a bug or what appears to be an interoperability issue please report it via connect.microsoft.com/ie

  19. Randall says:

    @Allen W-B: Wow, thanks for digging into that!  I'm sorry I couldn't report it properly at first since I can't run the IE9 PP.  I put this into Connect (with a reference to your comment), although I recognize that's probably redundant and it may just be closed as such.

    Glad it turns out ES5 allows the trailing commas; accidental trailing commas (e.g., when hastily editing an object literal in a script and not testing cross-browser) have caused some embarrassing problems for apps I worked on.

  20. Brave Geeks PHP says:

    I'm just glad that HTML5 is becoming more the standard. It's funny how mobile devices seem to be at the forefront of this.