Skip to content
Browse files

Add some tests.

  • Loading branch information...
1 parent fb6001a commit 8256565b5df3e6c7156fb784801c7497bfe50002 @Mossop committed Mar 20, 2013
Showing with 20 additions and 3 deletions.
  1. +0 −2 lib/sdk/window/utils.js
  2. +20 −1 test/test-window-utils.js
View
2 lib/sdk/window/utils.js
@@ -340,5 +340,3 @@ function getFrames(window) {
exports.getFrames = getFrames;
exports.getBrowserWindow = method("getBrowserWindow");
-// Required to set the default implementation of getBrowserWindow
-require("sdk/windows");
View
21 test/test-window-utils.js
@@ -7,9 +7,10 @@ const windowUtils = require("sdk/deprecated/window-utils");
const timer = require("sdk/timers");
const { Cc, Ci } = require("chrome");
const { Loader } = require("sdk/test/loader");
-const { open, getFrames, getWindowTitle, onFocus } = require('sdk/window/utils');
+const { open, getFrames, getWindowTitle, onFocus, getDOMWindow, getMostRecentBrowserWindow, getBrowserWindow } = require('sdk/window/utils');
const { close } = require('sdk/window/helpers');
const { fromIterator: toArray } = require('sdk/util/array');
+const { browserWindows } = require('sdk/windows');
const WM = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
@@ -301,6 +302,24 @@ exports.testWindowIterator = function(assert, done) {
}, false);
};
+exports["test getBrowserWindow"] = function(assert) {
+ let window = browserWindows.activeWindow;
+ let chromeWindow = getMostRecentBrowserWindow();
+
+ assert.equal(getBrowserWindow(chromeWindow), window, "getBrowserWindow should have worked");
+}
+
+exports["test getDOMWindow"] = function(assert) {
+ let window = browserWindows.activeWindow;
+ let tab = window.tabs.activeTab;
+
+ let chromeWindow = getMostRecentBrowserWindow();
+ let contentWindow = chromeWindow.content;
+
+ assert.equal(getDOMWindow(window), chromeWindow, "getDOMWindow should have worked for a window");
+ assert.equal(getDOMWindow(tab), contentWindow, "getDOMWindow should have worked for a window");
+}
+
if (require("sdk/system/xul-app").is("Fennec")) {
module.exports = {
"test Unsupported Test": function UnsupportedTest (assert) {

0 comments on commit 8256565

Please sign in to comment.
Something went wrong with that request. Please try again.