| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 if (context.IsEmpty()) | 565 if (context.IsEmpty()) |
| 566 return v8::Local<v8::Value>(); | 566 return v8::Local<v8::Value>(); |
| 567 | 567 |
| 568 ScriptState* scriptState = ScriptState::from(context); | 568 ScriptState* scriptState = ScriptState::from(context); |
| 569 ScriptState::Scope scope(scriptState); | 569 ScriptState::Scope scope(scriptState); |
| 570 | 570 |
| 571 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); | 571 RefPtrWillBeRawPtr<LocalFrame> protect(frame()); |
| 572 if (frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument()) | 572 if (frame()->loader().stateMachine()->isDisplayingInitialEmptyDocument()) |
| 573 frame()->loader().didAccessInitialDocument(); | 573 frame()->loader().didAccessInitialDocument(); |
| 574 | 574 |
| 575 OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentatio
n::preprocess(frame(), sourceCode); | 575 ScriptSourceCode maybeProcessedSourceCode = InspectorInstrumentation::prepro
cess(frame(), sourceCode); |
| 576 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *ma
ybeProcessedSourceCode : sourceCode; | 576 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode.isNul
l() ? sourceCode : maybeProcessedSourceCode; |
| 577 | 577 |
| 578 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte
xt(), sourceCodeToCompile, corsStatus, compilationFinishTime); | 578 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte
xt(), sourceCodeToCompile, corsStatus, compilationFinishTime); |
| 579 m_sourceURL = savedSourceURL; | 579 m_sourceURL = savedSourceURL; |
| 580 | 580 |
| 581 if (object.IsEmpty()) | 581 if (object.IsEmpty()) |
| 582 return v8::Local<v8::Value>(); | 582 return v8::Local<v8::Value>(); |
| 583 | 583 |
| 584 return handleScope.Escape(object); | 584 return handleScope.Escape(object); |
| 585 } | 585 } |
| 586 | 586 |
| 587 void ScriptController::executeScriptInIsolatedWorld(int worldID, const Vector<Sc
riptSourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Value> >* res
ults) | 587 void ScriptController::executeScriptInIsolatedWorld(int worldID, const WillBeHea
pVector<ScriptSourceCode>& sources, int extensionGroup, Vector<v8::Local<v8::Val
ue> >* results) |
| 588 { | 588 { |
| 589 ASSERT(worldID > 0); | 589 ASSERT(worldID > 0); |
| 590 | 590 |
| 591 RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(isolate
(), worldID, extensionGroup); | 591 RefPtr<DOMWrapperWorld> world = DOMWrapperWorld::ensureIsolatedWorld(isolate
(), worldID, extensionGroup); |
| 592 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); | 592 WindowProxy* isolatedWorldWindowProxy = windowProxy(*world); |
| 593 if (!isolatedWorldWindowProxy->isContextInitialized()) | 593 if (!isolatedWorldWindowProxy->isContextInitialized()) |
| 594 return; | 594 return; |
| 595 | 595 |
| 596 ScriptState* scriptState = isolatedWorldWindowProxy->scriptState(); | 596 ScriptState* scriptState = isolatedWorldWindowProxy->scriptState(); |
| 597 v8::Context::Scope scope(scriptState->context()); | 597 v8::Context::Scope scope(scriptState->context()); |
| 598 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size())
; | 598 v8::Local<v8::Array> resultArray = v8::Array::New(isolate(), sources.size())
; |
| 599 | 599 |
| 600 for (size_t i = 0; i < sources.size(); ++i) { | 600 for (size_t i = 0; i < sources.size(); ++i) { |
| 601 v8::Local<v8::Value> evaluationResult = executeScriptAndReturnValue(scri
ptState->context(), sources[i]); | 601 v8::Local<v8::Value> evaluationResult = executeScriptAndReturnValue(scri
ptState->context(), sources[i]); |
| 602 if (evaluationResult.IsEmpty()) | 602 if (evaluationResult.IsEmpty()) |
| 603 evaluationResult = v8::Local<v8::Value>::New(isolate(), v8::Undefine
d(isolate())); | 603 evaluationResult = v8::Local<v8::Value>::New(isolate(), v8::Undefine
d(isolate())); |
| 604 resultArray->Set(i, evaluationResult); | 604 resultArray->Set(i, evaluationResult); |
| 605 } | 605 } |
| 606 | 606 |
| 607 if (results) { | 607 if (results) { |
| 608 for (size_t i = 0; i < resultArray->Length(); ++i) | 608 for (size_t i = 0; i < resultArray->Length(); ++i) |
| 609 results->append(resultArray->Get(i)); | 609 results->append(resultArray->Get(i)); |
| 610 } | 610 } |
| 611 } | 611 } |
| 612 | 612 |
| 613 } // namespace blink | 613 } // namespace blink |
| OLD | NEW |