1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 'use strict'; 6 7 base.require('base.event_target'); 8 base.require('base.events'); 9 10 base.unittest.testSuite('base.event_target', function() { 11 test('eventTargetHelper', function() { 12 var listenerCallCount = 0; 13 function listener() { listenerCallCount++; } 14 15 var div = document.createElement('div'); 16 base.EventTargetHelper.decorate(div); 17 18 assertFalse(div.hasEventListener('foo')); 19 20 div.addEventListener('foo', listener); 21 assertTrue(div.hasEventListener('foo')); 22 23 base.dispatchSimpleEvent(div, 'foo'); 24 assertEquals(1, listenerCallCount); 25 26 div.removeEventListener('foo', listener); 27 28 base.dispatchSimpleEvent(div, 'foo'); 29 assertEquals(1, listenerCallCount); 30 31 assertFalse(div.hasEventListener('foo')); 32 }); 33 }); 34