Bug 1275508 - Remove JavaScript werror from browser. r=mccr8
authorTom Schuster <evilpies@gmail.com>
Wed, 11 Mar 2020 12:20:21 +0000
changeset 518123 f34c6e1c6fb504b24150e522cabab3f284ff79f6
parent 518122 6dd02c648edb3990e67b25f905172497d5891aaa
child 518124 005382a5a58ff70933c9f535b3a8e6158ccccea6
push id37204
push userrmaries@mozilla.com
push dateWed, 11 Mar 2020 15:45:15 +0000
treeherdermozilla-central@5e32bdf73dc2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1275508
milestone76.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1275508 - Remove JavaScript werror from browser. r=mccr8 Differential Revision: https://phabricator.services.mozilla.com/D66255
dom/workers/RuntimeService.cpp
js/src/tests/user.js
js/xpconnect/idl/xpccomponents.idl
js/xpconnect/src/XPCComponents.cpp
js/xpconnect/src/XPCJSContext.cpp
js/xpconnect/src/XPCShellImpl.cpp
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -269,37 +269,36 @@ void LoadContextOptions(const char* aPre
       prefName.EqualsLiteral(PREF_WORKERS_OPTIONS_PREFIX PREF_GCZEAL)) {
     return;
   }
 #endif
 
   // Context options.
   JS::ContextOptions contextOptions;
   contextOptions.setAsmJS(GetWorkerPref<bool>(NS_LITERAL_CSTRING("asmjs")))
+#ifdef FUZZING
+      .setFuzzing(GetWorkerPref<bool>(NS_LITERAL_CSTRING("fuzzing.enabled")))
+#endif
       .setWasm(GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm")))
       .setWasmForTrustedPrinciples(
           GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm_trustedprincipals")))
       .setWasmBaseline(
           GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm_baselinejit")))
       .setWasmIon(GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm_ionjit")))
 #ifdef ENABLE_WASM_CRANELIFT
       .setWasmCranelift(
           GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm_cranelift")))
 #endif
 #ifdef ENABLE_WASM_REFTYPES
       .setWasmGc(GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm_gc")))
 #endif
       .setWasmVerbose(GetWorkerPref<bool>(NS_LITERAL_CSTRING("wasm_verbose")))
       .setThrowOnAsmJSValidationFailure(GetWorkerPref<bool>(
           NS_LITERAL_CSTRING("throw_on_asmjs_validation_failure")))
-      .setAsyncStack(GetWorkerPref<bool>(NS_LITERAL_CSTRING("asyncstack")))
-#ifdef FUZZING
-      .setFuzzing(GetWorkerPref<bool>(NS_LITERAL_CSTRING("fuzzing.enabled")))
-#endif
-      .setWerror(GetWorkerPref<bool>(NS_LITERAL_CSTRING("werror")));
+      .setAsyncStack(GetWorkerPref<bool>(NS_LITERAL_CSTRING("asyncstack")));
 
   nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
   if (xr) {
     bool safeMode = false;
     xr->GetInSafeMode(&safeMode);
     if (safeMode) {
       contextOptions.disableOptionsForSafeMode();
     }
--- a/js/src/tests/user.js
+++ b/js/src/tests/user.js
@@ -13,17 +13,16 @@ user_pref("dom.max_chrome_script_run_tim
 user_pref("javascript.allow.mailnews", true);
 user_pref("javascript.options.showInConsole", true);
 user_pref("layout.css.report_errors", true);
 user_pref("browser.warnOnQuit", false);
 user_pref("browser.cache.check_doc_frequency", 1);
 user_pref("extensions.checkCompatibility", false);
 user_pref("extensions.checkUpdateSecurity", false);
 user_pref("browser.EULA.override", true);
-user_pref("javascript.options.werror", false);
 user_pref("toolkit.startup.max_resumed_crashes", -1);
 user_pref("security.turn_off_all_security_so_that_viruses_can_take_over_this_computer", true);
 user_pref("datareporting.healthreport.uploadEnabled", false);
 user_pref("browser.safebrowsing.phishing.enabled", false);
 user_pref("browser.safebrowsing.malware.enabled", false);
 user_pref("browser.safebrowsing.blockedURIs.enabled", false);
 user_pref("browser.safebrowsing.passwords.enabled", false);
 user_pref("plugins.flashBlock.enabled", false);
--- a/js/xpconnect/idl/xpccomponents.idl
+++ b/js/xpconnect/idl/xpccomponents.idl
@@ -496,30 +496,22 @@ interface nsIXPCComponents_Utils : nsISu
      * Dispatches a runnable to the current/main thread. If |scope| is passed,
      * the runnable will be dispatch in the compartment of |scope|, which
      * affects which error reporter gets called.
      */
     [implicit_jscontext]
     void dispatch(in jsval runnable, [optional] in jsval scope);
 
     /*
-     * To be called from JS only.
-     *
-     * These are the set of JSContext options that privileged script
-     * is allowed to control for the purposes of testing.  These
-     * options should be kept in sync with what's controllable in the
-     * jsshell and by setting prefs in nsJSEnvironment.
+     * Bug 1621603 - Remove strict_mode.
      *
-     * NB: Assume that getting any of these attributes is relatively
-     * cheap, but setting any of them is relatively expensive.
+     * Do not use this API! Instead use "use strict"; at the top of your JS
+     * file.
      */
     [implicit_jscontext]
-    attribute boolean werror;
-
-    [implicit_jscontext]
     attribute boolean strict_mode;
 
     // Returns true if we're running in automation and certain security
     // restrictions can be eased.
     readonly attribute boolean isInAutomation;
 
     void crashIfNotInAutomation();
 
--- a/js/xpconnect/src/XPCComponents.cpp
+++ b/js/xpconnect/src/XPCComponents.cpp
@@ -2091,17 +2091,16 @@ nsXPCComponents_Utils::Dispatch(HandleVa
     return NS_OK;                                                       \
   }                                                                     \
   NS_IMETHODIMP                                                         \
   nsXPCComponents_Utils::Set##_attr(JSContext* cx, bool aValue) {       \
     ContextOptionsRef(cx)._setter(aValue);                              \
     return NS_OK;                                                       \
   }
 
-GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Werror, werror, setWerror)
 GENERATE_JSCONTEXTOPTION_GETTER_SETTER(Strict_mode, strictMode, setStrictMode)
 
 #undef GENERATE_JSCONTEXTOPTION_GETTER_SETTER
 
 NS_IMETHODIMP
 nsXPCComponents_Utils::SetGCZeal(int32_t aValue, JSContext* cx) {
 #ifdef JS_GC_ZEAL
   JS_SetGCZeal(cx, uint8_t(aValue), JS_DEFAULT_ZEAL_FREQ);
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -906,18 +906,16 @@ static void ReloadPrefsCallback(const ch
   bool useAsyncStack = Preferences::GetBool(JS_OPTIONS_DOT_STR "asyncstack");
 
   bool throwOnDebuggeeWouldRun =
       Preferences::GetBool(JS_OPTIONS_DOT_STR "throw_on_debuggee_would_run");
 
   bool dumpStackOnDebuggeeWouldRun = Preferences::GetBool(
       JS_OPTIONS_DOT_STR "dump_stack_on_debuggee_would_run");
 
-  bool werror = Preferences::GetBool(JS_OPTIONS_DOT_STR "werror");
-
   sSharedMemoryEnabled =
       Preferences::GetBool(JS_OPTIONS_DOT_STR "shared_memory");
   sStreamsEnabled = Preferences::GetBool(JS_OPTIONS_DOT_STR "streams");
   sPropertyErrorMessageFixEnabled =
       Preferences::GetBool(JS_OPTIONS_DOT_STR "property_error_message_fix");
 #ifdef NIGHTLY_BUILD
   sWeakRefsEnabled =
       Preferences::GetBool(JS_OPTIONS_DOT_STR "experimental.weakrefs");
@@ -933,35 +931,34 @@ static void ReloadPrefsCallback(const ch
 #endif  // JS_GC_ZEAL
 
 #ifdef FUZZING
   bool fuzzingEnabled = StaticPrefs::fuzzing_enabled();
 #endif
 
   JS::ContextOptionsRef(cx)
       .setAsmJS(useAsmJS)
+#ifdef FUZZING
+      .setFuzzing(fuzzingEnabled)
+#endif
       .setWasm(useWasm)
       .setWasmForTrustedPrinciples(useWasmTrustedPrincipals)
       .setWasmIon(useWasmIon)
       .setWasmBaseline(useWasmBaseline)
 #ifdef ENABLE_WASM_CRANELIFT
       .setWasmCranelift(useWasmCranelift)
 #endif
 #ifdef ENABLE_WASM_GC
       .setWasmGc(useWasmGc)
 #endif
       .setWasmVerbose(useWasmVerbose)
       .setThrowOnAsmJSValidationFailure(throwOnAsmJSValidationFailure)
       .setAsyncStack(useAsyncStack)
       .setThrowOnDebuggeeWouldRun(throwOnDebuggeeWouldRun)
-      .setDumpStackOnDebuggeeWouldRun(dumpStackOnDebuggeeWouldRun)
-#ifdef FUZZING
-      .setFuzzing(fuzzingEnabled)
-#endif
-      .setWerror(werror);
+      .setDumpStackOnDebuggeeWouldRun(dumpStackOnDebuggeeWouldRun);
 
   nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
   if (xr) {
     bool safeMode = false;
     xr->GetInSafeMode(&safeMode);
     if (safeMode) {
       JS::ContextOptionsRef(cx).disableOptionsForSafeMode();
     }
--- a/js/xpconnect/src/XPCShellImpl.cpp
+++ b/js/xpconnect/src/XPCShellImpl.cpp
@@ -480,38 +480,28 @@ static bool Options(JSContext* cx, unsig
       return false;
     }
 
     opt = JS_EncodeStringToUTF8(cx, str);
     if (!opt) {
       return false;
     }
 
-    if (strcmp(opt.get(), "werror") == 0) {
-      ContextOptionsRef(cx).toggleWerror();
-    } else if (strcmp(opt.get(), "strict_mode") == 0) {
+    if (strcmp(opt.get(), "strict_mode") == 0) {
       ContextOptionsRef(cx).toggleStrictMode();
     } else {
       JS_ReportErrorUTF8(cx,
-                         "unknown option name '%s'. The valid names are "
-                         "werror and strict_mode.",
+                         "unknown option name '%s'. The valid name is "
+                         "strict_mode.",
                          opt.get());
       return false;
     }
   }
 
   UniqueChars names;
-  if (oldContextOptions.werror()) {
-    names =
-        JS_sprintf_append(std::move(names), "%s%s", names ? "," : "", "werror");
-    if (!names) {
-      JS_ReportOutOfMemory(cx);
-      return false;
-    }
-  }
   if (names && oldContextOptions.strictMode()) {
     names = JS_sprintf_append(std::move(names), "%s%s", names ? "," : "",
                               "strict_mode");
     if (!names) {
       JS_ReportOutOfMemory(cx);
       return false;
     }
   }
@@ -833,47 +823,26 @@ static bool Process(AutoJSAPI& jsapi, co
   }
   return ok;
 }
 
 static int usage() {
   fprintf(gErrFile, "%s\n", JS_GetImplementationVersion());
   fprintf(
       gErrFile,
-      "usage: xpcshell [-g gredir] [-a appdir] [-r manifest]... [-WwxiCSmIp] "
+      "usage: xpcshell [-g gredir] [-a appdir] [-r manifest]... [-WwxiCmIp] "
       "[-f scriptfile] [-e script] [scriptfile] [scriptarg...]\n");
   return 2;
 }
 
 static bool printUsageAndSetExitCode() {
   gExitCode = usage();
   return false;
 }
 
-static void ProcessArgsForCompartment(JSContext* cx, char** argv, int argc) {
-  for (int i = 0; i < argc; i++) {
-    if (argv[i][0] != '-' || argv[i][1] == '\0') {
-      break;
-    }
-
-    switch (argv[i][1]) {
-      case 'v':
-      case 'f':
-      case 'e':
-        if (++i == argc) {
-          return;
-        }
-        break;
-      case 'S':
-        ContextOptionsRef(cx).toggleWerror();
-        break;
-    }
-  }
-}
-
 static bool ProcessArgs(AutoJSAPI& jsapi, char** argv, int argc,
                         XPCShellDirProvider* aDirProvider) {
   JSContext* cx = jsapi.cx();
   const char rcfilename[] = "xpcshell.js";
   FILE* rcfile;
   int rootPosition;
   JS::Rooted<JSObject*> argsObj(cx);
   char* filename = nullptr;
@@ -991,19 +960,16 @@ static bool ProcessArgs(AutoJSAPI& jsapi
 
         isInteractive = false;
         break;
       }
       case 'C':
         compileOnly = true;
         isInteractive = false;
         break;
-      case 'S':
-        // These options are processed in ProcessArgsForCompartment.
-        break;
       case 'p': {
         // plugins path
         char* pluginPath = argv[++i];
         nsCOMPtr<nsIFile> pluginsDir;
         if (NS_FAILED(
                 XRE_GetFileFromPath(pluginPath, getter_AddRefs(pluginsDir)))) {
           fprintf(gErrFile, "Couldn't use given plugins dir.\n");
           return printUsageAndSetExitCode();
@@ -1255,17 +1221,16 @@ int XRE_XPCShellMain(int argc, char** ar
     // reason to bother.
     sScriptedInterruptCallback = new PersistentRootedValue;
     sScriptedInterruptCallback->init(cx, UndefinedValue());
 
     JS_AddInterruptCallback(cx, XPCShellInterruptCallback);
 
     argc--;
     argv++;
-    ProcessArgsForCompartment(cx, argv, argc);
 
     nsCOMPtr<nsIPrincipal> systemprincipal;
     // Fetch the system principal and store it away in a global, to use for
     // script compilation in Load() and ProcessFile() (including interactive
     // eval loop)
     {
       nsCOMPtr<nsIScriptSecurityManager> securityManager =
           do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);