ContentSearchChild.sys.mjs (1001B)
1 /* vim: set ts=2 sw=2 sts=2 et tw=80: */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 export class ContentSearchChild extends JSWindowActorChild { 7 handleEvent(event) { 8 // The event gets translated into a message that 9 // is then sent to the parent. 10 if (event.type == "ContentSearchClient") { 11 this.sendAsyncMessage(event.detail.type, event.detail.data); 12 } 13 } 14 15 receiveMessage(msg) { 16 // The message gets translated into an event that 17 // is then sent to the content. 18 this._fireEvent(msg.name, msg.data); 19 } 20 21 _fireEvent(type, data = null) { 22 let event = Cu.cloneInto( 23 { 24 detail: { 25 type, 26 data, 27 }, 28 }, 29 this.contentWindow 30 ); 31 this.contentWindow.dispatchEvent( 32 new this.contentWindow.CustomEvent("ContentSearchService", event) 33 ); 34 } 35 }