OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 15 matching lines...) Expand all Loading... |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --expose-debug-as debug --expose-gc | 28 // Flags: --expose-debug-as debug --expose-gc |
29 // Get the Debug object exposed from the debug context global object. | 29 // Get the Debug object exposed from the debug context global object. |
30 Debug = debug.Debug | 30 Debug = debug.Debug |
31 | 31 |
32 Date(); | 32 Date(); |
33 RegExp(); | 33 RegExp(); |
34 | 34 |
35 // Count script types. | 35 // Count script types. |
36 var native_count = 0; | 36 var named_native_count = 0; |
37 var extension_count = 0; | 37 var extension_count = 0; |
38 var normal_count = 0; | 38 var normal_count = 0; |
39 var scripts = Debug.scripts(); | 39 var scripts = Debug.scripts(); |
40 for (i = 0; i < scripts.length; i++) { | 40 for (i = 0; i < scripts.length; i++) { |
41 if (scripts[i].type == Debug.ScriptType.Native) { | 41 if (scripts[i].type == Debug.ScriptType.Native) { |
42 native_count++; | 42 if (scripts[i].name) { |
| 43 named_native_count++; |
| 44 } |
43 } else if (scripts[i].type == Debug.ScriptType.Extension) { | 45 } else if (scripts[i].type == Debug.ScriptType.Extension) { |
44 extension_count++; | 46 extension_count++; |
45 } else if (scripts[i].type == Debug.ScriptType.Normal) { | 47 } else if (scripts[i].type == Debug.ScriptType.Normal) { |
46 if (!scripts[i].name) print("X" + scripts[i].source + "X"); // empty script | 48 normal_count++; |
47 else { | |
48 print(scripts[i].name); | |
49 normal_count++; | |
50 } | |
51 } else { | 49 } else { |
52 assertUnreachable('Unexpected type ' + scripts[i].type); | 50 assertUnreachable('Unexpected type ' + scripts[i].type); |
53 } | 51 } |
54 } | 52 } |
55 | 53 |
56 // This has to be updated if the number of native scripts change. | 54 // This has to be updated if the number of native scripts change. |
57 assertEquals(16, native_count); | 55 assertEquals(12, named_native_count); |
58 // If no snapshot is used, only the 'gc' extension is loaded. | 56 // If no snapshot is used, only the 'gc' extension is loaded. |
59 // If snapshot is used, all extensions are cached in the snapshot. | 57 // If snapshot is used, all extensions are cached in the snapshot. |
60 assertTrue(extension_count == 1 || extension_count == 5); | 58 assertTrue(extension_count == 1 || extension_count == 5); |
61 // This script and mjsunit.js has been loaded. If using d8, d8 loads | 59 // This script and mjsunit.js has been loaded. If using d8, d8 loads |
62 // a normal script during startup too. | 60 // a normal script during startup too. |
63 assertTrue(normal_count == 2 || normal_count == 3); | 61 assertTrue(normal_count == 2 || normal_count == 3); |
64 | 62 |
65 // Test a builtins script. | 63 // Test a builtins script. |
66 var math_script = Debug.findScript('native math.js'); | 64 var math_script = Debug.findScript('native math.js'); |
67 assertEquals('native math.js', math_script.name); | 65 assertEquals('native math.js', math_script.name); |
(...skipping 17 matching lines...) Expand all Loading... |
85 } | 83 } |
86 | 84 |
87 // Test a normal script. | 85 // Test a normal script. |
88 var mjsunit_js_script = Debug.findScript(/mjsunit.js/); | 86 var mjsunit_js_script = Debug.findScript(/mjsunit.js/); |
89 assertTrue(/mjsunit.js/.test(mjsunit_js_script.name)); | 87 assertTrue(/mjsunit.js/.test(mjsunit_js_script.name)); |
90 assertEquals(Debug.ScriptType.Normal, mjsunit_js_script.type); | 88 assertEquals(Debug.ScriptType.Normal, mjsunit_js_script.type); |
91 | 89 |
92 // Check a nonexistent script. | 90 // Check a nonexistent script. |
93 var dummy_script = Debug.findScript('dummy.js'); | 91 var dummy_script = Debug.findScript('dummy.js'); |
94 assertTrue(typeof dummy_script == 'undefined'); | 92 assertTrue(typeof dummy_script == 'undefined'); |
OLD | NEW |