summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/ScriptController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/v8/ScriptController.cpp')
-rw-r--r--WebCore/bindings/v8/ScriptController.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp
index 40a71be..ee15eaa 100644
--- a/WebCore/bindings/v8/ScriptController.cpp
+++ b/WebCore/bindings/v8/ScriptController.cpp
@@ -33,7 +33,6 @@
#include "ScriptController.h"
#include "PlatformBridge.h"
-#include "CString.h"
#include "Document.h"
#include "DOMWindow.h"
#include "Event.h"
@@ -48,6 +47,7 @@
#include "NPV8Object.h"
#include "ScriptSourceCode.h"
#include "Settings.h"
+#include "UserGestureIndicator.h"
#include "V8Binding.h"
#include "V8BindingState.h"
#include "V8DOMWindow.h"
@@ -59,6 +59,7 @@
#include "Widget.h"
#include "XSSAuditor.h"
#include <wtf/StdLibExtras.h>
+#include <wtf/text/CString.h>
namespace WebCore {
@@ -153,9 +154,10 @@ void ScriptController::updatePlatformScriptObjects()
bool ScriptController::processingUserGesture(DOMWrapperWorld*) const
{
Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext();
- // No script is running, so it must be run by users.
+ // No script is running, so it is user-initiated unless the gesture stack
+ // explicitly says it is not.
if (!activeFrame)
- return true;
+ return UserGestureIndicator::processingUserGesture();
V8Proxy* activeProxy = activeFrame->script()->proxy();
@@ -176,7 +178,7 @@ bool ScriptController::processingUserGesture(DOMWrapperWorld*) const
// Based on code from kjs_bindings.cpp.
// Note: This is more liberal than Firefox's implementation.
if (event) {
- if (event->createdByDOM())
+ if (!UserGestureIndicator::processingUserGesture())
return false;
const AtomicString& type = event->type();
@@ -190,7 +192,7 @@ bool ScriptController::processingUserGesture(DOMWrapperWorld*) const
if (eventOk)
return true;
- } else if (activeProxy->inlineCode() && !activeProxy->timerCallback()) {
+ } else if (m_sourceURL && m_sourceURL->isNull() && !activeProxy->timerCallback()) {
// This is the <a href="javascript:window.open('...')> case -> we let it through.
return true;
}
@@ -219,7 +221,9 @@ void ScriptController::evaluateInIsolatedWorld(unsigned worldID, const Vector<Sc
ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode)
{
String sourceURL = sourceCode.url();
-
+ const String* savedSourceURL = m_sourceURL;
+ m_sourceURL = &sourceURL;
+
if (!m_XSSAuditor->canEvaluate(sourceCode.source())) {
// This script is not safe to be evaluated.
return ScriptValue();
@@ -237,9 +241,11 @@ ScriptValue ScriptController::evaluate(const ScriptSourceCode& sourceCode)
v8::Local<v8::Value> object = m_proxy->evaluate(sourceCode, 0);
// Evaluating the JavaScript could cause the frame to be deallocated
- // so we starot the keep alive timer here.
+ // so we start the keep alive timer here.
m_frame->keepAlive();
+ m_sourceURL = savedSourceURL;
+
if (object.IsEmpty() || object->IsUndefined())
return ScriptValue();
@@ -402,7 +408,7 @@ NPObject* ScriptController::windowScriptNPObject()
if (m_windowScriptNPObject)
return m_windowScriptNPObject;
- if (canExecuteScripts()) {
+ if (canExecuteScripts(NotAboutToExecuteScript)) {
// JavaScript is enabled, so there is a JavaScript window object.
// Return an NPObject bound to the window object.
m_windowScriptNPObject = createScriptObject(m_frame);
@@ -419,7 +425,7 @@ NPObject* ScriptController::windowScriptNPObject()
NPObject* ScriptController::createScriptObjectForPluginElement(HTMLPlugInElement* plugin)
{
// Can't create NPObjects when JavaScript is disabled.
- if (!canExecuteScripts())
+ if (!canExecuteScripts(NotAboutToExecuteScript))
return createNoScriptObject();
v8::HandleScope handleScope;