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

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

  • Anonymous
    June 25, 2010
    I still can't believe Microsoft calls their engine "Chakra" with a straight face.

  • Anonymous
    June 25, 2010
    This blog post has three tags. Clearly, the first tag needs to be quadriplicated.

  • Anonymous
    June 25, 2010
    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"?)

  • Anonymous
    June 25, 2010
    "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? ¬_¬

  • Anonymous
    June 25, 2010
    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.

  • Anonymous
    June 25, 2010
    Have you looked at Google's Sputnik Javascript test? How do your efforts relate to that project?

  • Anonymous
    June 25, 2010
    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

  • Anonymous
    June 25, 2010
    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

  • Anonymous
    June 25, 2010
    Microsoft dares not mention Sputnik. As usual, they're the embarrassed dead last. sputnik.googlelabs.com/compare

  • Anonymous
    June 25, 2010
    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.

  • Anonymous
    June 25, 2010
    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"
  • Anonymous
    June 25, 2010
    @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.

  • Anonymous
    June 25, 2010
    IE in general, sure. Mostly irrelevant when IE9PP3 is the subject.

  • Anonymous
    June 25, 2010
    @Allen W-B You're right - my bad. Correct numbers for IR9pre3 Total tests: 1236 Passed: 1002 Failed: 234 Could not load: 0

  • Anonymous
    June 25, 2010
    The comment has been removed

  • Anonymous
    June 25, 2010
    The comment has been removed

  • Anonymous
    June 26, 2010
    @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

  • Anonymous
    June 26, 2010
    @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.

  • Anonymous
    June 27, 2010
    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.