Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | 'use strict'; |
michael@0 | 2 | |
michael@0 | 3 | const { open, focus, close } = require('sdk/window/helpers'); |
michael@0 | 4 | const { isPrivate } = require('sdk/private-browsing'); |
michael@0 | 5 | const { defer } = require('sdk/core/promise'); |
michael@0 | 6 | const { browserWindows: windows } = require('sdk/windows'); |
michael@0 | 7 | |
michael@0 | 8 | const BROWSER = 'chrome://browser/content/browser.xul'; |
michael@0 | 9 | |
michael@0 | 10 | exports.testRequirePanel = function(assert) { |
michael@0 | 11 | require('sdk/panel'); |
michael@0 | 12 | assert.ok('the panel module should not throw an error'); |
michael@0 | 13 | }; |
michael@0 | 14 | |
michael@0 | 15 | exports.testShowPanelInPrivateWindow = function(assert, done) { |
michael@0 | 16 | let panel = require('sdk/panel').Panel({ |
michael@0 | 17 | contentURL: "data:text/html;charset=utf-8," |
michael@0 | 18 | }); |
michael@0 | 19 | |
michael@0 | 20 | assert.ok(windows.length > 0, 'there is at least one open window'); |
michael@0 | 21 | for (let window of windows) { |
michael@0 | 22 | assert.equal(isPrivate(window), false, 'open window is private'); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | testShowPanel(assert, panel). |
michael@0 | 26 | then(makeEmptyPrivateBrowserWindow). |
michael@0 | 27 | then(focus). |
michael@0 | 28 | then(function(window) { |
michael@0 | 29 | assert.equal(isPrivate(window), true, 'opened window is private'); |
michael@0 | 30 | assert.pass('private window was focused'); |
michael@0 | 31 | return window; |
michael@0 | 32 | }). |
michael@0 | 33 | then(function(window) { |
michael@0 | 34 | let { promise, resolve } = defer(); |
michael@0 | 35 | |
michael@0 | 36 | assert.ok(!panel.isShowing, 'the panel is not showing [1]'); |
michael@0 | 37 | |
michael@0 | 38 | panel.once('show', function() { |
michael@0 | 39 | assert.ok(panel.isShowing, 'the panel is showing'); |
michael@0 | 40 | |
michael@0 | 41 | panel.once('hide', function() { |
michael@0 | 42 | assert.ok(!panel.isShowing, 'the panel is not showing [2]'); |
michael@0 | 43 | |
michael@0 | 44 | resolve(window); |
michael@0 | 45 | }); |
michael@0 | 46 | |
michael@0 | 47 | panel.hide(); |
michael@0 | 48 | }); |
michael@0 | 49 | |
michael@0 | 50 | panel.show(); |
michael@0 | 51 | |
michael@0 | 52 | return promise; |
michael@0 | 53 | }). |
michael@0 | 54 | then(close). |
michael@0 | 55 | then(done). |
michael@0 | 56 | then(null, assert.fail); |
michael@0 | 57 | }; |
michael@0 | 58 | |
michael@0 | 59 | |
michael@0 | 60 | function makeEmptyPrivateBrowserWindow(options) { |
michael@0 | 61 | options = options || {}; |
michael@0 | 62 | return open(BROWSER, { |
michael@0 | 63 | features: { |
michael@0 | 64 | chrome: true, |
michael@0 | 65 | toolbar: true, |
michael@0 | 66 | private: true |
michael@0 | 67 | } |
michael@0 | 68 | }); |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | function testShowPanel(assert, panel) { |
michael@0 | 72 | let { promise, resolve } = defer(); |
michael@0 | 73 | let shown = false; |
michael@0 | 74 | |
michael@0 | 75 | assert.ok(!panel.isShowing, 'the panel is not showing [1]'); |
michael@0 | 76 | |
michael@0 | 77 | panel.once('hide', function() { |
michael@0 | 78 | assert.ok(!panel.isShowing, 'the panel is not showing [2]'); |
michael@0 | 79 | assert.ok(shown, 'the panel was shown') |
michael@0 | 80 | |
michael@0 | 81 | resolve(null); |
michael@0 | 82 | }); |
michael@0 | 83 | |
michael@0 | 84 | panel.once('show', function() { |
michael@0 | 85 | shown = true; |
michael@0 | 86 | |
michael@0 | 87 | assert.ok(panel.isShowing, 'the panel is showing'); |
michael@0 | 88 | |
michael@0 | 89 | panel.hide(); |
michael@0 | 90 | }); |
michael@0 | 91 | |
michael@0 | 92 | panel.show(); |
michael@0 | 93 | |
michael@0 | 94 | return promise; |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | //Test disabled because of bug 911071 |
michael@0 | 98 | module.exports = {} |