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

Unified Diff: ppapi/proxy/raw_var_data_unittest.cc

Issue 16140011: Don't send PP_Vars/V8 values with cycles across PostMessage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months 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
Index: ppapi/proxy/raw_var_data_unittest.cc
diff --git a/ppapi/proxy/raw_var_data_unittest.cc b/ppapi/proxy/raw_var_data_unittest.cc
index 2b134af1d840788038c6d2af9629d6125e2ff1c3..ee2c95d72f778aeea5e0048598fa3f5933eb54dd 100644
--- a/ppapi/proxy/raw_var_data_unittest.cc
+++ b/ppapi/proxy/raw_var_data_unittest.cc
@@ -44,21 +44,28 @@ class RawVarDataTest : public testing::Test {
TestGlobals globals_;
};
-PP_Var WriteAndRead(const PP_Var& var) {
+bool WriteAndRead(const PP_Var& var, PP_Var* result) {
PP_Instance dummy_instance = 1234;
scoped_ptr<RawVarDataGraph> expected_data(RawVarDataGraph::Create(
var, dummy_instance));
+ if (!expected_data)
+ return false;
IPC::Message m;
expected_data->Write(&m);
PickleIterator iter(m);
scoped_ptr<RawVarDataGraph> actual_data(RawVarDataGraph::Read(&m, &iter));
- return actual_data->CreatePPVar(dummy_instance);
+ *result = actual_data->CreatePPVar(dummy_instance);
+ return true;
}
// Assumes a ref for var.
bool WriteReadAndCompare(const PP_Var& var) {
ScopedPPVar expected(ScopedPPVar::PassRef(), var);
- ScopedPPVar actual(ScopedPPVar::PassRef(), WriteAndRead(expected.get()));
+ PP_Var result;
+ bool success = WriteAndRead(expected.get(), &result);
+ if (!success)
+ return false;
+ ScopedPPVar actual(ScopedPPVar::PassRef(), result);
return TestEqual(expected.get(), actual.get());
}
@@ -160,25 +167,18 @@ TEST_F(RawVarDataTest, DictionaryArrayTest) {
// Array <-> dictionary cycle.
dictionary->SetWithStringKey("10", release_array.get());
- ScopedPPVar result = ScopedPPVar(ScopedPPVar::PassRef(),
- WriteAndRead(release_dictionary.get()));
- EXPECT_TRUE(TestEqual(release_dictionary.get(), result.get()));
+ PP_Var result;
+ ASSERT_FALSE(WriteAndRead(release_dictionary.get(), &result));
// Break the cycle.
// TODO(raymes): We need some better machinery for releasing vars with
// cycles. Remove the code below once we have that.
dictionary->DeleteWithStringKey("10");
- DictionaryVar* result_dictionary = DictionaryVar::FromPPVar(result.get());
- result_dictionary->DeleteWithStringKey("10");
// Array with self references.
array->Set(index, release_array.get());
- result = ScopedPPVar(ScopedPPVar::PassRef(),
- WriteAndRead(release_array.get()));
- EXPECT_TRUE(TestEqual(release_array.get(), result.get()));
+ ASSERT_FALSE(WriteAndRead(release_array.get(), &result));
// Break the self reference.
array->Set(index, PP_MakeUndefined());
- ArrayVar* result_array = ArrayVar::FromPPVar(result.get());
- result_array->Set(index, PP_MakeUndefined());
}
} // namespace proxy

Powered by Google App Engine
This is Rietveld 408576698