dom.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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';
  5. const { Trait } = require('../deprecated/traits');
  6. const { isWindowPrivate, getWindowTitle } = require('../window/utils');
  7. const { deprecateUsage } = require('../util/deprecate');
  8. module.metadata = {
  9. "stability": "unstable"
  10. };
  11. const WindowDom = Trait.compose({
  12. _window: Trait.required,
  13. get title() {
  14. return getWindowTitle(this._window);
  15. },
  16. close: function close() {
  17. let window = this._window;
  18. if (window) window.close();
  19. return this._public;
  20. },
  21. activate: function activate() {
  22. let window = this._window;
  23. if (window) window.focus();
  24. return this._public;
  25. },
  26. get isPrivateBrowsing() {
  27. deprecateUsage('`browserWindow.isPrivateBrowsing` is deprecated, please ' +
  28. 'consider using ' +
  29. '`require("sdk/private-browsing").isPrivate(browserWindow)` ' +
  30. 'instead.');
  31. return isWindowPrivate(this._window);
  32. }
  33. });
  34. exports.WindowDom = WindowDom;