summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-03-28 11:33:19 +0200
committerwolfbeast <mcwerewolf@gmail.com>2018-03-28 11:33:19 +0200
commitdc8aad9b9dc6983bb88aa586f34d9db007840eb8 (patch)
treec8d904ea558af12c858ee6df1f9a08cfa11434e5
parent19b934070704c1ed12d3a75bc97752831d23f087 (diff)
parentd990d8ab2cade6c928e8bbe56ae038d020cef599 (diff)
downloadUXP-dc8aad9b9dc6983bb88aa586f34d9db007840eb8.tar
UXP-dc8aad9b9dc6983bb88aa586f34d9db007840eb8.tar.gz
UXP-dc8aad9b9dc6983bb88aa586f34d9db007840eb8.tar.lz
UXP-dc8aad9b9dc6983bb88aa586f34d9db007840eb8.tar.xz
UXP-dc8aad9b9dc6983bb88aa586f34d9db007840eb8.zip
Merge remote-tracking branch 'janek/_testBranch_js_array_values'
-rw-r--r--dom/workers/RuntimeService.cpp4
-rw-r--r--js/src/jsapi.h10
-rw-r--r--js/src/jsarray.cpp2
-rw-r--r--js/src/jsobj.cpp5
-rw-r--r--js/src/shell/js.cpp9
-rw-r--r--js/xpconnect/src/XPCJSContext.cpp5
-rw-r--r--js/xpconnect/tests/chrome/test_xrayToJS.xul4
-rw-r--r--modules/libpref/init/all.js2
8 files changed, 32 insertions, 9 deletions
diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp
index 1f5616873..1739f3d31 100644
--- a/dom/workers/RuntimeService.cpp
+++ b/dom/workers/RuntimeService.cpp
@@ -301,7 +301,9 @@ LoadContextOptions(const char* aPrefName, void* /* aClosure */)
.setNativeRegExp(GetWorkerPref<bool>(NS_LITERAL_CSTRING("native_regexp")))
.setAsyncStack(GetWorkerPref<bool>(NS_LITERAL_CSTRING("asyncstack")))
.setWerror(GetWorkerPref<bool>(NS_LITERAL_CSTRING("werror")))
- .setExtraWarnings(GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict")));
+ .setExtraWarnings(GetWorkerPref<bool>(NS_LITERAL_CSTRING("strict")))
+ .setArrayProtoValues(GetWorkerPref<bool>(
+ NS_LITERAL_CSTRING("array_prototype_values")));
RuntimeService::SetDefaultContextOptions(contextOptions);
diff --git a/js/src/jsapi.h b/js/src/jsapi.h
index 5523dfa1d..989abe47c 100644
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -1099,7 +1099,8 @@ class JS_PUBLIC_API(ContextOptions) {
dumpStackOnDebuggeeWouldRun_(false),
werror_(false),
strictMode_(false),
- extraWarnings_(false)
+ extraWarnings_(false),
+ arrayProtoValues_(true)
{
}
@@ -1223,6 +1224,12 @@ class JS_PUBLIC_API(ContextOptions) {
return *this;
}
+ bool arrayProtoValues() const { return arrayProtoValues_; }
+ ContextOptions& setArrayProtoValues(bool flag) {
+ arrayProtoValues_ = flag;
+ return *this;
+ }
+
private:
bool baseline_ : 1;
bool ion_ : 1;
@@ -1238,6 +1245,7 @@ class JS_PUBLIC_API(ContextOptions) {
bool werror_ : 1;
bool strictMode_ : 1;
bool extraWarnings_ : 1;
+ bool arrayProtoValues_ : 1;
};
JS_PUBLIC_API(ContextOptions&)
diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp
index 9cbeff6a2..7a67c0095 100644
--- a/js/src/jsarray.cpp
+++ b/js/src/jsarray.cpp
@@ -3165,9 +3165,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),
diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp
index 33feb0a54..b17c845bb 100644
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -2936,6 +2936,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;
diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp
index b53914942..cc68c90d5 100644
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -323,6 +323,7 @@ static bool enableNativeRegExp = false;
static bool enableUnboxedArrays = false;
static bool enableSharedMemory = SHARED_MEMORY_DEFAULT;
static bool enableWasmAlwaysBaseline = false;
+static bool enableArrayProtoValues = true;
static bool printTiming = false;
static const char* jsCacheDir = nullptr;
static const char* jsCacheAsmJSPath = nullptr;
@@ -7264,6 +7265,7 @@ SetContextOptions(JSContext* cx, const OptionParser& op)
enableNativeRegExp = !op.getBoolOption("no-native-regexp");
enableUnboxedArrays = op.getBoolOption("unboxed-arrays");
enableWasmAlwaysBaseline = op.getBoolOption("wasm-always-baseline");
+ enableArrayProtoValues = !op.getBoolOption("no-array-proto-values");
JS::ContextOptionsRef(cx).setBaseline(enableBaseline)
.setIon(enableIon)
@@ -7271,7 +7273,8 @@ SetContextOptions(JSContext* cx, const OptionParser& op)
.setWasm(enableWasm)
.setWasmAlwaysBaseline(enableWasmAlwaysBaseline)
.setNativeRegExp(enableNativeRegExp)
- .setUnboxedArrays(enableUnboxedArrays);
+ .setUnboxedArrays(enableUnboxedArrays)
+ .setArrayProtoValues(enableArrayProtoValues);
if (op.getBoolOption("wasm-check-bce"))
jit::JitOptions.wasmAlwaysCheckBounds = true;
@@ -7542,7 +7545,8 @@ SetWorkerContextOptions(JSContext* cx)
.setWasm(enableWasm)
.setWasmAlwaysBaseline(enableWasmAlwaysBaseline)
.setNativeRegExp(enableNativeRegExp)
- .setUnboxedArrays(enableUnboxedArrays);
+ .setUnboxedArrays(enableUnboxedArrays)
+ .setArrayProtoValues(enableArrayProtoValues);
cx->setOffthreadIonCompilationEnabled(offthreadCompilation);
cx->profilingScripts = enableCodeCoverage || enableDisassemblyDumps;
@@ -7715,6 +7719,7 @@ main(int argc, char** argv, char** envp)
|| !op.addBoolOption('\0', "unboxed-arrays", "Allow creating unboxed arrays")
|| !op.addBoolOption('\0', "wasm-always-baseline", "Enable wasm baseline compiler when possible")
|| !op.addBoolOption('\0', "wasm-check-bce", "Always generate wasm bounds check, even redundant ones.")
+ || !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 "
diff --git a/js/xpconnect/src/XPCJSContext.cpp b/js/xpconnect/src/XPCJSContext.cpp
index defd1b785..bedb7c650 100644
--- a/js/xpconnect/src/XPCJSContext.cpp
+++ b/js/xpconnect/src/XPCJSContext.cpp
@@ -1473,6 +1473,8 @@ ReloadPrefsCallback(const char* pref, void* data)
sExtraWarningsForSystemJS = Preferences::GetBool(JS_OPTIONS_DOT_STR "strict.debug");
#endif
+ bool arrayProtoValues = Preferences::GetBool(JS_OPTIONS_DOT_STR "array_prototype_values");
+
JS::ContextOptionsRef(cx).setBaseline(useBaseline)
.setIon(useIon)
.setAsmJS(useAsmJS)
@@ -1484,7 +1486,8 @@ ReloadPrefsCallback(const char* pref, void* data)
.setThrowOnDebuggeeWouldRun(throwOnDebuggeeWouldRun)
.setDumpStackOnDebuggeeWouldRun(dumpStackOnDebuggeeWouldRun)
.setWerror(werror)
- .setExtraWarnings(extraWarnings);
+ .setExtraWarnings(extraWarnings)
+ .setArrayProtoValues(arrayProtoValues);
JS_SetParallelParsingEnabled(cx, parallelParsing);
JS_SetOffthreadIonCompilationEnabled(cx, offthreadIonCompilation);
diff --git a/js/xpconnect/tests/chrome/test_xrayToJS.xul b/js/xpconnect/tests/chrome/test_xrayToJS.xul
index aaacd4d00..ed67a34fe 100644
--- a/js/xpconnect/tests/chrome/test_xrayToJS.xul
+++ b/js/xpconnect/tests/chrome/test_xrayToJS.xul
@@ -198,9 +198,9 @@ 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");
+ // ...nothing now
}
gConstructorProperties['Array'] =
constructorProps(["join", "reverse", "sort", "push", "pop", "shift",
diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js
index 7e0b4dde3..ff47dc8e3 100644
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -1233,6 +1233,8 @@ pref("dom.webcomponents.enabled", false);
pref("dom.webcomponents.customelements.enabled", false);
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);