summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-07-13 23:21:45 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-07-18 22:38:43 -0400
commit03df00e45ff4dd24b739a973d56edaf800313f7f (patch)
tree6a4c7c095ebf12b42099f7e9ed20fcc209ccfc4c /js
parentfe80b3d80d20241ff03338de4351d580796fd2c7 (diff)
downloadUXP-03df00e45ff4dd24b739a973d56edaf800313f7f.tar
UXP-03df00e45ff4dd24b739a973d56edaf800313f7f.tar.gz
UXP-03df00e45ff4dd24b739a973d56edaf800313f7f.tar.lz
UXP-03df00e45ff4dd24b739a973d56edaf800313f7f.tar.xz
UXP-03df00e45ff4dd24b739a973d56edaf800313f7f.zip
1367204 - Generate "[sourceless code]" for class constructors when sourceIsLazy and no source hook is set.
Diffstat (limited to 'js')
-rw-r--r--js/src/jsfun.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp
index 06dc40162..9edf238ef 100644
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -1013,7 +1013,20 @@ js::FunctionToString(JSContext* cx, HandleFunction fun, bool prettyPrint)
if (!out.append(")"))
return nullptr;
}
- } else if (fun->isInterpreted() && !fun->isSelfHostedBuiltin()) {
+ } else if (fun->isInterpreted() &&
+ (!fun->isSelfHostedBuiltin() ||
+ fun->infallibleIsDefaultClassConstructor(cx)))
+ {
+ // Default class constructors should always haveSource except;
+ //
+ // 1. Source has been discarded for the whole compartment.
+ //
+ // 2. The source is marked as "lazy", i.e., retrieved on demand, and
+ // the embedding has not provided a hook to retrieve sources.
+ MOZ_ASSERT_IF(fun->infallibleIsDefaultClassConstructor(cx),
+ !cx->runtime()->sourceHook ||
+ !script->scriptSource()->sourceRetrievable() ||
+ fun->compartment()->behaviors().discardSource());
if (!AppendPrelude() ||
!out.append("() {\n ") ||
!out.append("[sourceless code]") ||
@@ -1022,10 +1035,6 @@ js::FunctionToString(JSContext* cx, HandleFunction fun, bool prettyPrint)
return nullptr;
}
} else {
- // Default class constructors should always haveSource unless source
- // has been discarded for the whole compartment.
- MOZ_ASSERT(!fun->infallibleIsDefaultClassConstructor(cx) ||
- fun->compartment()->behaviors().discardSource());
if (!AppendPrelude() ||
!out.append("() {\n "))