diff --git a/lib/browser/event-target.ts b/lib/browser/event-target.ts index 9d3b2ca89..c0a6341dc 100644 --- a/lib/browser/event-target.ts +++ b/lib/browser/event-target.ts @@ -1,7 +1,7 @@ import {patchEventTargetMethods} from '../common/utils'; const WTF_ISSUE_555 = 'Anchor,Area,Audio,BR,Base,BaseFont,Body,Button,Canvas,Content,DList,Directory,Div,Embed,FieldSet,Font,Form,Frame,FrameSet,HR,Head,Heading,Html,IFrame,Image,Input,Keygen,LI,Label,Legend,Link,Map,Marquee,Media,Menu,Meta,Meter,Mod,OList,Object,OptGroup,Option,Output,Paragraph,Pre,Progress,Quote,Script,Select,Source,Span,Style,TableCaption,TableCell,TableCol,Table,TableRow,TableSection,TextArea,Title,Track,UList,Unknown,Video'; -const NO_EVENT_TARGET = 'ApplicationCache,EventSource,FileReader,InputMethodContext,MediaController,MessagePort,Node,Performance,SVGElementInstance,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebKitNamedFlow,Worker,WorkerGlobalScope,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload,IDBRequest,IDBOpenDBRequest,IDBDatabase,IDBTransaction,IDBCursor,DBIndex'.split(','); +const NO_EVENT_TARGET = 'ApplicationCache,EventSource,FileReader,InputMethodContext,MediaController,MessagePort,Node,Performance,SVGElementInstance,SharedWorker,TextTrack,TextTrackCue,TextTrackList,WebKitNamedFlow,Window,Worker,WorkerGlobalScope,XMLHttpRequest,XMLHttpRequestEventTarget,XMLHttpRequestUpload,IDBRequest,IDBOpenDBRequest,IDBDatabase,IDBTransaction,IDBCursor,DBIndex'.split(','); const EVENT_TARGET = 'EventTarget'; export function eventTargetPatch(_global) { diff --git a/test/browser/browser.spec.ts b/test/browser/browser.spec.ts index 2d67164cd..3087f75a6 100644 --- a/test/browser/browser.spec.ts +++ b/test/browser/browser.spec.ts @@ -72,6 +72,28 @@ describe('Zone', function () { expect(eventListenerSpy).toHaveBeenCalled(); }); + it('should support addEventListener on window', function () { + var hookSpy = jasmine.createSpy('hook'); + var eventListenerSpy = jasmine.createSpy('eventListener'); + var zone = rootZone.fork({ + name: 'spy', + onScheduleTask: (parentZoneDelegate: ZoneDelegate, currentZone: Zone, targetZone: Zone, + task: Task): any => { + hookSpy(); + return parentZoneDelegate.scheduleTask(targetZone, task); + } + }); + + zone.run(function() { + window.addEventListener('click', eventListenerSpy); + }); + + window.dispatchEvent(clickEvent); + + expect(hookSpy).toHaveBeenCalled(); + expect(eventListenerSpy).toHaveBeenCalled(); + }); + it('should support removeEventListener', function () { var hookSpy = jasmine.createSpy('hook'); var eventListenerSpy = jasmine.createSpy('eventListener');