1359622 - Fix assert for calling Function.toString on class constructors when the compartment has had source discarded.

This commit is contained in:
Gaming4JC 2019-07-13 23:12:12 -04:00 • committed by Roy Tam
commit 6d7cc2b0ab
2 changed files with 8 additions and 2 deletions

View file

@ -0,0 +1,4 @@
setDiscardSource(true)
evaluate(`
unescape(class get { static staticMethod() {} });
`);

View file

@ -1022,8 +1022,10 @@ js::FunctionToString(JSContext* cx, HandleFunction fun, bool prettyPrint)
return nullptr; return nullptr;
} }
} else { } else {
// Default class constructors should always haveSource. // Default class constructors should always haveSource unless source
MOZ_ASSERT(!fun->infallibleIsDefaultClassConstructor(cx)); // has been discarded for the whole compartment.
MOZ_ASSERT(!fun->infallibleIsDefaultClassConstructor(cx) ||
fun->compartment()->behaviors().discardSource());
if (!AppendPrelude() || if (!AppendPrelude() ||
!out.append("() {\n ")) !out.append("() {\n "))