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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4 'use strict';
michael@0 5
michael@0 6 const { Cc, Ci } = require('chrome');
michael@0 7 const { setTimeout } = require('sdk/timers');
michael@0 8 const { Loader } = require('sdk/test/loader');
michael@0 9 const WM = Cc['@mozilla.org/appshell/window-mediator;1'].
michael@0 10 getService(Ci.nsIWindowMediator);
michael@0 11 const { browserWindows } = require('sdk/windows');
michael@0 12
michael@0 13 const ERR_MSG = 'This method is not yet supported by Fennec, consider using require("sdk/tabs") instead';
michael@0 14
michael@0 15 // TEST: browserWindows.length for Fennec
michael@0 16 exports.testBrowserWindowsLength = function(assert) {
michael@0 17 assert.equal(browserWindows.length, 1, "Only one window open");
michael@0 18 };
michael@0 19
michael@0 20 // TEST: open & close window
michael@0 21 exports.testOpenWindow = function(assert) {
michael@0 22 let tabCount = browserWindows.activeWindow.tabs.length;
michael@0 23 let url = "data:text/html;charset=utf-8,<title>windows%20API%20test</title>";
michael@0 24
michael@0 25 try {
michael@0 26 browserWindows.open({url: url});
michael@0 27 assert.fail('Error was not thrown');
michael@0 28 }
michael@0 29 catch(e) {
michael@0 30 assert.equal(e.message, ERR_MSG, 'Error is thrown on windows.open');
michael@0 31 assert.equal(browserWindows.length, 1, "Only one window open");
michael@0 32 }
michael@0 33 };
michael@0 34
michael@0 35 exports.testCloseWindow = function(assert) {
michael@0 36 let window = browserWindows.activeWindow;
michael@0 37
michael@0 38 try {
michael@0 39 window.close();
michael@0 40 assert.fail('Error was not thrown');
michael@0 41 }
michael@0 42 catch(e) {
michael@0 43 assert.equal(e.message, ERR_MSG, 'Error is thrown on windows.close');
michael@0 44 assert.equal(browserWindows.length, 1, "Only one window open");
michael@0 45 }
michael@0 46 };
michael@0 47
michael@0 48 require('sdk/test').run(exports);

mercurial