1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/addon-sdk/source/test/windows/test-fennec-windows.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 +'use strict'; 1.8 + 1.9 +const { Cc, Ci } = require('chrome'); 1.10 +const { setTimeout } = require('sdk/timers'); 1.11 +const { Loader } = require('sdk/test/loader'); 1.12 +const WM = Cc['@mozilla.org/appshell/window-mediator;1']. 1.13 + getService(Ci.nsIWindowMediator); 1.14 +const { browserWindows } = require('sdk/windows'); 1.15 + 1.16 +const ERR_MSG = 'This method is not yet supported by Fennec, consider using require("sdk/tabs") instead'; 1.17 + 1.18 +// TEST: browserWindows.length for Fennec 1.19 +exports.testBrowserWindowsLength = function(assert) { 1.20 + assert.equal(browserWindows.length, 1, "Only one window open"); 1.21 +}; 1.22 + 1.23 +// TEST: open & close window 1.24 +exports.testOpenWindow = function(assert) { 1.25 + let tabCount = browserWindows.activeWindow.tabs.length; 1.26 + let url = "data:text/html;charset=utf-8,<title>windows%20API%20test</title>"; 1.27 + 1.28 + try { 1.29 + browserWindows.open({url: url}); 1.30 + assert.fail('Error was not thrown'); 1.31 + } 1.32 + catch(e) { 1.33 + assert.equal(e.message, ERR_MSG, 'Error is thrown on windows.open'); 1.34 + assert.equal(browserWindows.length, 1, "Only one window open"); 1.35 + } 1.36 +}; 1.37 + 1.38 +exports.testCloseWindow = function(assert) { 1.39 + let window = browserWindows.activeWindow; 1.40 + 1.41 + try { 1.42 + window.close(); 1.43 + assert.fail('Error was not thrown'); 1.44 + } 1.45 + catch(e) { 1.46 + assert.equal(e.message, ERR_MSG, 'Error is thrown on windows.close'); 1.47 + assert.equal(browserWindows.length, 1, "Only one window open"); 1.48 + } 1.49 +}; 1.50 + 1.51 +require('sdk/test').run(exports);