| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // events for the source inside eval. | 58 // events for the source inside eval. |
| 59 if (current_source.indexOf('eval') == 0) { | 59 if (current_source.indexOf('eval') == 0) { |
| 60 // For source with 'eval' there will be compile events with substrings | 60 // For source with 'eval' there will be compile events with substrings |
| 61 // as well as with with the exact source. | 61 // as well as with with the exact source. |
| 62 assertTrue(current_source.indexOf(event_data.script().source()) >= 0); | 62 assertTrue(current_source.indexOf(event_data.script().source()) >= 0); |
| 63 } else { | 63 } else { |
| 64 // For source without 'eval' there will be a compile events with the | 64 // For source without 'eval' there will be a compile events with the |
| 65 // exact source. | 65 // exact source. |
| 66 assertEquals(current_source, event_data.script().source()); | 66 assertEquals(current_source, event_data.script().source()); |
| 67 } | 67 } |
| 68 // Check that script context is included into the event message. |
| 69 var json = event_data.toJSONProtocol(); |
| 70 var msg = eval('(' + json + ')'); |
| 71 assertTrue('context' in msg.body.script); |
| 68 } | 72 } |
| 69 } catch (e) { | 73 } catch (e) { |
| 70 exception = e | 74 exception = e |
| 71 } | 75 } |
| 72 }; | 76 }; |
| 73 | 77 |
| 74 | 78 |
| 75 // Add the debug event listener. | 79 // Add the debug event listener. |
| 76 Debug.setListener(listener); | 80 Debug.setListener(listener); |
| 77 | 81 |
| 78 // Compile different sources. | 82 // Compile different sources. |
| 79 compileSource('a=1'); | 83 compileSource('a=1'); |
| 80 compileSource('function(){}'); | 84 compileSource('function(){}'); |
| 81 compileSource('eval("a=2")'); | 85 compileSource('eval("a=2")'); |
| 82 source_count++; // Using eval causes additional compilation event. | 86 source_count++; // Using eval causes additional compilation event. |
| 83 compileSource('eval("eval(\'function(){return a;}\')")'); | 87 compileSource('eval("eval(\'function(){return a;}\')")'); |
| 84 source_count += 2; // Using eval causes additional compilation event. | 88 source_count += 2; // Using eval causes additional compilation event. |
| 85 | 89 |
| 86 // Make sure that the debug event listener was invoked. | 90 // Make sure that the debug event listener was invoked. |
| 87 assertFalse(exception, "exception in listener") | 91 assertFalse(exception, "exception in listener") |
| 88 | 92 |
| 89 // Number of before and after compile events should be the same. | 93 // Number of before and after compile events should be the same. |
| 90 assertEquals(before_compile_count, after_compile_count); | 94 assertEquals(before_compile_count, after_compile_count); |
| 91 | 95 |
| 92 // Check the actual number of events. | 96 // Check the actual number of events. |
| 93 assertEquals(source_count, after_compile_count); | 97 assertEquals(source_count, after_compile_count); |
| 94 | 98 |
| 95 Debug.setListener(null); | 99 Debug.setListener(null); |
| OLD | NEW |