addon-sdk/source/test/windows/test-fennec-windows.js

branch
TOR_BUG_9701
changeset 10
ac0c01689b40
equal deleted inserted replaced
-1:000000000000 0:d6ceba06c245
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
6 const { Cc, Ci } = require('chrome');
7 const { setTimeout } = require('sdk/timers');
8 const { Loader } = require('sdk/test/loader');
9 const WM = Cc['@mozilla.org/appshell/window-mediator;1'].
10 getService(Ci.nsIWindowMediator);
11 const { browserWindows } = require('sdk/windows');
12
13 const ERR_MSG = 'This method is not yet supported by Fennec, consider using require("sdk/tabs") instead';
14
15 // TEST: browserWindows.length for Fennec
16 exports.testBrowserWindowsLength = function(assert) {
17 assert.equal(browserWindows.length, 1, "Only one window open");
18 };
19
20 // TEST: open & close window
21 exports.testOpenWindow = function(assert) {
22 let tabCount = browserWindows.activeWindow.tabs.length;
23 let url = "data:text/html;charset=utf-8,<title>windows%20API%20test</title>";
24
25 try {
26 browserWindows.open({url: url});
27 assert.fail('Error was not thrown');
28 }
29 catch(e) {
30 assert.equal(e.message, ERR_MSG, 'Error is thrown on windows.open');
31 assert.equal(browserWindows.length, 1, "Only one window open");
32 }
33 };
34
35 exports.testCloseWindow = function(assert) {
36 let window = browserWindows.activeWindow;
37
38 try {
39 window.close();
40 assert.fail('Error was not thrown');
41 }
42 catch(e) {
43 assert.equal(e.message, ERR_MSG, 'Error is thrown on windows.close');
44 assert.equal(browserWindows.length, 1, "Only one window open");
45 }
46 };
47
48 require('sdk/test').run(exports);

mercurial