11/*1* KEEP THIS CODE AT THE TOP TO AVOID LINE NUMBER CHANGES */
22/*2*/ 'use strict' ;
33/*3*/ function foo ( n ) {
4- /*4*/ var A = new Array ( 3 ) ; return n + 42 + A [ 0 ] ;
5- /*5*/ }
6- /*6*/ function getterObject ( ) {
7- /*7*/ var hasGetter = { _a : 5 , get a ( ) { return this . _a ; } , b : 'hello world' } ;
8- /*8*/ return hasGetter . a ;
9- /*9*/ }
4+ /*4*/ var A = [ 1 , 2 , 3 ] ; var B = { a : 5 , b : 6 , c : 7 } ;
5+ /*5*/ return n + 42 + A [ 0 ] + B . b ;
6+ /*6*/ }
7+ /*7*/ function getterObject ( ) {
8+ /*8*/ var hasGetter = { _a : 5 , get a ( ) { return this . _a ; } , b : 'hello world' } ;
9+ /*9*/ return hasGetter . a ;
10+ /*10*/ }
1011/**
1112 * Copyright 2015 Google Inc. All Rights Reserved.
1213 *
@@ -449,6 +450,8 @@ describe('v8debugapi', function() {
449450 location : breakpointInFoo . location ,
450451 expressions : [ 'process' ]
451452 } ;
453+ var oldMax = config . capture . maxProperties ;
454+ config . capture . maxProperties = 0 ;
452455 api . set ( bp , function ( err ) {
453456 assert . ifError ( err ) ;
454457 api . wait ( bp , function ( err ) {
@@ -477,6 +480,7 @@ describe('v8debugapi', function() {
477480 } ) ) ;
478481
479482 api . clear ( bp ) ;
483+ config . capture . maxProperties = oldMax ;
480484 done ( ) ;
481485 } ) ;
482486 process . nextTick ( function ( ) { foo ( 3 ) ; } ) ;
@@ -486,7 +490,7 @@ describe('v8debugapi', function() {
486490 it ( 'should report error for native prop or getter' , function ( done ) {
487491 var bp = {
488492 id : 'fake-id-124' ,
489- location : { path : 'test-v8debugapi.js' , line : 8 } ,
493+ location : { path : 'test-v8debugapi.js' , line : 9 } ,
490494 expressions : [ 'process.env' , 'hasGetter' ]
491495 } ;
492496 api . set ( bp , function ( err ) {
@@ -520,7 +524,7 @@ describe('v8debugapi', function() {
520524 it ( 'should limit string length' , function ( done ) {
521525 var bp = {
522526 id : 'fake-id-124' ,
523- location : { path : 'test-v8debugapi.js' , line : 8 } ,
527+ location : { path : 'test-v8debugapi.js' , line : 9 } ,
524528 expressions : [ 'hasGetter' ]
525529 } ;
526530 var oldMax = config . capture . maxStringLength ;
@@ -543,6 +547,60 @@ describe('v8debugapi', function() {
543547 } ) ;
544548 } ) ;
545549
550+ it ( 'should limit array length' , function ( done ) {
551+ var bp = {
552+ id : 'fake-id-124' ,
553+ location : { path : 'test-v8debugapi.js' , line : 5 } ,
554+ expressions : [ 'A' ]
555+ } ;
556+ var oldMax = config . capture . maxProperties ;
557+ config . capture . maxProperties = 1 ;
558+ api . set ( bp , function ( err ) {
559+ assert . ifError ( err ) ;
560+ api . wait ( bp , function ( err ) {
561+ assert . ifError ( err ) ;
562+ var foo = bp . evaluatedExpressions [ 0 ] ;
563+ var fooVal = bp . variableTable [ foo . varTableIndex ] ;
564+ assert . equal ( fooVal . members . length , 1 ) ;
565+ assert ( foo . status . status . description . format . indexOf (
566+ 'Only first' ) !== - 1 ) ;
567+ assert ( ! foo . status . isError ) ;
568+
569+ api . clear ( bp ) ;
570+ config . capture . maxProperties = oldMax ;
571+ done ( ) ;
572+ } ) ;
573+ process . nextTick ( function ( ) { foo ( 2 ) ; } ) ;
574+ } ) ;
575+ } ) ;
576+
577+ it ( 'should limit object length' , function ( done ) {
578+ var bp = {
579+ id : 'fake-id-124' ,
580+ location : { path : 'test-v8debugapi.js' , line : 5 } ,
581+ expressions : [ 'B' ]
582+ } ;
583+ var oldMax = config . capture . maxProperties ;
584+ config . capture . maxProperties = 1 ;
585+ api . set ( bp , function ( err ) {
586+ assert . ifError ( err ) ;
587+ api . wait ( bp , function ( err ) {
588+ assert . ifError ( err ) ;
589+ var foo = bp . evaluatedExpressions [ 0 ] ;
590+ var fooVal = bp . variableTable [ foo . varTableIndex ] ;
591+ assert . equal ( fooVal . members . length , 1 ) ;
592+ assert ( foo . status . status . description . format . indexOf (
593+ 'Only first' ) !== - 1 ) ;
594+ assert ( ! foo . status . isError ) ;
595+
596+ api . clear ( bp ) ;
597+ config . capture . maxProperties = oldMax ;
598+ done ( ) ;
599+ } ) ;
600+ process . nextTick ( function ( ) { foo ( 2 ) ; } ) ;
601+ } ) ;
602+ } ) ;
603+
546604 it ( 'should capture without values for invalid watch expressions' , function ( done ) {
547605 // clone a clean breakpointInFoo
548606 var bp = {
0 commit comments