| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 v8::Isolate* GetIsolate() const { return isolate_; } | 52 v8::Isolate* GetIsolate() const { return isolate_; } |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 v8::Isolate* isolate_; | 55 v8::Isolate* isolate_; |
| 56 }; | 56 }; |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 | 59 |
| 60 TEST(MicrotaskDeliverySimple) { | 60 TEST(MicrotaskDeliverySimple) { |
| 61 i::FLAG_harmony_object_observe = true; |
| 61 HarmonyIsolate isolate; | 62 HarmonyIsolate isolate; |
| 62 v8::HandleScope scope(isolate.GetIsolate()); | 63 v8::HandleScope scope(isolate.GetIsolate()); |
| 63 LocalContext context(isolate.GetIsolate()); | 64 LocalContext context(isolate.GetIsolate()); |
| 64 CompileRun( | 65 CompileRun( |
| 65 "var ordering = [];" | 66 "var ordering = [];" |
| 66 "var resolver = {};" | 67 "var resolver = {};" |
| 67 "function handler(resolve) { resolver.resolve = resolve; }" | 68 "function handler(resolve) { resolver.resolve = resolve; }" |
| 68 "var obj = {};" | 69 "var obj = {};" |
| 69 "var observeOrders = [1, 4];" | 70 "var observeOrders = [1, 4];" |
| 70 "function observer() {" | 71 "function observer() {" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 96 CHECK_EQ(4, | 97 CHECK_EQ(4, |
| 97 CompileRun("ordering[3]")->Int32Value(context.local()).FromJust()); | 98 CompileRun("ordering[3]")->Int32Value(context.local()).FromJust()); |
| 98 CHECK_EQ(5, | 99 CHECK_EQ(5, |
| 99 CompileRun("ordering[4]")->Int32Value(context.local()).FromJust()); | 100 CompileRun("ordering[4]")->Int32Value(context.local()).FromJust()); |
| 100 CHECK_EQ(6, | 101 CHECK_EQ(6, |
| 101 CompileRun("ordering[5]")->Int32Value(context.local()).FromJust()); | 102 CompileRun("ordering[5]")->Int32Value(context.local()).FromJust()); |
| 102 } | 103 } |
| 103 | 104 |
| 104 | 105 |
| 105 TEST(MicrotaskPerIsolateState) { | 106 TEST(MicrotaskPerIsolateState) { |
| 107 i::FLAG_harmony_object_observe = true; |
| 106 HarmonyIsolate isolate; | 108 HarmonyIsolate isolate; |
| 107 v8::HandleScope scope(isolate.GetIsolate()); | 109 v8::HandleScope scope(isolate.GetIsolate()); |
| 108 LocalContext context1(isolate.GetIsolate()); | 110 LocalContext context1(isolate.GetIsolate()); |
| 109 isolate.GetIsolate()->SetAutorunMicrotasks(false); | 111 isolate.GetIsolate()->SetAutorunMicrotasks(false); |
| 110 CompileRun( | 112 CompileRun( |
| 111 "var obj = { calls: 0 };"); | 113 "var obj = { calls: 0 };"); |
| 112 v8::Local<v8::Value> obj = CompileRun("obj"); | 114 v8::Local<v8::Value> obj = CompileRun("obj"); |
| 113 { | 115 { |
| 114 LocalContext context2(isolate.GetIsolate()); | 116 LocalContext context2(isolate.GetIsolate()); |
| 115 context2->Global() | 117 context2->Global() |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 v8::String::NewFromUtf8(isolate.GetIsolate(), "obj", | 155 v8::String::NewFromUtf8(isolate.GetIsolate(), "obj", |
| 154 v8::NewStringType::kNormal) | 156 v8::NewStringType::kNormal) |
| 155 .ToLocalChecked(), | 157 .ToLocalChecked(), |
| 156 obj) | 158 obj) |
| 157 .FromJust(); | 159 .FromJust(); |
| 158 isolate.GetIsolate()->RunMicrotasks(); | 160 isolate.GetIsolate()->RunMicrotasks(); |
| 159 CHECK_EQ(2, | 161 CHECK_EQ(2, |
| 160 CompileRun("obj.calls")->Int32Value(context4.local()).FromJust()); | 162 CompileRun("obj.calls")->Int32Value(context4.local()).FromJust()); |
| 161 } | 163 } |
| 162 } | 164 } |
| OLD | NEW |