| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 135 } |
| 136 | 136 |
| 137 void ScriptController::updateSecurityOrigin(SecurityOrigin* origin) | 137 void ScriptController::updateSecurityOrigin(SecurityOrigin* origin) |
| 138 { | 138 { |
| 139 m_windowProxy->updateSecurityOrigin(origin); | 139 m_windowProxy->updateSecurityOrigin(origin); |
| 140 } | 140 } |
| 141 | 141 |
| 142 v8::Local<v8::Value> ScriptController::callFunction(v8::Handle<v8::Function> fun
ction, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[]) | 142 v8::Local<v8::Value> ScriptController::callFunction(v8::Handle<v8::Function> fun
ction, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[]) |
| 143 { | 143 { |
| 144 // Keep LocalFrame (and therefore ScriptController) alive. | 144 // Keep LocalFrame (and therefore ScriptController) alive. |
| 145 RefPtr<LocalFrame> protect(m_frame); | 145 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame); |
| 146 return ScriptController::callFunction(m_frame->document(), function, receive
r, argc, info, m_isolate); | 146 return ScriptController::callFunction(m_frame->document(), function, receive
r, argc, info, m_isolate); |
| 147 } | 147 } |
| 148 | 148 |
| 149 v8::Local<v8::Value> ScriptController::callFunction(ExecutionContext* context, v
8::Handle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::
Handle<v8::Value> info[], v8::Isolate* isolate) | 149 v8::Local<v8::Value> ScriptController::callFunction(ExecutionContext* context, v
8::Handle<v8::Function> function, v8::Handle<v8::Value> receiver, int argc, v8::
Handle<v8::Value> info[], v8::Isolate* isolate) |
| 150 { | 150 { |
| 151 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FunctionCall",
"data", devToolsTraceEventData(context, function, isolate)); | 151 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "FunctionCall",
"data", devToolsTraceEventData(context, function, isolate)); |
| 152 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "
CallStack", "stack", InspectorCallStackEvent::currentCallStack()); | 152 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), "
CallStack", "stack", InspectorCallStackEvent::currentCallStack()); |
| 153 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. | 153 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli
ne migrates to tracing. |
| 154 InspectorInstrumentationCookie cookie; | 154 InspectorInstrumentationCookie cookie; |
| 155 if (InspectorInstrumentation::timelineAgentEnabled(context)) { | 155 if (InspectorInstrumentation::timelineAgentEnabled(context)) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 185 // from here. | 185 // from here. |
| 186 v8::TryCatch tryCatch; | 186 v8::TryCatch tryCatch; |
| 187 tryCatch.SetVerbose(true); | 187 tryCatch.SetVerbose(true); |
| 188 | 188 |
| 189 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(source, m_
isolate, corsStatus, v8CacheOptions); | 189 v8::Handle<v8::Script> script = V8ScriptRunner::compileScript(source, m_
isolate, corsStatus, v8CacheOptions); |
| 190 | 190 |
| 191 if (compilationFinishTime) { | 191 if (compilationFinishTime) { |
| 192 *compilationFinishTime = WTF::monotonicallyIncreasingTime(); | 192 *compilationFinishTime = WTF::monotonicallyIncreasingTime(); |
| 193 } | 193 } |
| 194 // Keep LocalFrame (and therefore ScriptController) alive. | 194 // Keep LocalFrame (and therefore ScriptController) alive. |
| 195 RefPtr<LocalFrame> protect(m_frame); | 195 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame); |
| 196 result = V8ScriptRunner::runCompiledScript(script, m_frame->document(),
m_isolate); | 196 result = V8ScriptRunner::runCompiledScript(script, m_frame->document(),
m_isolate); |
| 197 ASSERT(!tryCatch.HasCaught() || result.IsEmpty()); | 197 ASSERT(!tryCatch.HasCaught() || result.IsEmpty()); |
| 198 } | 198 } |
| 199 | 199 |
| 200 InspectorInstrumentation::didEvaluateScript(cookie); | 200 InspectorInstrumentation::didEvaluateScript(cookie); |
| 201 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", "data", InspectorUpdateCountersEvent::data()); | 201 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", "data", InspectorUpdateCountersEvent::data()); |
| 202 | 202 |
| 203 return result; | 203 return result; |
| 204 } | 204 } |
| 205 | 205 |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 { | 530 { |
| 531 if (!protocolIsJavaScript(url)) | 531 if (!protocolIsJavaScript(url)) |
| 532 return false; | 532 return false; |
| 533 | 533 |
| 534 if (!m_frame->page() | 534 if (!m_frame->page() |
| 535 || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_
frame->document()->url(), eventHandlerPosition().m_line)) | 535 || !m_frame->document()->contentSecurityPolicy()->allowJavaScriptURLs(m_
frame->document()->url(), eventHandlerPosition().m_line)) |
| 536 return true; | 536 return true; |
| 537 | 537 |
| 538 // We need to hold onto the LocalFrame here because executing script can | 538 // We need to hold onto the LocalFrame here because executing script can |
| 539 // destroy the frame. | 539 // destroy the frame. |
| 540 RefPtr<LocalFrame> protector(m_frame); | 540 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame); |
| 541 RefPtrWillBeRawPtr<Document> ownerDocument(m_frame->document()); | 541 RefPtrWillBeRawPtr<Document> ownerDocument(m_frame->document()); |
| 542 | 542 |
| 543 const int javascriptSchemeLength = sizeof("javascript:") - 1; | 543 const int javascriptSchemeLength = sizeof("javascript:") - 1; |
| 544 | 544 |
| 545 bool locationChangeBefore = m_frame->navigationScheduler().locationChangePen
ding(); | 545 bool locationChangeBefore = m_frame->navigationScheduler().locationChangePen
ding(); |
| 546 | 546 |
| 547 String decodedURL = decodeURLEscapeSequences(url.string()); | 547 String decodedURL = decodeURLEscapeSequences(url.string()); |
| 548 v8::HandleScope handleScope(m_isolate); | 548 v8::HandleScope handleScope(m_isolate); |
| 549 v8::Local<v8::Value> result = evaluateScriptInMainWorld(ScriptSourceCode(dec
odedURL.substring(javascriptSchemeLength)), NotSharableCrossOrigin, DoNotExecute
ScriptWhenScriptsDisabled); | 549 v8::Local<v8::Value> result = evaluateScriptInMainWorld(ScriptSourceCode(dec
odedURL.substring(javascriptSchemeLength)), NotSharableCrossOrigin, DoNotExecute
ScriptWhenScriptsDisabled); |
| 550 | 550 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 m_sourceURL = &sourceURL; | 593 m_sourceURL = &sourceURL; |
| 594 | 594 |
| 595 v8::EscapableHandleScope handleScope(m_isolate); | 595 v8::EscapableHandleScope handleScope(m_isolate); |
| 596 v8::Handle<v8::Context> context = toV8Context(m_frame, DOMWrapperWorld::main
World()); | 596 v8::Handle<v8::Context> context = toV8Context(m_frame, DOMWrapperWorld::main
World()); |
| 597 if (context.IsEmpty()) | 597 if (context.IsEmpty()) |
| 598 return v8::Local<v8::Value>(); | 598 return v8::Local<v8::Value>(); |
| 599 | 599 |
| 600 ScriptState* scriptState = ScriptState::from(context); | 600 ScriptState* scriptState = ScriptState::from(context); |
| 601 ScriptState::Scope scope(scriptState); | 601 ScriptState::Scope scope(scriptState); |
| 602 | 602 |
| 603 RefPtr<LocalFrame> protect(m_frame); | 603 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame); |
| 604 if (m_frame->loader().stateMachine()->isDisplayingInitialEmptyDocument()) | 604 if (m_frame->loader().stateMachine()->isDisplayingInitialEmptyDocument()) |
| 605 m_frame->loader().didAccessInitialDocument(); | 605 m_frame->loader().didAccessInitialDocument(); |
| 606 | 606 |
| 607 OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentatio
n::preprocess(m_frame, sourceCode); | 607 OwnPtr<ScriptSourceCode> maybeProcessedSourceCode = InspectorInstrumentatio
n::preprocess(m_frame, sourceCode); |
| 608 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *ma
ybeProcessedSourceCode : sourceCode; | 608 const ScriptSourceCode& sourceCodeToCompile = maybeProcessedSourceCode ? *ma
ybeProcessedSourceCode : sourceCode; |
| 609 | 609 |
| 610 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte
xt(), sourceCodeToCompile, corsStatus, compilationFinishTime); | 610 v8::Local<v8::Value> object = executeScriptAndReturnValue(scriptState->conte
xt(), sourceCodeToCompile, corsStatus, compilationFinishTime); |
| 611 m_sourceURL = savedSourceURL; | 611 m_sourceURL = savedSourceURL; |
| 612 | 612 |
| 613 if (object.IsEmpty()) | 613 if (object.IsEmpty()) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 637 resultArray->Set(i, evaluationResult); | 637 resultArray->Set(i, evaluationResult); |
| 638 } | 638 } |
| 639 | 639 |
| 640 if (results) { | 640 if (results) { |
| 641 for (size_t i = 0; i < resultArray->Length(); ++i) | 641 for (size_t i = 0; i < resultArray->Length(); ++i) |
| 642 results->append(handleScope.Escape(resultArray->Get(i))); | 642 results->append(handleScope.Escape(resultArray->Get(i))); |
| 643 } | 643 } |
| 644 } | 644 } |
| 645 | 645 |
| 646 } // namespace blink | 646 } // namespace blink |
| OLD | NEW |