Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/browser/event-target.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
28 changes: 28 additions & 0 deletions test/browser/browser.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {ifEnvSupports} from '../test-util';

function windowPrototype() {
return !!(global['Window'] && global['Window'].prototype);
}

describe('Zone', function () {
var rootZone = Zone.current;

Expand Down Expand Up @@ -72,6 +78,28 @@ describe('Zone', function () {
expect(eventListenerSpy).toHaveBeenCalled();
});

it('should support addEventListener on window', ifEnvSupports(windowPrototype, 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');
Expand Down