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.

     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';
     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');
    13 const ERR_MSG = 'This method is not yet supported by Fennec, consider using require("sdk/tabs") instead';
    15 // TEST: browserWindows.length for Fennec
    16 exports.testBrowserWindowsLength = function(assert) {
    17   assert.equal(browserWindows.length, 1, "Only one window open");
    18 };
    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>";
    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 };
    35 exports.testCloseWindow = function(assert) {
    36   let window = browserWindows.activeWindow;
    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 };
    48 require('sdk/test').run(exports);

mercurial