merge for backing out of changeset 680248df0349, the second of two commits for bug 598980, because it generates test failures per bug 604801 that are 0.9 release blockers
authorMyk Melez <myk@mozilla.org>
Mon, 18 Oct 2010 16:37:46 -0700
changeset 879 e80ffb9aa4ca71120e9a86600a4eba6e527f2fbd
parent 877 7c173906997105398c0a94d51cbac2d5392faef8 (current diff)
parent 878 28f897d10b203a26bb1cc874e1c29326c71d331e (diff)
child 881 378391fa478355e74c654fc2f17b483c4c816f92
push id387
push usermyk@mozilla.com
push dateMon, 18 Oct 2010 23:56:05 +0000
bugs598980, 604801
merge for backing out of changeset 680248df0349, the second of two commits for bug 598980, because it generates test failures per bug 604801 that are 0.9 release blockers
packages/jetpack-core/lib/windows/dom.js
packages/jetpack-core/lib/windows/loader.js
packages/jetpack-core/lib/windows/tabs.js
packages/jetpack-core/tests/test-window-loader.js
deleted file mode 100644
--- a/packages/jetpack-core/lib/windows/dom.js
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Jetpack.
- *
- * The Initial Developer of the Original Code is
- * the Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Irakli Gozalishvili <gozala@mozilla.com> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-'use strict';
-
-const { Trait } = require('traits');
-
-const WindowDom = Trait.compose({
-  _window: Trait.required,
-  get title() {
-    let window = this._window;
-    return window && window.document ? window.document.title : null
-  },
-  close: function close() {
-    let window = this._window;
-    if (window) window.close();
-    return this._public;
-  },
-  focus: function focus() {
-    let window = this._window;
-    if (window) window.focus();
-    return this._public;
-  }
-});
-exports.WindowDom = WindowDom;
-
deleted file mode 100644
--- a/packages/jetpack-core/lib/windows/loader.js
+++ /dev/null
@@ -1,149 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Jetpack.
- *
- * The Initial Developer of the Original Code is Mozilla.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Irakli Gozalishvili <gozala@mozilla.com> (Original author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-"use strict";
-
-const { Cc, Ci } = require('chrome'),
-      { setTimeout } = require("timer"),
-      { Trait } = require('traits'),
-
-      WM = Cc['@mozilla.org/appshell/window-mediator;1'].
-        getService(Ci.nsIWindowMediator),
-
-      URI_BROWSER = 'chrome://browser/content/browser.xul',
-      NAME = '_blank',
-      FEATURES = 'chrome,all,dialog=no',
-      PARAMS = [ URI_BROWSER, NAME, FEATURES ],
-      ON_LOAD = 'load',
-      ON_UNLOAD = 'unload',
-      STATE_LOADED = 'complete',
-      BROWSER = 'navigator:browser';
-
-/**
- * Trait provides private `_window` property and requires `_onLoad` property
- * that will be called when `_window` is loaded. If `_window` property value
- * is changed with already loaded window `_onLoad` still will be called.
- */
-const WindowLoader = Trait.compose({
-  /**
-   * Internal listener that is called when window is loaded.
-   * Please keep in mind that this trait will not handle exceptions that may
-   * be thrown by this method so method itself should take care of
-   * handling them.
-   * @param {nsIWindow} window
-   */
-  _onLoad: Trait.required,
-  /**
-   * Internal listener that is called when `_window`'s DOM 'unload' event
-   * is dispatched. Please note that this trait will not handle exceptions that
-   * may be thrown by this method so method itself should take care of
-   * handling them.
-   */
-  _onUnload: Trait.required,
-  /**
-   * Private window who's load event is being tracked. Once window is loaded
-   * `_onLoad` is called.
-   * @type {nsIWindow}
-   */
-  get _window() {
-    if (this.__window) return this.__window
-    let params = PARAMS;
-    if (Array.isArray(this._params))
-      params = PARAMS.concat(this._params);
-    let browser =  WM.getMostRecentWindow(BROWSER);
-    return this._window = browser.openDialog.apply(browser, params)
-  },
-  set _window(window) {
-    let _window = this.__window;
-    if (!window) window = null;
-    if (window == _window) return;
-    if (_window) {
-      _window.removeEventListener(ON_UNLOAD, this.__unloadListener, true);
-      _window.removeEventListener(ON_LOAD, this.__loadListener, true);
-    }
-    if (!window) return;
-    window.addEventListener(
-      ON_UNLOAD,
-      this.__unloadListener ||
-        (this.__unloadListener = this._unloadListener.bind(this))
-      ,
-      true
-    );
-    if (STATE_LOADED != window.document.readyState) {
-      window.addEventListener(
-        ON_LOAD,
-        this.__loadListener ||
-          (this.__loadListener = this._loadListener.bind(this))
-        ,
-        true
-      );
-    }
-    else {
-      // calling listener in another turn of the event loop
-      setTimeout(this._onLoad.bind(this), 0, window);
-    }
-    return this.__window = window;
-  },
-  __window: null,
-  /**
-   * Internal method used for listening 'load' event on the `_window`.
-   * Method takes care of removing itself from 'load' event listeners once
-   * event is being handled.
-   */
-  _loadListener: function _loadListener(event) {
-    let window = this._window;
-    if (!event.target || event.target.defaultView != window) return;
-    window.removeEventListener(ON_LOAD, this.__loadListener, true);
-    this._onLoad(window);
-  },
-  __loadListener: null,
-  /**
-   * Internal method used for listening 'unload' event on the `_window`.
-   * Method takes care of removing itself from 'unload' event listeners once
-   * event is being handled.
-   */
-  _unloadListener: function _unloadListener(event) {
-    let window = this._window;
-    if (!event.target
-      || event.target.defaultView != window
-      || STATE_LOADED != window.document.readyState
-    ) return;
-    window.removeEventListener(ON_UNLOAD, this.__unloadListener, true);
-    this._onUnload(window);
-  },
-  __unloadListener: null
-});
-exports.WindowLoader = WindowLoader;
-
deleted file mode 100644
--- a/packages/jetpack-core/lib/windows/tabs.js
+++ /dev/null
@@ -1,70 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Jetpack.
- *
- * The Initial Developer of the Original Code is
- * the Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Irakli Gozalishvili <gozala@mozilla.com> (Original Author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-'use strict';
-
-const { Trait } = require('traits'),
-      { TabModule } = require("tab-browser"),
-
-      ON_READY = 'DOMContentLoaded';
-
-const WindowTabs = Trait.compose({
-  _window: Trait.required,
-  get tabs() {
-    let tabs = new TabModule(this._window);
-    Object.defineProperty(this, 'tabs', { value: tabs })
-    return this.tabs
-  }
-});
-exports.WindowTabs = WindowTabs;
-
-const WindowTabTracker = Trait.compose({
-  _window: Trait.required,
-  _onReady: Trait.required,
-  _initWindowTabTracker: function _initWindowTabTracker() {
-    let gBrowser = this._window.gBrowser;
-    let tab = gBrowser.getBrowserForTab(gBrowser.tabContainer.children[0]);
-    let listener = this.__onReady = this.__onReady.bind(this, tab)
-    tab.addEventListener(ON_READY, listener, false);
-  },
-  __onReady: function __onReady(tab, e) {
-    tab.removeEventListener(ON_READY, this.__onReady, false);
-    this._onReady(e);
-  }
-});
-exports.WindowTabTracker = WindowTabTracker;
-
deleted file mode 100644
--- a/packages/jetpack-core/tests/test-window-loader.js
+++ /dev/null
@@ -1,147 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Jetpack.
- *
- * The Initial Developer of the Original Code is Mozilla.
- * Portions created by the Initial Developer are Copyright (C) 2010
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Irakli Gozalishvili <gozala@mozilla.com> (Original author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-"use strict";
-
-const { WindowLoader } = require('windows/loader'),
-      { Trait } = require('traits');
-
-const Loader = Trait.compose(
-  WindowLoader,
-  {
-    constructor: function Loader(options) {
-      this._onLoad = options.onLoad;
-      this._onUnload = options.onUnload;
-      if ('window' in options)
-        this._window = options.window;
-      this.window = this._window;
-    },
-    window: null,
-    _onLoad: null,
-    _onUnload: null
-  }
-);
-
-exports['test compositions with missing required properties'] = function(test) {
-  test.assertRaises(
-    function() WindowLoader.compose({})(),
-    /Missing required property:/,
-    'should throw missing required property exception'
-  );
-  test.assertRaises(
-    function() WindowLoader.compose({ _onLoad: null })(),
-    'Missing required property: _onUnload',
-    'should throw missing required property `_onUnload`'
-  );
-  test.assertRaises(
-    function() WindowLoader.compose({ _onUnload: null })(),
-    'Missing required property: _onLoad',
-    'should throw missing required property `_onLoad`'
-  );
-};
-
-exports['test `load` events'] = function(test) {
-  test.waitUntilDone();
-  let onLoadCalled = false;
-  Loader({
-    onLoad: function(window) {
-      onLoadCalled = true;
-      test.assertEqual(
-        window, this._window, 'windows should match'
-      );
-      test.assertEqual(
-        window.document.readyState, 'complete', 'window must be fully loaded'
-      );
-      window.close();
-    },
-    onUnload: function(window) {
-      test.assertEqual(
-        window, this._window, 'windows should match'
-      );
-      test.assertEqual(
-        window.document.readyState, 'complete', 'window must be fully loaded'
-      );
-      test.assert(onLoadCalled, 'load callback is supposed to be called');
-      test.done();
-    }
-  });
-};
-
-exports['test removeing listeners'] = function(test) {
-  test.waitUntilDone();
-  Loader({
-    onLoad: function(window) {
-      test.assertEqual(
-        window, this._window, 'windows should match'
-      );
-      this._window = null;
-      window.close();
-      test.done();
-    },
-    onUnload: function(window) {
-      test.fail('listener must be unset');
-    }
-  });
-};
-
-exports['test create loader from opened window'] = function(test) {
-  test.waitUntilDone();
-  let onUnloadCalled = false;
-  Loader({
-    onLoad: function(window) {
-      test.assertEqual(
-        window, this._window, 'windows should match'
-      );
-      test.assertEqual(
-        window.document.readyState, 'complete', 'window must be fully loaded'
-      );
-      Loader({
-        window: window,
-        onLoad: function(win) {
-          test.assertEqual(win, window, 'windows should match');
-          window.close();
-        },
-        onUnload: function(window) {
-          test.assert(onUnloadCalled, 'first handler should be called already');
-          test.done();
-        }
-      });
-    },
-    onUnload: function(window) {
-      onUnloadCalled = true;
-    }
-  });
-};
-