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