OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This is intended for permanent JS behavior changes for mocking out | 5 // This is intended for permanent JS behavior changes for mocking out |
6 // non-deterministic behavior. For temporary suppressions, please refer to | 6 // non-deterministic behavior. For temporary suppressions, please refer to |
7 // v8_suppressions.js. | 7 // v8_suppressions.js. |
8 // This file is loaded before each correctness test cases and won't get | 8 // This file is loaded before each correctness test cases and won't get |
9 // minimized. | 9 // minimized. |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 }, | 46 }, |
47 get: function(target, property, receiver) { | 47 get: function(target, property, receiver) { |
48 if (property == "now") { | 48 if (property == "now") { |
49 return __magic_mocked_date_now; | 49 return __magic_mocked_date_now; |
50 } | 50 } |
51 }, | 51 }, |
52 } | 52 } |
53 | 53 |
54 Date = new Proxy(Date, __magic_mock_date_handler); | 54 Date = new Proxy(Date, __magic_mock_date_handler); |
55 | 55 |
| 56 // Mock stack traces. |
| 57 Error.prepareStackTrace = function (error, structuredStackTrace) { |
| 58 return ""; |
| 59 } |
| 60 |
56 // Mock Worker. | 61 // Mock Worker. |
57 var __magic_index_for_mocked_worker = 0 | 62 var __magic_index_for_mocked_worker = 0 |
58 // TODO(machenbach): Randomize this for each test case, but keep stable during | 63 // TODO(machenbach): Randomize this for each test case, but keep stable during |
59 // comparison. Also data and random above. | 64 // comparison. Also data and random above. |
60 var __magic_mocked_worker_messages = [ | 65 var __magic_mocked_worker_messages = [ |
61 undefined, 0, -1, "", "foo", 42, [], {}, [0], {"x": 0} | 66 undefined, 0, -1, "", "foo", 42, [], {}, [0], {"x": 0} |
62 ] | 67 ] |
63 Worker = function(code){ | 68 Worker = function(code){ |
64 try { | 69 try { |
65 __PrettyPrint(eval(code)); | 70 __PrettyPrint(eval(code)); |
66 } catch(e) { | 71 } catch(e) { |
67 __PrettyPrint(e); | 72 __PrettyPrint(e); |
68 } | 73 } |
69 this.getMessage = function(){ | 74 this.getMessage = function(){ |
70 __magic_index_for_mocked_worker = (__magic_index_for_mocked_worker + 1) % 10 | 75 __magic_index_for_mocked_worker = (__magic_index_for_mocked_worker + 1) % 10 |
71 return __magic_mocked_worker_messages[__magic_index_for_mocked_worker]; | 76 return __magic_mocked_worker_messages[__magic_index_for_mocked_worker]; |
72 } | 77 } |
73 this.postMessage = function(msg){ | 78 this.postMessage = function(msg){ |
74 __PrettyPrint(msg); | 79 __PrettyPrint(msg); |
75 } | 80 } |
76 } | 81 } |
OLD | NEW |