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/. */
7 * The BrowserElementParent is for performing actions on one or more subframes of
8 * a <xul:browser> from the browser element binding.
10 export class BrowserElementParent extends JSWindowActorParent {
11 receiveMessage(message) {
12 switch (message.name) {
13 case "DOMWindowClose": {
14 // This message is sent whenever window.close() is called within a window
15 // that had originally been opened via window.open. Double-check that this is
16 // coming from a top-level frame, and then dispatch the DOMWindowClose event
17 // on the browser so that the front-end code can do the right thing with the
19 if (!this.manager.browsingContext.parent) {
20 let browser = this.manager.browsingContext.embedderElement;
21 let win = browser.ownerGlobal;
22 // If this is a non-remote browser, the DOMWindowClose event will bubble
23 // up naturally, and doesn't need to be re-dispatched.
24 if (browser.isRemoteBrowser) {
25 browser.dispatchEvent(
26 new win.CustomEvent("DOMWindowClose", {