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

Unified Diff: test/cctest/test-object-observe.cc

Issue 11274014: Store Object.observe state per-isolate rather than per-context (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added back runtime asserts Created 8 years, 1 month 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 | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-object-observe.cc
diff --git a/test/cctest/test-ast.cc b/test/cctest/test-object-observe.cc
similarity index 55%
copy from test/cctest/test-ast.cc
copy to test/cctest/test-object-observe.cc
index c72f87ec3dee0fcc4d356a0a45bc1dedb3c1e36b..7e0eb47493ac26c9180a3bb8958d595b4291932e 100644
--- a/test/cctest/test-ast.cc
+++ b/test/cctest/test-object-observe.cc
@@ -25,37 +25,60 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <stdlib.h>
-
#include "v8.h"
-#include "ast.h"
#include "cctest.h"
-using namespace v8::internal;
-
-TEST(List) {
- v8::internal::V8::Initialize(NULL);
- List<AstNode*>* list = new List<AstNode*>(0);
- CHECK_EQ(0, list->length());
+using namespace v8;
- Isolate* isolate = Isolate::Current();
- Zone* zone = isolate->runtime_zone();
- ZoneScope zone_scope(zone, DELETE_ON_EXIT);
- AstNodeFactory<AstNullVisitor> factory(isolate, zone);
- AstNode* node = factory.NewEmptyStatement();
- list->Add(node);
- CHECK_EQ(1, list->length());
- CHECK_EQ(node, list->at(0));
- CHECK_EQ(node, list->last());
+namespace {
+// Need to create a new isolate when FLAG_harmony_observation is on.
+class HarmonyIsolate {
+ public:
+ HarmonyIsolate() {
+ i::FLAG_harmony_observation = true;
+ isolate_ = Isolate::New();
+ isolate_->Enter();
+ }
- const int kElements = 100;
- for (int i = 0; i < kElements; i++) {
- list->Add(node);
+ ~HarmonyIsolate() {
+ isolate_->Exit();
+ isolate_->Dispose();
}
- CHECK_EQ(1 + kElements, list->length());
- list->Clear();
- CHECK_EQ(0, list->length());
- delete list;
+ private:
+ Isolate* isolate_;
+};
+}
+
+TEST(PerIsolateState) {
+ HarmonyIsolate isolate;
+ HandleScope scope;
+ LocalContext context1;
+ CompileRun(
+ "var count = 0;"
+ "var calls = 0;"
+ "var observer = function(records) { count = records.length; calls++ };"
+ "var obj = {};"
+ "Object.observe(obj, observer);"
+ "Object.notify(obj, {type: 'a'});");
+ Handle<Value> observer = CompileRun("observer");
+ Handle<Value> obj = CompileRun("obj");
+ {
+ LocalContext context2;
+ context2->Global()->Set(String::New("obj"), obj);
+ CompileRun("Object.notify(obj, {type: 'b'});");
+ }
+ {
+ LocalContext context3;
+ context3->Global()->Set(String::New("obj"), obj);
+ CompileRun("Object.notify(obj, {type: 'c'});");
+ }
+ {
+ LocalContext context4;
+ context4->Global()->Set(String::New("observer"), observer);
+ CompileRun("Object.deliverChangeRecords(observer)");
+ }
+ CHECK_EQ(1, CompileRun("calls")->Int32Value());
+ CHECK_EQ(3, CompileRun("count")->Int32Value());
}
« no previous file with comments | « test/cctest/cctest.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698