OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Flags: --expose-debug-as debug |
| 6 |
| 7 Debug = debug.Debug; |
| 8 |
| 9 var base_id = -1; |
| 10 var exception = null; |
| 11 var expected = [ |
| 12 "enqueue #1", |
| 13 "willHandle #1", |
| 14 "didHandle #1", |
| 15 ]; |
| 16 |
| 17 function assertLog(msg) { |
| 18 print(msg); |
| 19 assertTrue(expected.length > 0); |
| 20 assertEquals(expected.shift(), msg); |
| 21 if (!expected.length) { |
| 22 Debug.setListener(null); |
| 23 } |
| 24 } |
| 25 |
| 26 function listener(event, exec_state, event_data, data) { |
| 27 if (event != Debug.DebugEvent.AsyncTaskEvent) return; |
| 28 try { |
| 29 if (base_id < 0) |
| 30 base_id = event_data.id(); |
| 31 var id = event_data.id() - base_id + 1; |
| 32 assertEquals("Object.observe", event_data.name()); |
| 33 assertLog(event_data.type() + " #" + id); |
| 34 } catch (e) { |
| 35 print(e + e.stack) |
| 36 exception = e; |
| 37 } |
| 38 } |
| 39 |
| 40 Debug.setListener(listener); |
| 41 |
| 42 var obj = {}; |
| 43 Object.observe(obj, function(changes) { |
| 44 print(change.type + " " + change.name + " " + change.oldValue); |
| 45 }); |
| 46 |
| 47 obj.foo = 1; |
| 48 obj.zoo = 2; |
| 49 obj.foo = 3; |
| 50 |
| 51 assertNull(exception); |
OLD | NEW |