Clone InitAttributes for serialization test

Commit 8b11f6a151 requires InitAttributes to be available, which isn't
the case for the secondary context in serialization test. So clone
InitAttributes to make it available.

```
ERROR: JavaScript error: simulation/helpers/Commands.js line 89
InitAttributes is not defined
  reveal-map@simulation/helpers/Commands.js:89:7
  ProcessCommand@simulation/helpers/Commands.js:932:23
ERROR: Failed to call ProcessCommand() global script function
```

Reported-by: phosit <phosit@autistici.org>
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
Ralph Sennhauser
2025-08-29 06:33:56 +02:00
parent 3592814aa8
commit 4136b2f6f7
+7
View File
@@ -430,6 +430,13 @@ void CSimulation2Impl::Update(int turnLength, const std::vector<SimulationComman
ScriptRequest rq(scriptInterface);
// Clone InitAttributes.
{
const ScriptRequest rq2(m_SecondaryComponentManager->GetScriptInterface());
const JS::RootedValue initAttributesCloned(rq2.cx, Script::CloneValueFromOtherCompartment(m_SecondaryComponentManager->GetScriptInterface(), scriptInterface, m_InitAttributes));
m_SecondaryComponentManager->GetScriptInterface().SetGlobal("InitAttributes", initAttributesCloned, true, true, true);
}
// Load the trigger scripts after we have loaded the simulation.
{
ScriptRequest rq2(m_SecondaryComponentManager->GetScriptInterface());