| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2009 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. | 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
| 8 * met: | 8 * met: |
| 9 * | 9 * |
| 10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 void ScriptController::executeScriptInIsolatedWorld( | 465 void ScriptController::executeScriptInIsolatedWorld( |
| 466 int worldID, | 466 int worldID, |
| 467 const HeapVector<ScriptSourceCode>& sources, | 467 const HeapVector<ScriptSourceCode>& sources, |
| 468 int extensionGroup, | 468 int extensionGroup, |
| 469 Vector<v8::Local<v8::Value>>* results) { | 469 Vector<v8::Local<v8::Value>>* results) { |
| 470 ASSERT(worldID > 0); | 470 ASSERT(worldID > 0); |
| 471 | 471 |
| 472 RefPtr<DOMWrapperWorld> world = | 472 RefPtr<DOMWrapperWorld> world = |
| 473 DOMWrapperWorld::ensureIsolatedWorld(isolate(), worldID, extensionGroup); | 473 DOMWrapperWorld::ensureIsolatedWorld(isolate(), worldID, extensionGroup); |
| 474 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); | 474 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); |
| 475 if (!isolatedWorldWindowProxy->isContextInitialized()) | 475 ScriptState* scriptState = isolatedWorldWindowProxy->getScriptState(); |
| 476 if (!scriptState->contextIsValid()) |
| 476 return; | 477 return; |
| 477 | |
| 478 ScriptState* scriptState = isolatedWorldWindowProxy->getScriptState(); | |
| 479 v8::Context::Scope scope(scriptState->context()); | 478 v8::Context::Scope scope(scriptState->context()); |
| 480 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size()); | 479 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size()); |
| 481 | 480 |
| 482 for (size_t i = 0; i < sources.size(); ++i) { | 481 for (size_t i = 0; i < sources.size(); ++i) { |
| 483 v8::Local<v8::Value> evaluationResult = | 482 v8::Local<v8::Value> evaluationResult = |
| 484 executeScriptAndReturnValue(scriptState->context(), sources[i]); | 483 executeScriptAndReturnValue(scriptState->context(), sources[i]); |
| 485 if (evaluationResult.IsEmpty()) | 484 if (evaluationResult.IsEmpty()) |
| 486 evaluationResult = | 485 evaluationResult = |
| 487 v8::Local<v8::Value>::New(isolate(), v8::Undefined(isolate())); | 486 v8::Local<v8::Value>::New(isolate(), v8::Undefined(isolate())); |
| 488 if (!v8CallBoolean(resultArray->CreateDataProperty(scriptState->context(), | 487 if (!v8CallBoolean(resultArray->CreateDataProperty(scriptState->context(), |
| 489 i, evaluationResult))) | 488 i, evaluationResult))) |
| 490 return; | 489 return; |
| 491 } | 490 } |
| 492 | 491 |
| 493 if (results) { | 492 if (results) { |
| 494 for (size_t i = 0; i < resultArray->Length(); ++i) { | 493 for (size_t i = 0; i < resultArray->Length(); ++i) { |
| 495 v8::Local<v8::Value> value; | 494 v8::Local<v8::Value> value; |
| 496 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) | 495 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) |
| 497 return; | 496 return; |
| 498 results->push_back(value); | 497 results->push_back(value); |
| 499 } | 498 } |
| 500 } | 499 } |
| 501 } | 500 } |
| 502 | 501 |
| 503 } // namespace blink | 502 } // namespace blink |
| OLD | NEW |