Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 "use strict";
6 module.metadata = {
7 "stability": "unstable"
8 };
10 const { EventEmitterTrait: EventEmitter } = require("../deprecated/events");
11 const { WindowTracker, windowIterator } = require("../deprecated/window-utils");
12 const { DOMEventAssembler } = require("../deprecated/events/assembler");
13 const { Trait } = require("../deprecated/light-traits");
15 // Event emitter objects used to register listeners and emit events on them
16 // when they occur.
17 const observer = Trait.compose(DOMEventAssembler, EventEmitter).create({
18 /**
19 * Method is implemented by `EventEmitter` and is used just for emitting
20 * events on registered listeners.
21 */
22 _emit: Trait.required,
23 /**
24 * Events that are supported and emitted by the module.
25 */
26 supportedEventsTypes: [ "activate", "deactivate" ],
27 /**
28 * Function handles all the supported events on all the windows that are
29 * observed. Method is used to proxy events to the listeners registered on
30 * this event emitter.
31 * @param {Event} event
32 * Keyboard event being emitted.
33 */
34 handleEvent: function handleEvent(event) {
35 this._emit(event.type, event.target, event);
36 }
37 });
39 // Using `WindowTracker` to track window events.
40 WindowTracker({
41 onTrack: function onTrack(chromeWindow) {
42 observer._emit("open", chromeWindow);
43 observer.observe(chromeWindow);
44 },
45 onUntrack: function onUntrack(chromeWindow) {
46 observer._emit("close", chromeWindow);
47 observer.ignore(chromeWindow);
48 }
49 });
51 exports.observer = observer;