Bug 381031: make JS1.8 the default for <xul:script>, and add a JSVERSION_LATEST #define to simplify future changes, patch by Nickolay Ponomarev <asqueella@gmail.com>, r+sr=brendan

This commit is contained in:
gavin@gavinsharp.com 2007-06-07 15:50:12 -07:00
parent 7cbb96fa68
commit 218738d375
4 changed files with 21 additions and 19 deletions

View File

@ -1040,6 +1040,7 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
if (isJavaScript) {
langID = nsIProgrammingLanguage::JAVASCRIPT;
version = JSVERSION_LATEST;
} else {
// Use the script object factory to locate the language.
nsCOMPtr<nsIScriptRuntime> runtime;
@ -1059,20 +1060,20 @@ XULContentSinkImpl::OpenScript(const PRUnichar** aAttributes,
EmptyCString(), PR_FALSE, nsnull,
versionName);
if (NS_FAILED(rv)) {
// no version specified - version remains 0.
if (rv != NS_ERROR_INVALID_ARG)
return rv;
} else {
nsCOMPtr<nsIScriptRuntime> runtime;
rv = NS_GetScriptRuntimeByID(langID, getter_AddRefs(runtime));
if (NS_FAILED(rv))
return rv;
rv = runtime->ParseVersion(versionName, &version);
if (NS_FAILED(rv)) {
NS_WARNING("This script language version is not supported - ignored");
langID = nsIProgrammingLanguage::UNKNOWN;
}
if (rv != NS_ERROR_INVALID_ARG)
return rv;
// no version specified - version remains the default.
} else {
nsCOMPtr<nsIScriptRuntime> runtime;
rv = NS_GetScriptRuntimeByID(langID, getter_AddRefs(runtime));
if (NS_FAILED(rv))
return rv;
rv = runtime->ParseVersion(versionName, &version);
if (NS_FAILED(rv)) {
NS_WARNING("This script language version is not supported - ignored");
langID = nsIProgrammingLanguage::UNKNOWN;
}
}
}
// Some js specifics yet to be abstracted.
if (langID == nsIProgrammingLanguage::JAVASCRIPT) {

View File

@ -589,8 +589,8 @@ NS_IMETHODIMP nsJSSh::Init()
// Enable e4x:
JS_SetOptions(mJSContext, JS_GetOptions(mJSContext) | JSOPTION_XML);
// Enable js1.7 features (let, yield, etc - see bug#351515)
JS_SetVersion(mJSContext, JSVERSION_1_7);
// Always use the latest js version
JS_SetVersion(mJSContext, JSVERSION_LATEST);
mContextStack = do_GetService("@mozilla.org/js/xpc/ContextStack;1");
if (!mContextStack) {

View File

@ -73,7 +73,8 @@ typedef enum JSVersion {
JSVERSION_1_7 = 170,
JSVERSION_1_8 = 180,
JSVERSION_DEFAULT = 0,
JSVERSION_UNKNOWN = -1
JSVERSION_UNKNOWN = -1,
JSVERSION_LATEST = JSVERSION_1_8
} JSVersion;
#define JSVERSION_IS_ECMA(version) \

View File

@ -511,9 +511,9 @@ mozJSComponentLoader::ReallyInit()
uint32 options = JS_GetOptions(mContext);
JS_SetOptions(mContext, options | JSOPTION_XML);
// enable Javascript 1.7 features (let, yield, etc. - see bug#351515)
JS_SetVersion(mContext, JSVERSION_1_7);
// Always use the latest js version
JS_SetVersion(mContext, JSVERSION_LATEST);
#ifndef XPCONNECT_STANDALONE
nsCOMPtr<nsIScriptSecurityManager> secman =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);