|
6 | 6 | * found in the LICENSE file at https://angular.io/license |
7 | 7 | */ |
8 | 8 |
|
9 | | -import {isBrowser, zoneSymbol} from '../../lib/common/utils'; |
10 | | -import {ifEnvSupports, isSupportSetErrorStack} from '../test-util'; |
| 9 | +import {isBrowser, isIE, zoneSymbol} from '../../lib/common/utils'; |
| 10 | +import {ifEnvSupports, isSafari, isSupportSetErrorStack} from '../test-util'; |
11 | 11 |
|
12 | 12 | const defineProperty = (Object as any)[zoneSymbol('defineProperty')] || Object.defineProperty; |
13 | 13 |
|
@@ -82,6 +82,40 @@ describe( |
82 | 82 | }); |
83 | 83 | })); |
84 | 84 |
|
| 85 | + it('should not overwrite long stack traces data for different optimized eventTasks', |
| 86 | + ifEnvSupports(() => isBrowser, function() { |
| 87 | + lstz.run(function() { |
| 88 | + const button = document.createElement('button'); |
| 89 | + const clickEvent = document.createEvent('Event'); |
| 90 | + clickEvent.initEvent('click', true, true); |
| 91 | + document.body.appendChild(button); |
| 92 | + |
| 93 | + const div = document.createElement('div'); |
| 94 | + const enterEvent = document.createEvent('Event'); |
| 95 | + enterEvent.initEvent('mouseenter', true, true); |
| 96 | + document.body.appendChild(div); |
| 97 | + |
| 98 | + button.addEventListener('click', function() { |
| 99 | + throw new Error('clickError'); |
| 100 | + }); |
| 101 | + |
| 102 | + div.addEventListener('mouseenter', function() { |
| 103 | + throw new Error('enterError'); |
| 104 | + }); |
| 105 | + |
| 106 | + button.dispatchEvent(clickEvent); |
| 107 | + div.dispatchEvent(enterEvent); |
| 108 | + |
| 109 | + expect(log.length).toBe(2); |
| 110 | + if (!isSafari() && !isIE()) { |
| 111 | + expect(log[0].stack === log[1].stack).toBe(false); |
| 112 | + } |
| 113 | + |
| 114 | + document.body.removeChild(button); |
| 115 | + document.body.removeChild(div); |
| 116 | + }); |
| 117 | + })); |
| 118 | + |
85 | 119 | it('should produce a long stack trace even if stack setter throws', (done) => { |
86 | 120 | let wasStackAssigned = false; |
87 | 121 | let error = new Error('Expected error'); |
|
0 commit comments