michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: 'use strict'; michael@0: michael@0: const { Cc, Ci } = require('chrome'); michael@0: const { setTimeout } = require('sdk/timers'); michael@0: const { Loader } = require('sdk/test/loader'); michael@0: const WM = Cc['@mozilla.org/appshell/window-mediator;1']. michael@0: getService(Ci.nsIWindowMediator); michael@0: const { browserWindows } = require('sdk/windows'); michael@0: michael@0: const ERR_MSG = 'This method is not yet supported by Fennec, consider using require("sdk/tabs") instead'; michael@0: michael@0: // TEST: browserWindows.length for Fennec michael@0: exports.testBrowserWindowsLength = function(assert) { michael@0: assert.equal(browserWindows.length, 1, "Only one window open"); michael@0: }; michael@0: michael@0: // TEST: open & close window michael@0: exports.testOpenWindow = function(assert) { michael@0: let tabCount = browserWindows.activeWindow.tabs.length; michael@0: let url = "data:text/html;charset=utf-8,windows%20API%20test"; michael@0: michael@0: try { michael@0: browserWindows.open({url: url}); michael@0: assert.fail('Error was not thrown'); michael@0: } michael@0: catch(e) { michael@0: assert.equal(e.message, ERR_MSG, 'Error is thrown on windows.open'); michael@0: assert.equal(browserWindows.length, 1, "Only one window open"); michael@0: } michael@0: }; michael@0: michael@0: exports.testCloseWindow = function(assert) { michael@0: let window = browserWindows.activeWindow; michael@0: michael@0: try { michael@0: window.close(); michael@0: assert.fail('Error was not thrown'); michael@0: } michael@0: catch(e) { michael@0: assert.equal(e.message, ERR_MSG, 'Error is thrown on windows.close'); michael@0: assert.equal(browserWindows.length, 1, "Only one window open"); michael@0: } michael@0: }; michael@0: michael@0: require('sdk/test').run(exports);