Bug 1420101 - Add default enabled pref for Array.prototype.values. r=jandem,bz

--HG--
extra : rebase_source : a8e3eb91d08c22e63a4ff4ac499067b8a64996f1
This commit is contained in:
Tom Schuster 2018-02-02 18:46:21 +01:00
parent a361be5f80
commit 7fd063c021
9 changed files with 31 additions and 8 deletions

View File

@ -107,6 +107,7 @@ const char* mozilla::dom::ContentPrefs::gEarlyPrefs[] = {
"intl.charset.fallback.utf8_for_file",
"intl.ime.hack.on_ime_unaware_apps.fire_key_events_for_composition",
"javascript.enabled",
"javascript.options.array_prototype_values",
"javascript.options.asmjs",
"javascript.options.asyncstack",
"javascript.options.baselinejit",

View File

@ -305,7 +305,9 @@ LoadContextOptions(const char* aPrefName, void* /* aClosure */)
.setFuzzing(GetWorkerPref<bool>(NS_LITERAL_CSTRING("fuzzing.enabled")))
#endif
.setStreams(GetWorkerPref<bool>(NS_LITERAL_CSTRING("streams")))
.setExtraWarnings(GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict")));
.setExtraWarnings(GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict")))
.setArrayProtoValues(GetWorkerPref<bool>(
NS_LITERAL_CSTRING("array_prototype_values")));
nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
if (xr) {

View File

@ -1118,6 +1118,7 @@ class JS_PUBLIC_API(ContextOptions) {
, fuzzing_(false)
#endif
, expressionClosures_(false)
, arrayProtoValues_(true)
{
}
@ -1279,6 +1280,12 @@ class JS_PUBLIC_API(ContextOptions) {
return *this;
}
bool arrayProtoValues() const { return arrayProtoValues_; }
ContextOptions& setArrayProtoValues(bool flag) {
arrayProtoValues_ = flag;
return *this;
}
void disableOptionsForSafeMode() {
setBaseline(false);
setIon(false);
@ -1310,6 +1317,7 @@ class JS_PUBLIC_API(ContextOptions) {
bool fuzzing_ : 1;
#endif
bool expressionClosures_ : 1;
bool arrayProtoValues_ : 1;
};

View File

@ -3543,9 +3543,7 @@ static const JSFunctionSpec array_methods[] = {
JS_SELF_HOSTED_SYM_FN(iterator, "ArrayValues", 0,0),
JS_SELF_HOSTED_FN("entries", "ArrayEntries", 0,0),
JS_SELF_HOSTED_FN("keys", "ArrayKeys", 0,0),
#ifdef NIGHTLY_BUILD
JS_SELF_HOSTED_FN("values", "ArrayValues", 0,0),
#endif
/* ES7 additions */
JS_SELF_HOSTED_FN("includes", "ArrayIncludes", 2,0),

View File

@ -2967,6 +2967,11 @@ DefineFunctionFromSpec(JSContext* cx, HandleObject obj, const JSFunctionSpec* fs
if (!PropertySpecNameToId(cx, fs->name, &id))
return false;
if (StandardProtoKeyOrNull(obj) == JSProto_Array && id == NameToId(cx->names().values)) {
if (!cx->options().arrayProtoValues())
return true;
}
JSFunction* fun = NewFunctionFromSpec(cx, fs, id);
if (!fun)
return false;

View File

@ -478,6 +478,7 @@ static bool enableWasmIon = false;
static bool enableTestWasmAwaitTier2 = false;
static bool enableAsyncStacks = false;
static bool enableStreams = false;
static bool enableArrayProtoValues = true;
#ifdef JS_GC_ZEAL
static uint32_t gZealBits = 0;
static uint32_t gZealFrequency = 0;
@ -8495,6 +8496,7 @@ SetContextOptions(JSContext* cx, const OptionParser& op)
enableTestWasmAwaitTier2 = op.getBoolOption("test-wasm-await-tier2");
enableAsyncStacks = !op.getBoolOption("no-async-stacks");
enableStreams = op.getBoolOption("enable-streams");
enableArrayProtoValues = !op.getBoolOption("no-array-proto-values");
JS::ContextOptionsRef(cx).setBaseline(enableBaseline)
.setIon(enableIon)
@ -8505,7 +8507,8 @@ SetContextOptions(JSContext* cx, const OptionParser& op)
.setTestWasmAwaitTier2(enableTestWasmAwaitTier2)
.setNativeRegExp(enableNativeRegExp)
.setAsyncStack(enableAsyncStacks)
.setStreams(enableStreams);
.setStreams(enableStreams)
.setArrayProtoValues(enableArrayProtoValues);
if (op.getBoolOption("no-unboxed-objects"))
jit::JitOptions.disableUnboxedObjects = true;
@ -8794,7 +8797,8 @@ SetWorkerContextOptions(JSContext* cx)
.setWasmIon(enableWasmIon)
.setTestWasmAwaitTier2(enableTestWasmAwaitTier2)
.setNativeRegExp(enableNativeRegExp)
.setStreams(enableStreams);
.setStreams(enableStreams)
.setArrayProtoValues(enableArrayProtoValues);
cx->runtime()->setOffthreadIonCompilationEnabled(offthreadCompilation);
cx->runtime()->profilingScripts = enableCodeCoverage || enableDisassemblyDumps;
@ -9034,6 +9038,7 @@ main(int argc, char** argv, char** envp)
|| !op.addBoolOption('\0', "no-native-regexp", "Disable native regexp compilation")
|| !op.addBoolOption('\0', "no-unboxed-objects", "Disable creating unboxed plain objects")
|| !op.addBoolOption('\0', "enable-streams", "Enable WHATWG Streams")
|| !op.addBoolOption('\0', "no-array-proto-values", "Remove Array.prototype.values")
#ifdef ENABLE_SHARED_ARRAY_BUFFER
|| !op.addStringOption('\0', "shared-memory", "on/off",
"SharedArrayBuffer and Atomics "

View File

@ -830,6 +830,8 @@ ReloadPrefsCallback(const char* pref, void* data)
bool fuzzingEnabled = Preferences::GetBool("fuzzing.enabled");
#endif
bool arrayProtoValues = Preferences::GetBool(JS_OPTIONS_DOT_STR "array_prototype_values");
JS::ContextOptionsRef(cx).setBaseline(useBaseline)
.setIon(useIon)
.setAsmJS(useAsmJS)
@ -846,7 +848,8 @@ ReloadPrefsCallback(const char* pref, void* data)
.setFuzzing(fuzzingEnabled)
#endif
.setStreams(streams)
.setExtraWarnings(extraWarnings);
.setExtraWarnings(extraWarnings)
.setArrayProtoValues(arrayProtoValues);
nsCOMPtr<nsIXULRuntime> xr = do_GetService("@mozilla.org/xre/runtime;1");
if (xr) {

View File

@ -201,9 +201,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
"pop", "shift", "unshift", "splice", "concat", "slice", "lastIndexOf", "indexOf",
"includes", "forEach", "map", "reduce", "reduceRight", "filter", "some", "every", "find",
"findIndex", "copyWithin", "fill", Symbol.iterator, Symbol.unscopables, "entries", "keys",
"constructor"];
"values", "constructor"];
if (isNightlyBuild) {
gPrototypeProperties['Array'].push("values");
gPrototypeProperties['Array'].push("flatten", "flatMap");
}
gConstructorProperties['Array'] =

View File

@ -1431,6 +1431,8 @@ pref("dom.webcomponents.customelements.enabled", false);
#endif
pref("javascript.enabled", true);
// Enable Array.prototype.values
pref("javascript.options.array_prototype_values", true);
pref("javascript.options.strict", false);
#ifdef DEBUG
pref("javascript.options.strict.debug", false);