Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Unified Diff: Source/bindings/v8/SerializedScriptValue.cpp

Issue 97883002: Remove structured cloning restriction over accessor properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add test for cyclic-via-accessor-property object Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/SerializedScriptValue.cpp
diff --git a/Source/bindings/v8/SerializedScriptValue.cpp b/Source/bindings/v8/SerializedScriptValue.cpp
index 8b47d65f1b4ac16315dba30f39f2737f69804e7d..f067774e36bb9221dced0e7938c974740067e937 100644
--- a/Source/bindings/v8/SerializedScriptValue.cpp
+++ b/Source/bindings/v8/SerializedScriptValue.cpp
@@ -697,7 +697,6 @@ public:
: m_writer(writer)
, m_tryCatch(tryCatch)
, m_depth(0)
- , m_execDepth(0)
, m_status(Success)
, m_nextObjectReference(0)
, m_blobDataHandles(blobDataHandles)
@@ -731,12 +730,9 @@ public:
// Functions used by serialization states.
StateBase* doSerialize(v8::Handle<v8::Value>, StateBase* next);
- // The serializer workhorse, no stack depth check.
- StateBase* doSerializeImpl(v8::Handle<v8::Value>, StateBase* next);
-
StateBase* doSerializeArrayBuffer(v8::Handle<v8::Value> arrayBuffer, StateBase* next)
{
- return doSerializeImpl(arrayBuffer, next);
+ return doSerialize(arrayBuffer, next);
}
StateBase* checkException(StateBase* state)
@@ -835,20 +831,15 @@ private:
, m_index(0)
, m_numSerializedProperties(0)
, m_nameDone(false)
- , m_isSerializingAccessor(false)
{
}
- virtual uint32_t execDepth() const { return m_isSerializingAccessor ? 1 : 0; }
-
protected:
virtual StateBase* objectDone(unsigned numProperties, Serializer&) = 0;
StateBase* serializeProperties(bool ignoreIndexed, Serializer& serializer)
{
- m_isSerializingAccessor = false;
while (m_index < m_propertyNames->Length()) {
- bool isAccessor = false;
if (!m_nameDone) {
v8::Local<v8::Value> propertyName = m_propertyNames->Get(m_index);
if (StateBase* newState = serializer.checkException(this))
@@ -861,9 +852,6 @@ private:
bool hasIndexedProperty = !hasStringProperty && propertyName->IsUint32() && composite()->HasRealIndexedProperty(propertyName->Uint32Value());
if (StateBase* newState = serializer.checkException(this))
return newState;
- isAccessor = hasStringProperty && composite()->HasRealNamedCallbackProperty(propertyName.As<v8::String>());
- if (StateBase* newState = serializer.checkException(this))
- return newState;
if (hasStringProperty || (hasIndexedProperty && !ignoreIndexed))
m_propertyName = propertyName;
else {
@@ -884,15 +872,11 @@ private:
m_propertyName.Clear();
++m_index;
++m_numSerializedProperties;
- m_isSerializingAccessor = isAccessor;
// If we return early here, it's either because we have pushed a new state onto the
// serialization state stack or because we have encountered an error (and in both cases
- // we are unwinding the native stack). We reset m_isSerializingAccessor at the beginning
- // of advance() for this case (because advance() will be called on us again once we
- // are the top of the stack).
+ // we are unwinding the native stack).
if (StateBase* newState = serializer.doSerialize(value, this))
return newState;
- m_isSerializingAccessor = false;
}
return objectDone(m_numSerializedProperties, serializer);
}
@@ -904,9 +888,6 @@ private:
unsigned m_index;
unsigned m_numSerializedProperties;
bool m_nameDone;
- // Used along with execDepth() to determine the number of
- // accessors under which the serializer is currently serializing.
- bool m_isSerializingAccessor;
};
class ObjectState : public AbstractObjectState {
@@ -992,8 +973,6 @@ private:
StateBase* push(StateBase* state)
{
ASSERT(state);
- if (state->nextState())
- m_execDepth += state->nextState()->execDepth();
++m_depth;
return checkComposite(state) ? state : handleError(InputError, state);
}
@@ -1003,8 +982,6 @@ private:
ASSERT(state);
--m_depth;
StateBase* next = state->nextState();
- if (next)
- m_execDepth -= next->execDepth();
delete state;
return next;
}
@@ -1017,8 +994,6 @@ private:
StateBase* tmp = state->nextState();
delete state;
state = tmp;
- if (state)
- m_execDepth -= state->execDepth();
}
return new ErrorState;
}
@@ -1217,7 +1192,6 @@ private:
Writer& m_writer;
v8::TryCatch& m_tryCatch;
int m_depth;
- int m_execDepth;
Status m_status;
typedef V8ObjectMap<v8::Object, uint32_t> ObjectPool;
ObjectPool m_objectPool;
@@ -1228,7 +1202,7 @@ private:
v8::Isolate* m_isolate;
};
-Serializer::StateBase* Serializer::doSerializeImpl(v8::Handle<v8::Value> value, StateBase* next)
+Serializer::StateBase* Serializer::doSerialize(v8::Handle<v8::Value> value, StateBase* next)
{
m_writer.writeReferenceCount(m_nextObjectReference);
uint32_t objectReference;
@@ -1307,15 +1281,6 @@ Serializer::StateBase* Serializer::doSerializeImpl(v8::Handle<v8::Value> value,
return 0;
}
-Serializer::StateBase* Serializer::doSerialize(v8::Handle<v8::Value> value, StateBase* next)
-{
- if (m_execDepth + (next ? next->execDepth() : 0) > 1) {
- m_writer.writeNull();
- return 0;
- }
- return doSerializeImpl(value, next);
-}
-
// Interface used by Reader to create objects of composite types.
class CompositeCreator {
public:
« no previous file with comments | « LayoutTests/fast/dom/Window/window-postmessage-clone-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698