Remove ensureAuxiliaryContext

https://bugs.webkit.org/show_bug.cgi?id=99975

Patch by Dan Carney <dcarney@google.com> on 2012-10-29
Reviewed by Adam Barth.

Source/WebCore:

Removed auxilliaryContext as use if it is problematic in IDB.

No new tests. No change in functionality.

* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::update):
(WebCore::IDBCursor::setValueReady):
* Modules/indexeddb/IDBCursor.h:
(IDBCursor):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::generateIndexKeysForValue):
(WebCore::IDBObjectStore::put):
(WebCore):
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::onSuccess):
(WebCore::IDBRequest::dispatchEvent):
* bindings/v8/IDBBindingUtilities.cpp:
(WebCore::createIDBKeyFromScriptValueAndKeyPath):
(WebCore::deserializeIDBValue):
(WebCore::injectIDBKeyIntoScriptValue):
* bindings/v8/IDBBindingUtilities.h:
(WebCore):
* bindings/v8/V8Binding.cpp:
(WebCore::toV8Context):
(WebCore):
* bindings/v8/V8Binding.h:
(WebCore):
* bindings/v8/V8PerIsolateData.cpp:
(WebCore):
* bindings/v8/V8PerIsolateData.h:

Source/WebKit/chromium:

Updated tests to use correct v8 context.

* tests/IDBBindingUtilitiesTest.cpp:
(WebKit::checkKeyFromValueAndKeyPathInternal):
(WebKit::checkKeyPathNullValue):
(WebKit::injectKey):
(WebKit::checkInjection):
(WebKit::checkInjectionFails):
(WebKit::checkKeyPathStringValue):
(WebKit::checkKeyPathNumberValue):
(WebKit::scriptExecutionContext):
(WebKit):
(WebKit::TEST):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@132845 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e09f5ef7
2012-10-29 Dan Carney <dcarney@google.com>
Remove ensureAuxiliaryContext
https://bugs.webkit.org/show_bug.cgi?id=99975
Reviewed by Adam Barth.
Removed auxilliaryContext as use if it is problematic in IDB.
No new tests. No change in functionality.
* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::update):
(WebCore::IDBCursor::setValueReady):
* Modules/indexeddb/IDBCursor.h:
(IDBCursor):
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::generateIndexKeysForValue):
(WebCore::IDBObjectStore::put):
(WebCore):
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::onSuccess):
(WebCore::IDBRequest::dispatchEvent):
* bindings/v8/IDBBindingUtilities.cpp:
(WebCore::createIDBKeyFromScriptValueAndKeyPath):
(WebCore::deserializeIDBValue):
(WebCore::injectIDBKeyIntoScriptValue):
* bindings/v8/IDBBindingUtilities.h:
(WebCore):
* bindings/v8/V8Binding.cpp:
(WebCore::toV8Context):
(WebCore):
* bindings/v8/V8Binding.h:
(WebCore):
* bindings/v8/V8PerIsolateData.cpp:
(WebCore):
* bindings/v8/V8PerIsolateData.h:
2012-10-29 Alpha Lam <hclam@chromium.org>
[skia] Handle mask box image.
......@@ -42,6 +42,9 @@
#include "IDBTracing.h"
#include "IDBTransaction.h"
#include "ScriptExecutionContext.h"
#if USE(V8)
#include "V8Binding.h"
#endif
namespace WebCore {
......@@ -76,6 +79,9 @@ IDBRequest::IDBRequest(ScriptExecutionContext* context, PassRefPtr<IDBAny> sourc
, m_pendingCursor(0)
, m_didFireUpgradeNeededEvent(false)
, m_preventPropagation(false)
#if USE(V8)
, m_worldContextHandle(UseCurrentWorld)
#endif
{
if (m_transaction) {
m_transaction->registerRequest(this);
......@@ -284,6 +290,14 @@ void IDBRequest::onSuccess(PassRefPtr<IDBCursorBackendInterface> backend, PassRe
if (!shouldEnqueueEvent())
return;
#if USE(V8)
v8::HandleScope handleScope;
v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_worldContextHandle);
if (context.IsEmpty())
CRASH();
v8::Context::Scope contextScope(context);
#endif
ScriptValue value = deserializeIDBValue(scriptExecutionContext(), serializedValue);
ASSERT(m_cursorType != IDBCursorBackendInterface::InvalidCursorType);
RefPtr<IDBCursor> cursor;
......@@ -340,6 +354,14 @@ void IDBRequest::onSuccess(PassRefPtr<SerializedScriptValue> serializedScriptVal
if (!shouldEnqueueEvent())
return;
#if USE(V8)
v8::HandleScope handleScope;
v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_worldContextHandle);
if (context.IsEmpty())
CRASH();
v8::Context::Scope contextScope(context);
#endif
ScriptValue value = deserializeIDBValue(scriptExecutionContext(), serializedScriptValue);
onSuccessInternal(value);
}
......@@ -363,6 +385,14 @@ void IDBRequest::onSuccess(PassRefPtr<SerializedScriptValue> prpSerializedScript
if (!shouldEnqueueEvent())
return;
#if USE(V8)
v8::HandleScope handleScope;
v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_worldContextHandle);
if (context.IsEmpty())
CRASH();
v8::Context::Scope contextScope(context);
#endif
#ifndef NDEBUG
ASSERT(keyPath == effectiveObjectStore(m_source)->keyPath());
#endif
......@@ -404,6 +434,14 @@ void IDBRequest::onSuccess(PassRefPtr<IDBKey> key, PassRefPtr<IDBKey> primaryKey
if (!shouldEnqueueEvent())
return;
#if USE(V8)
v8::HandleScope handleScope;
v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_worldContextHandle);
if (context.IsEmpty())
CRASH();
v8::Context::Scope contextScope(context);
#endif
ScriptValue value = deserializeIDBValue(scriptExecutionContext(), serializedValue);
ASSERT(m_pendingCursor);
setResultCursor(m_pendingCursor.release(), key, primaryKey, value);
......@@ -449,6 +487,15 @@ bool IDBRequest::dispatchEvent(PassRefPtr<Event> event)
ASSERT(scriptExecutionContext());
ASSERT(event->target() == this);
ASSERT_WITH_MESSAGE(m_readyState < DONE, "When dispatching event %s, m_readyState < DONE(%d), was %d", event->type().string().utf8().data(), DONE, m_readyState);
#if USE(V8)
v8::HandleScope handleScope;
v8::Local<v8::Context> context = toV8Context(scriptExecutionContext(), m_worldContextHandle);
if (context.IsEmpty())
CRASH();
v8::Context::Scope contextScope(context);
#endif
if (event->type() != eventNames().blockedEvent)
m_readyState = DONE;
......
......@@ -42,6 +42,9 @@
#include "IDBCallbacks.h"
#include "IDBCursor.h"
#include "IDBCursorBackendInterface.h"
#if USE(V8)
#include "WorldContextHandle.h"
#endif
namespace WebCore {
......@@ -155,6 +158,9 @@ private:
bool m_preventPropagation;
EventTargetData m_eventTargetData;
#if USE(V8)
WorldContextHandle m_worldContextHandle;
#endif
};
} // namespace WebCore
......
......@@ -179,10 +179,9 @@ static PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(const ScriptValu
IDBKeyPathParseError error;
IDBParseKeyPath(keyPath, keyPathElements, error);
ASSERT(error == IDBKeyPathParseErrorNone);
ASSERT(v8::Context::InContext());
v8::HandleScope handleScope;
v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
v8::Handle<v8::Value> v8Value(value.v8Value());
v8::Handle<v8::Value> v8Key(getNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size()));
if (v8Key.IsEmpty())
......@@ -194,8 +193,10 @@ PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(const ScriptValue& valu
{
IDB_TRACE("createIDBKeyFromScriptValueAndKeyPath");
ASSERT(!keyPath.isNull());
ASSERT(v8::Context::InContext());
v8::HandleScope scope;
v8::HandleScope handleScope;
if (keyPath.type() == IDBKeyPath::ArrayType) {
IDBKey::KeyArray result;
const Vector<String>& array = keyPath.array();
......@@ -212,11 +213,10 @@ PassRefPtr<IDBKey> createIDBKeyFromScriptValueAndKeyPath(const ScriptValue& valu
return createIDBKeyFromScriptValueAndKeyPath(value, keyPath.string());
}
// FIXME: The only reason this exists is because we need a v8::Context and scope inside a timer. Is there a better / more general way to do this?
ScriptValue deserializeIDBValue(ScriptExecutionContext* scriptContext, PassRefPtr<SerializedScriptValue> prpValue)
{
ASSERT(v8::Context::InContext());
v8::HandleScope handleScope;
v8::Context::Scope contextScope(toV8Context(scriptContext, UseCurrentWorld));
RefPtr<SerializedScriptValue> serializedValue = prpValue;
if (serializedValue)
return ScriptValue(serializedValue->deserialize());
......@@ -226,6 +226,7 @@ ScriptValue deserializeIDBValue(ScriptExecutionContext* scriptContext, PassRefPt
bool injectIDBKeyIntoScriptValue(PassRefPtr<IDBKey> key, ScriptValue& value, const IDBKeyPath& keyPath)
{
IDB_TRACE("injectIDBKeyIntoScriptValue");
ASSERT(v8::Context::InContext());
ASSERT(keyPath.type() == IDBKeyPath::StringType);
Vector<String> keyPathElements;
......@@ -237,8 +238,6 @@ bool injectIDBKeyIntoScriptValue(PassRefPtr<IDBKey> key, ScriptValue& value, con
return 0;
v8::HandleScope handleScope;
v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
v8::Handle<v8::Value> v8Value(value.v8Value());
v8::Handle<v8::Value> parent(ensureNthValueOnKeyPath(v8Value, keyPathElements, keyPathElements.size() - 1));
if (parent.IsEmpty())
......@@ -268,9 +267,8 @@ bool canInjectIDBKeyIntoScriptValue(const ScriptValue& scriptValue, const IDBKey
ScriptValue idbKeyToScriptValue(ScriptExecutionContext* scriptContext, PassRefPtr<IDBKey> key)
{
ASSERT(v8::Context::InContext());
v8::HandleScope handleScope;
v8::Context::Scope contextScope(toV8Context(scriptContext, UseCurrentWorld));
v8::Handle<v8::Value> v8Value(toV8(key.get()));
return ScriptValue(v8Value);
}
......
......@@ -132,13 +132,6 @@ void V8PerIsolateData::visitExternalStrings(ExternalStringVisitor* visitor)
}
#endif
v8::Handle<v8::Context> V8PerIsolateData::ensureAuxiliaryContext()
{
if (m_auxiliaryContext.isEmpty())
m_auxiliaryContext.adopt(v8::Context::New());
return m_auxiliaryContext.get();
}
v8::Handle<v8::Value> V8PerIsolateData::constructorOfToString(const v8::Arguments& args)
{
// The DOM constructors' toString functions grab the current toString
......
......@@ -86,7 +86,6 @@ public:
DOMDataList& allStores() { return m_domDataList; }
V8HiddenPropertyName* hiddenPropertyName() { return m_hiddenPropertyName.get(); }
v8::Handle<v8::Context> ensureAuxiliaryContext();
void registerDOMDataStore(DOMDataStore* domDataStore)
{
......
2012-10-29 Dan Carney <dcarney@google.com>
Remove ensureAuxiliaryContext
https://bugs.webkit.org/show_bug.cgi?id=99975
Reviewed by Adam Barth.
Updated tests to use correct v8 context.
* tests/IDBBindingUtilitiesTest.cpp:
(WebKit::checkKeyFromValueAndKeyPathInternal):
(WebKit::checkKeyPathNullValue):
(WebKit::injectKey):
(WebKit::checkInjection):
(WebKit::checkInjectionFails):
(WebKit::checkKeyPathStringValue):
(WebKit::checkKeyPathNumberValue):
(WebKit::scriptExecutionContext):
(WebKit):
(WebKit::TEST):
2012-10-29 Patrick Dubroy <dubroy@chromium.org>
Web Inspector: Style toolbar to match Chromium toolbar on Chromium/Mac.
......
......@@ -24,11 +24,19 @@
*/
#include "config.h"
#include "Document.h"
#include "Frame.h"
#include "FrameTestHelpers.h"
#include "IDBBindingUtilities.h"
#include "IDBKey.h"
#include "IDBKeyPath.h"
#include "V8Binding.h"
#include "V8PerIsolateData.h"
#include "V8Utilities.h"
#include "WebFrame.h"
#include "WebFrameImpl.h"
#include "WebView.h"
#include "WorldContextHandle.h"
#include <gtest/gtest.h>
#include <wtf/Vector.h>
......@@ -36,6 +44,7 @@
#if ENABLE(INDEXED_DATABASE)
using namespace WebCore;
using namespace WebKit;
namespace {
......@@ -90,10 +99,21 @@ void checkKeyPathNumberValue(const ScriptValue& value, const String& keyPath, in
ASSERT_TRUE(expected == idbKey->number());
}
static v8::Handle<v8::Context> context()
{
static WebView* webView;
if (!webView) {
webView = FrameTestHelpers::createWebViewAndLoad("about:blank");
webView->setFocus(true);
}
ScriptExecutionContext* context = static_cast<WebFrameImpl*>(webView->mainFrame())->frame()->document();
return toV8Context(context, WorldContextHandle(UseCurrentWorld));
}
TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue)
{
v8::HandleScope handleScope;
v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
v8::Context::Scope scope(context());
v8::Local<v8::Object> object = v8::Object::New();
object->Set(v8::String::New("foo"), v8::String::New("zoo"));
......@@ -107,7 +127,7 @@ TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyStringValue)
TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue)
{
v8::HandleScope handleScope;
v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
v8::Context::Scope scope(context());
v8::Local<v8::Object> object = v8::Object::New();
object->Set(v8::String::New("foo"), v8::Number::New(456));
......@@ -121,7 +141,7 @@ TEST(IDBKeyFromValueAndKeyPathTest, TopLevelPropertyNumberValue)
TEST(IDBKeyFromValueAndKeyPathTest, SubProperty)
{
v8::HandleScope handleScope;
v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
v8::Context::Scope scope(context());
v8::Local<v8::Object> object = v8::Object::New();
v8::Local<v8::Object> subProperty = v8::Object::New();
......@@ -137,7 +157,7 @@ TEST(IDBKeyFromValueAndKeyPathTest, SubProperty)
TEST(InjectIDBKeyTest, TopLevelPropertyStringValue)
{
v8::HandleScope handleScope;
v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
v8::Context::Scope scope(context());
v8::Local<v8::Object> object = v8::Object::New();
object->Set(v8::String::New("foo"), v8::String::New("zoo"));
......@@ -152,7 +172,7 @@ TEST(InjectIDBKeyTest, TopLevelPropertyStringValue)
TEST(InjectIDBKeyTest, SubProperty)
{
v8::HandleScope handleScope;
v8::Context::Scope scope(V8PerIsolateData::current()->ensureAuxiliaryContext());
v8::Context::Scope scope(context());
v8::Local<v8::Object> object = v8::Object::New();
v8::Local<v8::Object> subProperty = v8::Object::New();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment