| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 exception = e | 95 exception = e |
| 96 } | 96 } |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 | 99 |
| 100 // Add the debug event listener. | 100 // Add the debug event listener. |
| 101 Debug.setListener(listener); | 101 Debug.setListener(listener); |
| 102 | 102 |
| 103 // Compile different sources. | 103 // Compile different sources. |
| 104 compileSource('a=1'); | 104 compileSource('a=1'); |
| 105 compileSource('function(){}'); | 105 compileSource('(function(){})'); |
| 106 compileSource('eval("a=2")'); | 106 compileSource('eval("a=2")'); |
| 107 source_count++; // Using eval causes additional compilation event. | 107 source_count++; // Using eval causes additional compilation event. |
| 108 compileSource('eval("eval(\'function(){return a;}\')")'); | 108 compileSource('eval("eval(\'(function(){return a;})\')")'); |
| 109 source_count += 2; // Using eval causes additional compilation event. | 109 source_count += 2; // Using eval causes additional compilation event. |
| 110 compileSource('JSON.parse("{a:1,b:2}")'); | 110 compileSource('JSON.parse("{a:1,b:2}")'); |
| 111 source_count++; // Using JSON.parse causes additional compilation event. | 111 source_count++; // Using JSON.parse causes additional compilation event. |
| 112 | 112 |
| 113 // Make sure that the debug event listener was invoked. | 113 // Make sure that the debug event listener was invoked. |
| 114 assertFalse(exception, "exception in listener") | 114 assertFalse(exception, "exception in listener") |
| 115 | 115 |
| 116 // Number of before and after compile events should be the same. | 116 // Number of before and after compile events should be the same. |
| 117 assertEquals(before_compile_count, after_compile_count); | 117 assertEquals(before_compile_count, after_compile_count); |
| 118 | 118 |
| 119 // Check the actual number of events (no compilation through the API as all | 119 // Check the actual number of events (no compilation through the API as all |
| 120 // source compiled through eval except for one JSON.parse call). | 120 // source compiled through eval except for one JSON.parse call). |
| 121 assertEquals(source_count, after_compile_count); | 121 assertEquals(source_count, after_compile_count); |
| 122 assertEquals(0, host_compilations); | 122 assertEquals(0, host_compilations); |
| 123 assertEquals(source_count - 1, eval_compilations); | 123 assertEquals(source_count - 1, eval_compilations); |
| 124 assertEquals(1, json_compilations); | 124 assertEquals(1, json_compilations); |
| 125 | 125 |
| 126 Debug.setListener(null); | 126 Debug.setListener(null); |
| OLD | NEW |