diff --git a/mozilla/content/base/src/nsParserUtils.cpp b/mozilla/content/base/src/nsParserUtils.cpp index 2d278225b1d..802f81bc921 100644 --- a/mozilla/content/base/src/nsParserUtils.cpp +++ b/mozilla/content/base/src/nsParserUtils.cpp @@ -151,6 +151,9 @@ nsParserUtils::IsJavaScriptLanguage(const nsString& aName, const char* *aVersion else if (aName.LowerCaseEqualsLiteral("javascript1.5")) { version = JSVERSION_1_5; } + else if (aName.LowerCaseEqualsLiteral("javascript1.6")) { + version = JSVERSION_1_6; + } if (version == JSVERSION_UNKNOWN) return PR_FALSE; *aVersion = JS_VersionToString(version); diff --git a/mozilla/content/base/src/nsScriptLoader.cpp b/mozilla/content/base/src/nsScriptLoader.cpp index 563e2e40f5e..692df441c74 100644 --- a/mozilla/content/base/src/nsScriptLoader.cpp +++ b/mozilla/content/base/src/nsScriptLoader.cpp @@ -473,6 +473,7 @@ nsScriptLoader::ProcessScriptElement(nsIScriptElement *aElement, case '3': jsVersion = JSVERSION_1_3; break; case '4': jsVersion = JSVERSION_1_4; break; case '5': jsVersion = JSVERSION_1_5; break; + case '6': jsVersion = JSVERSION_1_6; break; default: jsVersion = JSVERSION_UNKNOWN; } } @@ -739,9 +740,12 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest, JSContext *cx = (JSContext *)context->GetNativeContext(); uint32 options = ::JS_GetOptions(cx); - PRBool needE4X = aRequest->mHasE4XOption && !(options & JSOPTION_XML); - if (needE4X) { - ::JS_SetOptions(cx, options | JSOPTION_XML); + JSBool changed = (aRequest->mHasE4XOption ^ !!(options & JSOPTION_XML)); + if (changed) { + ::JS_SetOptions(cx, + aRequest->mHasE4XOption + ? options | JSOPTION_XML + : options & ~JSOPTION_XML); } // Update our current script. @@ -757,7 +761,7 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest, mCurrentScript = oldCurrent; ::JS_ReportPendingException(cx); - if (needE4X) { + if (changed) { ::JS_SetOptions(cx, options); } diff --git a/mozilla/content/xul/document/src/nsXULContentSink.cpp b/mozilla/content/xul/document/src/nsXULContentSink.cpp index 47a3ec0836b..48492718efd 100644 --- a/mozilla/content/xul/document/src/nsXULContentSink.cpp +++ b/mozilla/content/xul/document/src/nsXULContentSink.cpp @@ -1241,6 +1241,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes, case '3': jsVersion = JSVERSION_1_3; break; case '4': jsVersion = JSVERSION_1_4; break; case '5': jsVersion = JSVERSION_1_5; break; + case '6': jsVersion = JSVERSION_1_6; break; default: jsVersion = JSVERSION_UNKNOWN; } } diff --git a/mozilla/js/src/jscntxt.h b/mozilla/js/src/jscntxt.h index d39e970c7b5..6d2d9e6721f 100644 --- a/mozilla/js/src/jscntxt.h +++ b/mozilla/js/src/jscntxt.h @@ -512,7 +512,10 @@ struct JSContext { #define JSVERSION_MASK 0x0FFF /* see JSVersion in jspubtd.h */ #define JSVERSION_HAS_XML 0x1000 /* flag induced by XML option */ -#define JS_HAS_XML_OPTION(cx) ((cx)->version & JSVERSION_HAS_XML) + +#define JSVERSION_NUMBER(cx) ((cx)->version & JSVERSION_MASK) +#define JS_HAS_XML_OPTION(cx) ((cx)->version & JSVERSION_HAS_XML || \ + JSVERSION_NUMBER(cx) >= JSVERSION_1_6) #define JS_HAS_NATIVE_BRANCH_CALLBACK_OPTION(cx) \ JS_HAS_OPTION(cx, JSOPTION_NATIVE_BRANCH_CALLBACK) @@ -521,10 +524,8 @@ struct JSContext { * Wrappers for the JSVERSION_IS_* macros from jspubtd.h taking JSContext *cx * and masking off the XML flag and any other high order bits. */ -#define JS_VERSION_IS_ECMA(cx) \ - JSVERSION_IS_ECMA((cx)->version & JSVERSION_MASK) -#define JS_VERSION_IS_1_2(cx) \ - (((cx)->version & JSVERSION_MASK) == JSVERSION_1_2) +#define JS_VERSION_IS_ECMA(cx) JSVERSION_IS_ECMA(JSVERSION_NUMBER(cx)) +#define JS_VERSION_IS_1_2(cx) (JSVERSION_NUMBER(cx) == JSVERSION_1_2) /* * Common subroutine of JS_SetVersion and js_SetVersion, to update per-context diff --git a/mozilla/js/src/jsconfig.h b/mozilla/js/src/jsconfig.h index 76969e89f2b..5902499f90e 100644 --- a/mozilla/js/src/jsconfig.h +++ b/mozilla/js/src/jsconfig.h @@ -41,14 +41,14 @@ * JS configuration macros. */ #ifndef JS_VERSION -#define JS_VERSION 150 +#define JS_VERSION 160 #endif /* * Compile-time JS version configuration. The JS version numbers lie on the * number line like so: * - * 1.0 1.1 1.2 1.3 1.4 ECMAv3 1.5 + * 1.0 1.1 1.2 1.3 1.4 ECMAv3 1.5 1.6 * ^ ^ * | | * basis for ECMAv1 close to ECMAv2 @@ -448,6 +448,66 @@ #define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive */ #define JS_BUG_WITH_CLOSURE 0 /* with(o)function f(){} sets o.f */ +#define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */ +#define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */ +#define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */ +#define JS_HAS_DO_WHILE_LOOP 1 /* has do {...} while (b) */ +#define JS_HAS_SWITCH_STATEMENT 1 /* has switch (v) {case c: ...} */ +#define JS_HAS_SOME_PERL_FUN 1 /* has array.join/reverse/sort */ +#define JS_HAS_MORE_PERL_FUN 1 /* has array.push, str.substr, etc */ +#define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */ +#define JS_HAS_PERL_SUBSTR 1 /* has str.substr */ +#define JS_HAS_VALUEOF_HINT 1 /* valueOf(hint) where hint is typeof */ +#define JS_HAS_LEXICAL_CLOSURE 1 /* nested functions, lexically closed */ +#define JS_HAS_APPLY_FUNCTION 1 /* has apply(fun, arg1, ... argN) */ +#define JS_HAS_CALL_FUNCTION 1 /* has fun.call(obj, arg1, ... argN) */ +#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ +#define JS_HAS_REGEXPS 1 /* has perl r.e.s via RegExp, /pat/ */ +#define JS_HAS_SEQUENCE_OPS 1 /* has array.slice, string.concat */ +#define JS_HAS_INITIALIZERS 1 /* has var o = {'foo': 42, 'bar':3} */ +#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ +#define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun */ +#define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */ +#define JS_HAS_TRIPLE_EQOPS 1 /* has === and !== identity eqops */ +#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */ +#define JS_HAS_REPLACE_LAMBDA 1 /* has string.replace(re, lambda) */ +#define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() */ +#define JS_HAS_XDR 1 /* has XDR API and internal support */ +#define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */ +#define JS_HAS_EXCEPTIONS 1 /* has exception handling */ +#define JS_HAS_UNDEFINED 1 /* has global "undefined" property */ +#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ +#define JS_HAS_IN_OPERATOR 1 /* has in operator ('p' in {p:1}) */ +#define JS_HAS_INSTANCEOF 1 /* has {p:1} instanceof Object */ +#define JS_HAS_ARGS_OBJECT 1 /* has minimal ECMA arguments object */ +#define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */ +#define JS_HAS_ERROR_EXCEPTIONS 1 /* rt errors reflected as exceptions */ +#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */ +#define JS_HAS_NEW_OBJ_METHODS 1 /* has Object.prototype query methods */ +#define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */ +#define JS_HAS_DFLT_MSG_STRINGS 1 /* provides English error messages */ +#define JS_HAS_NUMBER_FORMATS 1 /* numbers have formatting methods */ +#define JS_HAS_GETTER_SETTER 1 /* has JS2 getter/setter functions */ +#define JS_HAS_UNEVAL 1 /* has uneval() top-level function */ +#define JS_HAS_CONST 1 /* has JS2 const as alternative var */ +#define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statement */ +#define JS_HAS_LVALUE_RETURN 1 /* has o.item(i) = j; for native item */ +#define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler */ +#define JS_HAS_XML_SUPPORT 0 /* has ECMAScript for XML support */ +#define JS_HAS_ARRAY_EXTRAS 0 /* has indexOf and Lispy extras */ + +#elif JS_VERSION == 160 + +#define JS_BUG_NULL_INDEX_PROPS 0 /* o[0] defaults to null, not void */ +#define JS_BUG_EMPTY_INDEX_ZERO 0 /* o[""] is equivalent to o[0] */ +#define JS_BUG_EAGER_TOSTRING 0 /* o.toString() trumps o.valueOf() */ +#define JS_BUG_VOID_TOSTRING 0 /* void 0 + 0 == "undefined0" */ +#define JS_BUG_EVAL_THIS_FUN 0 /* eval('this') in function f is f */ +#define JS_BUG_EVAL_THIS_SCOPE 0 /* Math.eval('sin(x)') vs. local x */ +#define JS_BUG_FALLIBLE_EQOPS 0 /* fallible/intransitive equality ops */ +#define JS_BUG_FALLIBLE_TONUM 0 /* fallible ValueToNumber primitive */ +#define JS_BUG_WITH_CLOSURE 0 /* with(o)function f(){} sets o.f */ + #define JS_HAS_PROP_DELETE 1 /* delete o.p removes p from o */ #define JS_HAS_CALL_OBJECT 1 /* fun.caller is stack frame obj */ #define JS_HAS_LABEL_STATEMENT 1 /* has break/continue to label: */ diff --git a/mozilla/js/src/jspubtd.h b/mozilla/js/src/jspubtd.h index ae856bee6da..c40946f20ac 100644 --- a/mozilla/js/src/jspubtd.h +++ b/mozilla/js/src/jspubtd.h @@ -69,6 +69,7 @@ typedef enum JSVersion { JSVERSION_1_4 = 140, JSVERSION_ECMA_3 = 148, JSVERSION_1_5 = 150, + JSVERSION_1_6 = 160, JSVERSION_DEFAULT = 0, JSVERSION_UNKNOWN = -1 } JSVersion;