Diff
Modified: trunk/Source/WebCore/ChangeLog (125151 => 125152)
--- trunk/Source/WebCore/ChangeLog 2012-08-09 05:27:30 UTC (rev 125151)
+++ trunk/Source/WebCore/ChangeLog 2012-08-09 05:29:22 UTC (rev 125152)
@@ -1,3 +1,46 @@
+2012-08-08 Sheriff Bot <[email protected]>
+
+ Unreviewed, rolling out r125146.
+ http://trac.webkit.org/changeset/125146
+ https://bugs.webkit.org/show_bug.cgi?id=93578
+
+ Would like to study fast/dom/Window/timer-null-script-
+ execution-context.html behavior change (Requested by abarth on
+ #webkit).
+
+ * bindings/js/JSDOMWindowBase.cpp:
+ (WebCore):
+ (WebCore::JSDOMWindowBase::crossDomainAccessErrorMessage):
+ (WebCore::JSDOMWindowBase::allowsAccessFrom):
+ * bindings/js/JSDOMWindowBase.h:
+ (JSDOMWindowBase):
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::namedItemGetter):
+ (WebCore::JSDOMWindow::getOwnPropertySlot):
+ (WebCore::JSDOMWindow::getOwnPropertyDescriptor):
+ (WebCore::JSDOMWindow::put):
+ (WebCore::JSDOMWindow::deleteProperty):
+ (WebCore::JSDOMWindow::getPropertyNames):
+ (WebCore::JSDOMWindow::getOwnPropertyNames):
+ (WebCore::JSDOMWindow::defineOwnProperty):
+ (WebCore::JSDOMWindow::setLocation):
+ * bindings/js/JSDOMWindowCustom.h:
+ (WebCore::JSDOMWindowBase::allowsAccessFrom):
+ (WebCore):
+ (WebCore::JSDOMWindowBase::allowsAccessFromNoErrorMessage):
+ (WebCore::JSDOMWindowBase::allowsAccessFromPrivate):
+ * bindings/js/JSInjectedScriptManager.cpp:
+ (WebCore::InjectedScriptManager::canAccessInspectedWindow):
+ * bindings/objc/WebScriptObject.mm:
+ (-[WebScriptObject _isSafeScript]):
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateGetOwnPropertyDescriptorBody):
+ (GenerateImplementation):
+ * bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
+ (WebCore::jsTestActiveDOMObjectExcitingAttr):
+ (WebCore::jsTestActiveDOMObjectConstructor):
+ (WebCore::jsTestActiveDOMObjectPrototypeFunctionExcitingFunction):
+
2012-08-05 Kinuko Yasuda <[email protected]>
Unprefix window.webkitURL
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp (125151 => 125152)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp 2012-08-09 05:27:30 UTC (rev 125151)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp 2012-08-09 05:29:22 UTC (rev 125152)
@@ -42,23 +42,9 @@
namespace WebCore {
-// FIXME: This function should call shouldAllowAccessToDocument once there is a predictable
-// way to get a Document* from a DOMWindow*.
-static bool shouldAllowAccessFrom(const JSGlobalObject* thisObject, ExecState* exec)
-{
- DOMWindow* active = activeDOMWindow(exec);
- DOMWindow* target = asJSDOMWindow(thisObject)->impl();
-
- if (active->securityOrigin()->canAccess(target->securityOrigin()))
- return true;
-
- printErrorMessageForFrame(target->frame(), target->crossDomainAccessErrorMessage(active));
- return false;
-}
-
const ClassInfo JSDOMWindowBase::s_info = { "Window", &JSDOMGlobalObject::s_info, 0, 0, CREATE_METHOD_TABLE(JSDOMWindowBase) };
-const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &shouldAllowAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &_javascript_ExperimentsEnabled };
+const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &allowsAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &_javascript_ExperimentsEnabled };
JSDOMWindowBase::JSDOMWindowBase(JSGlobalData& globalData, Structure* structure, PassRefPtr<DOMWindow> window, JSDOMWindowShell* shell)
: JSDOMGlobalObject(globalData, structure, shell->world(), &s_globalObjectMethodTable)
@@ -97,11 +83,41 @@
return m_impl->document();
}
+String JSDOMWindowBase::crossDomainAccessErrorMessage(const JSGlobalObject* other) const
+{
+ return m_shell->window()->impl()->crossDomainAccessErrorMessage(asJSDOMWindow(other)->impl());
+}
+
void JSDOMWindowBase::printErrorMessage(const String& message) const
{
printErrorMessageForFrame(impl()->frame(), message);
}
+// This method checks whether accesss to *this* global object is permitted from
+// the given context; this differs from allowsAccessFromPrivate, since that
+// method checks whether the given context is permitted to access the current
+// window the shell is referencing (which may come from a different security
+// origin to this global object).
+bool JSDOMWindowBase::allowsAccessFrom(const JSGlobalObject* thisObject, ExecState* exec)
+{
+ JSGlobalObject* otherObject = exec->lexicalGlobalObject();
+
+ const JSDOMWindow* originWindow = asJSDOMWindow(otherObject);
+ const JSDOMWindow* targetWindow = asJSDOMWindow(thisObject);
+
+ if (originWindow == targetWindow)
+ return true;
+
+ const SecurityOrigin* originSecurityOrigin = originWindow->impl()->securityOrigin();
+ const SecurityOrigin* targetSecurityOrigin = targetWindow->impl()->securityOrigin();
+
+ if (originSecurityOrigin->canAccess(targetSecurityOrigin))
+ return true;
+
+ targetWindow->printErrorMessage(targetWindow->crossDomainAccessErrorMessage(otherObject));
+ return false;
+}
+
bool JSDOMWindowBase::supportsProfiling(const JSGlobalObject* object)
{
#if !ENABLE(_javascript__DEBUGGER) || !ENABLE(INSPECTOR)
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h (125151 => 125152)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h 2012-08-09 05:27:30 UTC (rev 125151)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowBase.h 2012-08-09 05:29:22 UTC (rev 125152)
@@ -64,8 +64,15 @@
static bool supportsRichSourceInfo(const JSC::JSGlobalObject*);
static bool shouldInterruptScript(const JSC::JSGlobalObject*);
static bool _javascript_ExperimentsEnabled(const JSC::JSGlobalObject*);
+ static bool allowsAccessFrom(const JSC::JSGlobalObject*, JSC::ExecState*);
+
+ bool allowsAccessFrom(JSC::ExecState*) const;
+ bool allowsAccessFromNoErrorMessage(JSC::ExecState*) const;
+ bool allowsAccessFrom(JSC::ExecState*, String& message) const;
+ void printErrorMessage(const String&) const;
- void printErrorMessage(const String&) const;
+ // Don't call this version of allowsAccessFrom -- it's a slightly incorrect implementation used only by WebScriptObject
+ bool allowsAccessFrom(const JSC::JSGlobalObject*) const;
static JSC::JSObject* toThisObject(JSC::JSCell*, JSC::ExecState*);
JSDOMWindowShell* shell() const;
@@ -75,6 +82,9 @@
private:
RefPtr<DOMWindow> m_impl;
JSDOMWindowShell* m_shell;
+
+ bool allowsAccessFromPrivate(const JSC::JSGlobalObject*) const;
+ String crossDomainAccessErrorMessage(const JSC::JSGlobalObject*) const;
};
// Returns a JSDOMWindow or jsNull()
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (125151 => 125152)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp 2012-08-09 05:27:30 UTC (rev 125151)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp 2012-08-09 05:29:22 UTC (rev 125152)
@@ -112,7 +112,7 @@
JSDOMWindowBase* thisObj = jsCast<JSDOMWindow*>(asObject(slotBase));
Document* document = thisObj->impl()->frame()->document();
- ASSERT(shouldAllowAccessToFrame(exec, thisObj->impl()->frame()));
+ ASSERT(thisObj->allowsAccessFrom(exec));
ASSERT(document);
ASSERT(document->isHTMLDocument());
@@ -158,7 +158,7 @@
// because we always allow access to some function, just different ones depending whether access
// is allowed.
String errorMessage;
- bool allowsAccess = shouldAllowAccessToFrame(exec, thisObject->impl()->frame(), errorMessage);
+ bool allowsAccess = thisObject->allowsAccessFrom(exec, errorMessage);
// Look for overrides before looking at any of our own properties, but ignore overrides completely
// if this is cross-domain access.
@@ -166,7 +166,7 @@
return true;
// We need this code here because otherwise JSDOMWindowBase will stop the search before we even get to the
- // prototype due to the blanket same origin check at the end of getOwnPropertySlot.
+ // prototype due to the blanket same origin (allowsAccessFrom) check at the end of getOwnPropertySlot.
// Also, it's important to get the implementation straight out of the DOMWindow prototype regardless of
// what prototype is actually set on this object.
entry = JSDOMWindowPrototype::s_info.propHashTable(exec)->entry(exec, propertyName);
@@ -272,7 +272,7 @@
{
JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object);
// Never allow cross-domain getOwnPropertyDescriptor
- if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
+ if (!thisObject->allowsAccessFrom(exec))
return false;
const HashEntry* entry;
@@ -349,7 +349,7 @@
// Optimization: access _javascript_ global variables directly before involving the DOM.
if (thisObject->JSGlobalObject::hasOwnPropertyForWrite(exec, propertyName)) {
- if (shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
+ if (thisObject->allowsAccessFrom(exec))
JSGlobalObject::put(thisObject, exec, propertyName, value, slot);
return;
}
@@ -357,7 +357,7 @@
if (lookupPut<JSDOMWindow>(exec, propertyName, value, s_info.propHashTable(exec), thisObject))
return;
- if (shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
+ if (thisObject->allowsAccessFrom(exec))
Base::put(thisObject, exec, propertyName, value, slot);
}
@@ -365,7 +365,7 @@
{
JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(cell);
// Only allow deleting properties by frames in the same origin.
- if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
+ if (!thisObject->allowsAccessFrom(exec))
return false;
return Base::deleteProperty(thisObject, exec, propertyName);
}
@@ -374,7 +374,7 @@
{
JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object);
// Only allow the window to enumerated by frames in the same origin.
- if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
+ if (!thisObject->allowsAccessFrom(exec))
return;
Base::getPropertyNames(thisObject, exec, propertyNames, mode);
}
@@ -383,7 +383,7 @@
{
JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object);
// Only allow the window to enumerated by frames in the same origin.
- if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
+ if (!thisObject->allowsAccessFrom(exec))
return;
Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode);
}
@@ -392,7 +392,7 @@
{
JSDOMWindow* thisObject = jsCast<JSDOMWindow*>(object);
// Only allow defining properties in this way by frames in the same origin, as it allows setters to be introduced.
- if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))
+ if (!thisObject->allowsAccessFrom(exec))
return false;
// Don't allow shadowing location using accessor properties.
@@ -412,7 +412,7 @@
if (Frame* activeFrame = activeDOMWindow(exec)->frame()) {
if (Settings* settings = activeFrame->settings()) {
if (settings->usesDashboardBackwardCompatibilityMode() && !activeFrame->tree()->parent()) {
- if (shouldAllowAccessToFrame(exec, impl()->frame()))
+ if (allowsAccessFrom(exec))
putDirect(exec->globalData(), Identifier(exec, "location"), value);
return;
}
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.h (125151 => 125152)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.h 2012-08-09 05:27:30 UTC (rev 125151)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.h 2012-08-09 05:29:22 UTC (rev 125152)
@@ -36,6 +36,49 @@
return static_cast<const JSDOMWindow*>(globalObject);
}
+inline bool JSDOMWindowBase::allowsAccessFrom(const JSGlobalObject* other) const
+{
+ if (allowsAccessFromPrivate(other))
+ return true;
+ printErrorMessage(crossDomainAccessErrorMessage(other));
+ return false;
}
+inline bool JSDOMWindowBase::allowsAccessFrom(JSC::ExecState* exec) const
+{
+ if (allowsAccessFromPrivate(exec->lexicalGlobalObject()))
+ return true;
+ printErrorMessage(crossDomainAccessErrorMessage(exec->lexicalGlobalObject()));
+ return false;
+}
+
+inline bool JSDOMWindowBase::allowsAccessFromNoErrorMessage(JSC::ExecState* exec) const
+{
+ return allowsAccessFromPrivate(exec->lexicalGlobalObject());
+}
+
+inline bool JSDOMWindowBase::allowsAccessFrom(JSC::ExecState* exec, String& message) const
+{
+ if (allowsAccessFromPrivate(exec->lexicalGlobalObject()))
+ return true;
+ message = crossDomainAccessErrorMessage(exec->lexicalGlobalObject());
+ return false;
+}
+
+ALWAYS_INLINE bool JSDOMWindowBase::allowsAccessFromPrivate(const JSGlobalObject* other) const
+{
+ const JSDOMWindow* originWindow = asJSDOMWindow(other);
+ const JSDOMWindow* targetWindow = m_shell->window();
+
+ if (originWindow == targetWindow)
+ return true;
+
+ const SecurityOrigin* originSecurityOrigin = originWindow->impl()->securityOrigin();
+ const SecurityOrigin* targetSecurityOrigin = targetWindow->impl()->securityOrigin();
+
+ return originSecurityOrigin->canAccess(targetSecurityOrigin);
+}
+
+}
+
#endif // JSDOMWindowCustom_h
Modified: trunk/Source/WebCore/bindings/js/JSInjectedScriptManager.cpp (125151 => 125152)
--- trunk/Source/WebCore/bindings/js/JSInjectedScriptManager.cpp 2012-08-09 05:27:30 UTC (rev 125151)
+++ trunk/Source/WebCore/bindings/js/JSInjectedScriptManager.cpp 2012-08-09 05:29:22 UTC (rev 125152)
@@ -36,7 +36,6 @@
#include "InjectedScriptManager.h"
-#include "BindingSecurity.h"
#include "ExceptionCode.h"
#include "JSDOMWindow.h"
#include "JSDOMWindowCustom.h"
@@ -86,7 +85,7 @@
JSDOMWindow* inspectedWindow = toJSDOMWindow(scriptState->lexicalGlobalObject());
if (!inspectedWindow)
return false;
- return BindingSecurity::shouldAllowAccessToFrame(scriptState, inspectedWindow->impl()->frame(), DoNotReportSecurityError);
+ return inspectedWindow->allowsAccessFromNoErrorMessage(scriptState);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/objc/WebScriptObject.mm (125151 => 125152)
--- trunk/Source/WebCore/bindings/objc/WebScriptObject.mm 2012-08-09 05:27:30 UTC (rev 125151)
+++ trunk/Source/WebCore/bindings/objc/WebScriptObject.mm 2012-08-09 05:29:22 UTC (rev 125152)
@@ -241,11 +241,7 @@
if (!_private->originRootObject->isValid())
return false;
- // It's not actually correct to call shouldAllowAccessToFrame in this way because
- // JSDOMWindowBase* isn't the right object to represent the currently executing
- // _javascript_. Instead, we should use ExecState, like we do elsewhere.
- JSDOMWindowBase* target = jsCast<JSDOMWindowBase*>(root->globalObject());
- return shouldAllowAccessToFrame(_private->originRootObject->globalObject()->globalExec(), target->impl()->frame());
+ return jsCast<JSDOMWindowBase*>(root->globalObject())->allowsAccessFrom(_private->originRootObject->globalObject());
}
- (oneway void)release
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (125151 => 125152)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-08-09 05:27:30 UTC (rev 125151)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2012-08-09 05:29:22 UTC (rev 125152)
@@ -485,7 +485,11 @@
my @getOwnPropertyDescriptorImpl = ();
if ($dataNode->extendedAttributes->{"CheckSecurity"}) {
- push(@implContent, " if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))\n");
+ if ($interfaceName eq "DOMWindow") {
+ push(@implContent, " if (!thisObject->allowsAccessFrom(exec))\n");
+ } else {
+ push(@implContent, " if (!shouldAllowAccessToFrame(exec, thisObject->impl()->frame()))\n");
+ }
push(@implContent, " return false;\n");
}
@@ -1776,7 +1780,7 @@
if ($dataNode->extendedAttributes->{"CheckSecurity"} &&
!$attribute->signature->extendedAttributes->{"DoNotCheckSecurity"} &&
!$attribute->signature->extendedAttributes->{"DoNotCheckSecurityOnGetter"}) {
- push(@implContent, " if (!shouldAllowAccessToFrame(exec, castedThis->impl()->frame()))\n");
+ push(@implContent, " if (!castedThis->allowsAccessFrom(exec))\n");
push(@implContent, " return jsUndefined();\n");
}
@@ -1891,7 +1895,7 @@
push(@implContent, " ${className}* domObject = jsCast<$className*>(asObject(slotBase));\n");
if ($dataNode->extendedAttributes->{"CheckSecurity"}) {
- push(@implContent, " if (!shouldAllowAccessToFrame(exec, domObject->impl()->frame()))\n");
+ push(@implContent, " if (!domObject->allowsAccessFrom(exec))\n");
push(@implContent, " return jsUndefined();\n");
}
@@ -1965,7 +1969,11 @@
push(@implContent, " UNUSED_PARAM(exec);\n");
if ($dataNode->extendedAttributes->{"CheckSecurity"} && !$attribute->signature->extendedAttributes->{"DoNotCheckSecurity"}) {
- push(@implContent, " if (!shouldAllowAccessToFrame(exec, jsCast<$className*>(thisObject)->impl()->frame()))\n");
+ if ($interfaceName eq "DOMWindow") {
+ push(@implContent, " if (!jsCast<$className*>(thisObject)->allowsAccessFrom(exec))\n");
+ } else {
+ push(@implContent, " if (!shouldAllowAccessToFrame(exec, jsCast<$className*>(thisObject)->impl()->frame()))\n");
+ }
push(@implContent, " return;\n");
}
@@ -2090,7 +2098,11 @@
push(@implContent, "void ${constructorFunctionName}(ExecState* exec, JSObject* thisObject, JSValue value)\n");
push(@implContent, "{\n");
if ($dataNode->extendedAttributes->{"CheckSecurity"}) {
- push(@implContent, " if (!shouldAllowAccessToFrame(exec, jsCast<$className*>(thisObject)->impl()->frame()))\n");
+ if ($interfaceName eq "DOMWindow") {
+ push(@implContent, " if (!jsCast<$className*>(thisObject)->allowsAccessFrom(exec))\n");
+ } else {
+ push(@implContent, " if (!shouldAllowAccessToFrame(exec, jsCast<$className*>(thisObject)->impl()->frame()))\n");
+ }
push(@implContent, " return;\n");
}
@@ -2194,7 +2206,7 @@
if ($dataNode->extendedAttributes->{"CheckSecurity"} and
!$function->signature->extendedAttributes->{"DoNotCheckSecurity"}) {
- push(@implContent, " if (!shouldAllowAccessToFrame(exec, castedThis->impl()->frame()))\n");
+ push(@implContent, " if (!castedThis->allowsAccessFrom(exec))\n");
push(@implContent, " return JSValue::encode(jsUndefined());\n");
}
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp (125151 => 125152)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp 2012-08-09 05:27:30 UTC (rev 125151)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestActiveDOMObject.cpp 2012-08-09 05:29:22 UTC (rev 125152)
@@ -153,7 +153,7 @@
JSValue jsTestActiveDOMObjectExcitingAttr(ExecState* exec, JSValue slotBase, PropertyName)
{
JSTestActiveDOMObject* castedThis = jsCast<JSTestActiveDOMObject*>(asObject(slotBase));
- if (!shouldAllowAccessToFrame(exec, castedThis->impl()->frame()))
+ if (!castedThis->allowsAccessFrom(exec))
return jsUndefined();
UNUSED_PARAM(exec);
TestActiveDOMObject* impl = static_cast<TestActiveDOMObject*>(castedThis->impl());
@@ -165,7 +165,7 @@
JSValue jsTestActiveDOMObjectConstructor(ExecState* exec, JSValue slotBase, PropertyName)
{
JSTestActiveDOMObject* domObject = jsCast<JSTestActiveDOMObject*>(asObject(slotBase));
- if (!shouldAllowAccessToFrame(exec, domObject->impl()->frame()))
+ if (!domObject->allowsAccessFrom(exec))
return jsUndefined();
return JSTestActiveDOMObject::getConstructor(exec, domObject->globalObject());
}
@@ -182,7 +182,7 @@
return throwVMTypeError(exec);
JSTestActiveDOMObject* castedThis = jsCast<JSTestActiveDOMObject*>(asObject(thisValue));
ASSERT_GC_OBJECT_INHERITS(castedThis, &JSTestActiveDOMObject::s_info);
- if (!shouldAllowAccessToFrame(exec, castedThis->impl()->frame()))
+ if (!castedThis->allowsAccessFrom(exec))
return JSValue::encode(jsUndefined());
TestActiveDOMObject* impl = static_cast<TestActiveDOMObject*>(castedThis->impl());
if (exec->argumentCount() < 1)