зеркало из https://github.com/mozilla/gecko-dev.git
Bug 679939 part 1. Extend the hasRunOnce/treatAsRunOnce setup to global and eval scripts. r=luke
This commit is contained in:
Родитель
55ce94cd12
Коммит
bbd4f124f2
|
@ -611,6 +611,14 @@ js::XDRScript(XDRState<mode>* xdr, HandleObject enclosingScope, HandleScript enc
|
|||
if (mode == XDR_ENCODE) {
|
||||
script = scriptp.get();
|
||||
MOZ_ASSERT_IF(enclosingScript, enclosingScript->compartment() == script->compartment());
|
||||
MOZ_ASSERT(script->functionNonDelazifying() == fun);
|
||||
|
||||
if (!fun && script->treatAsRunOnce() && script->hasRunOnce()) {
|
||||
JS_ReportError(cx,
|
||||
"Can't serialize a run-once non-function script "
|
||||
"that has already run");
|
||||
return false;
|
||||
}
|
||||
|
||||
nargs = script->bindings.numArgs();
|
||||
nblocklocals = script->bindings.numBlockScoped();
|
||||
|
@ -2962,6 +2970,12 @@ js::CloneScript(JSContext* cx, HandleObject enclosingScope, HandleFunction fun,
|
|||
PollutedGlobalScopeOption polluted /* = HasCleanGlobalScope */,
|
||||
NewObjectKind newKind /* = GenericObject */)
|
||||
{
|
||||
if (src->treatAsRunOnce() && !src->functionNonDelazifying()) {
|
||||
// Toplevel run-once scripts may not be cloned.
|
||||
JS_ReportError(cx, "No cloning toplevel run-once scripts");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* NB: Keep this in sync with XDRScript. */
|
||||
|
||||
/* Some embeddings are not careful to use ExposeObjectToActiveJS as needed. */
|
||||
|
|
|
@ -955,7 +955,9 @@ class JSScript : public js::gc::TenuredCell
|
|||
// Script has singleton objects.
|
||||
bool hasSingletons_:1;
|
||||
|
||||
// Script is a lambda to treat as running once.
|
||||
// Script is a lambda to treat as running once or a global or eval script
|
||||
// that will only run once. Which one it is can be disambiguated by
|
||||
// checking whether function_ is null.
|
||||
bool treatAsRunOnce_:1;
|
||||
|
||||
// If treatAsRunOnce, whether script has executed.
|
||||
|
|
Загрузка…
Ссылка в новой задаче