Bug 385872 - Strict warnings should only be enabled for chrome by default (in debug builds). r=jst, sr=brendan.

This commit is contained in:
mozilla.mano@sent.com 2007-07-10 01:05:54 -07:00
parent 5733d91a03
commit a1b629fdd9
2 changed files with 15 additions and 7 deletions
browser/app/profile
dom/src/base

@ -279,7 +279,6 @@ pref("browser.bookmarks.sort.resource", "rdf:http://home.netscape.com/NC-rdf#Nam
pref("dom.disable_open_during_load", true);
#ifdef DEBUG
pref("javascript.options.showInConsole", true);
pref("javascript.options.strict", true);
pref("general.warnOnAboutConfig", false);
#else
pref("javascript.options.showInConsole", false);

@ -932,6 +932,18 @@ nsJSContext::JSOptionChangedCallback(const char *pref, void *data)
else
newDefaultJSOptions &= ~JSOPTION_STRICT;
#ifdef DEBUG
// In debug builds, warnings are always enabled in chrome context
// Note this callback is also called from context's InitClasses thus we don't
// need to enable this directly from InitContext
if ((newDefaultJSOptions & JSOPTION_STRICT) == 0) {
nsIScriptGlobalObject *global = context->GetGlobalObject();
nsCOMPtr<nsIDOMChromeWindow> chromeWindow(do_QueryInterface(global));
if (chromeWindow)
newDefaultJSOptions |= JSOPTION_STRICT;
}
#endif
PRBool werror = nsContentUtils::GetBoolPref(js_werror_option_str);
if (werror)
newDefaultJSOptions |= JSOPTION_WERROR;
@ -963,11 +975,7 @@ nsJSContext::nsJSContext(JSRuntime *aRuntime) : mGCOnDestruction(PR_TRUE)
mDefaultJSOptions = JSOPTION_PRIVATE_IS_NSISUPPORTS
| JSOPTION_NATIVE_BRANCH_CALLBACK
| JSOPTION_ANONFUNFIX
#ifdef DEBUG
| JSOPTION_STRICT // lint catching for development
#endif
;
| JSOPTION_ANONFUNFIX;
// Let xpconnect resync its JSContext tracker. We do this before creating
// a new JSContext just in case the heap manager recycles the JSContext
@ -985,7 +993,6 @@ nsJSContext::nsJSContext(JSRuntime *aRuntime) : mGCOnDestruction(PR_TRUE)
nsContentUtils::RegisterPrefCallback(js_options_dot_str,
JSOptionChangedCallback,
this);
JSOptionChangedCallback(js_options_dot_str, this);
::JS_SetBranchCallback(mContext, DOMBranchCallback);
@ -3044,6 +3051,8 @@ nsJSContext::InitClasses(void *aGlobalObj)
::JS_DefineFunctions(mContext, globalObj, JProfFunctions);
#endif
JSOptionChangedCallback(js_options_dot_str, this);
return rv;
}