1537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch// Copyright 2016 the V8 project authors. All rights reserved. 2537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch// Use of this source code is governed by a BSD-style license that can be 3537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch// found in the LICENSE file. 4537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 5537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch// Flags: --expose-debug-as debug 6537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 7537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch// Test that debug-evaluate doesn't crash when this is used before super() call 8537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch// in constructor. 9537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 10537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben MurdochDebug = debug.Debug 11537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 12537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdochvar result; 13537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 14537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdochfunction listener(event, exec_state, event_data, data) 15537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch{ 16537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch try { 17537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch if (event == Debug.DebugEvent.Break) { 18537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch result = exec_state.frame(0).evaluate("this.a").value(); 19537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch } 20537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch } catch (e) { 21537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch result = e.message; 22537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch } 23537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch} 24537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 25537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben MurdochDebug.setListener(listener); 26537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 27537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdochclass A { constructor () { this.a = 239; } } 28537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdochclass B extends A { 29537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch constructor () { 30537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch debugger; 31537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch assertEquals("Cannot read property 'a' of undefined", result); 32537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch super(); 33537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch debugger; 34537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch assertEquals(239, result); 35537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch } 36537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch} 37537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdochnew B(); 38537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben Murdoch 39537ba893e2530051ec7f296e769fdd37bb4ae4a0Ben MurdochDebug.setListener(null); 40