v8::Local<v8::Array> V8Proxy::evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup) { // FIXME: This will need to get reorganized once we have a windowShell for the isolated world. if (!windowShell()->initContextIfNeeded()) return v8::Local<v8::Array>(); v8::HandleScope handleScope; V8IsolatedContext* isolatedContext = 0; if (worldID > 0) { IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(worldID); if (iter != m_isolatedWorlds.end()) { isolatedContext = iter->second; } else { isolatedContext = new V8IsolatedContext(this, extensionGroup, worldID); if (isolatedContext->context().IsEmpty()) { delete isolatedContext; return v8::Local<v8::Array>(); } // FIXME: We should change this to using window shells to match JSC. m_isolatedWorlds.set(worldID, isolatedContext); } IsolatedWorldSecurityOriginMap::iterator securityOriginIter = m_isolatedWorldSecurityOrigins.find(worldID); if (securityOriginIter != m_isolatedWorldSecurityOrigins.end()) isolatedContext->setSecurityOrigin(securityOriginIter->second); } else { isolatedContext = new V8IsolatedContext(this, extensionGroup, worldID); if (isolatedContext->context().IsEmpty()) { delete isolatedContext; return v8::Local<v8::Array>(); } } v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolatedContext->context()); v8::Context::Scope context_scope(context); v8::Local<v8::Array> results = v8::Array::New(sources.size()); for (size_t i = 0; i < sources.size(); ++i) { v8::Local<v8::Value> evaluationResult = evaluate(sources[i], 0); if (evaluationResult.IsEmpty()) evaluationResult = v8::Local<v8::Value>::New(v8::Undefined()); results->Set(i, evaluationResult); } if (worldID == 0) isolatedContext->destroy(); return handleScope.Close(results); }
void V8Proxy::evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup) { // FIXME: This will need to get reorganized once we have a windowShell for the isolated world. windowShell()->initContextIfNeeded(); v8::HandleScope handleScope; V8IsolatedContext* isolatedContext = 0; if (worldID > 0) { IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(worldID); if (iter != m_isolatedWorlds.end()) { isolatedContext = iter->second; } else { isolatedContext = new V8IsolatedContext(this, extensionGroup); if (isolatedContext->context().IsEmpty()) { delete isolatedContext; return; } // FIXME: We should change this to using window shells to match JSC. m_isolatedWorlds.set(worldID, isolatedContext); // Setup context id for JS debugger. if (!setInjectedScriptContextDebugId(isolatedContext->context())) { m_isolatedWorlds.take(worldID); delete isolatedContext; return; } } } else { isolatedContext = new V8IsolatedContext(this, extensionGroup); if (isolatedContext->context().IsEmpty()) { delete isolatedContext; return; } } v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolatedContext->context()); v8::Context::Scope context_scope(context); for (size_t i = 0; i < sources.size(); ++i) evaluate(sources[i], 0); if (worldID == 0) isolatedContext->destroy(); }