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.
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 module.metadata = {
7 'engines': {
8 'Firefox': '*'
9 }
10 };
12 const { Cu } = require('chrome');
13 const { getMostRecentBrowserWindow } = require('sdk/window/utils');
14 const { fromIterator } = require('sdk/util/array');
16 const BUILTIN_SIDEBAR_MENUITEMS = exports.BUILTIN_SIDEBAR_MENUITEMS = [
17 'menu_socialSidebar',
18 'menu_historySidebar',
19 'menu_bookmarksSidebar'
20 ];
22 function isSidebarShowing(window) {
23 window = window || getMostRecentBrowserWindow();
24 let sidebar = window.document.getElementById('sidebar-box');
25 return !sidebar.hidden;
26 }
27 exports.isSidebarShowing = isSidebarShowing;
29 function getSidebarMenuitems(window) {
30 window = window || getMostRecentBrowserWindow();
31 return fromIterator(window.document.querySelectorAll('#viewSidebarMenu menuitem'));
32 }
33 exports.getSidebarMenuitems = getSidebarMenuitems;
35 function getExtraSidebarMenuitems() {
36 let menuitems = getSidebarMenuitems();
37 return menuitems.filter(function(mi) {
38 return BUILTIN_SIDEBAR_MENUITEMS.indexOf(mi.getAttribute('id')) < 0;
39 });
40 }
41 exports.getExtraSidebarMenuitems = getExtraSidebarMenuitems;
43 function makeID(id) {
44 return 'jetpack-sidebar-' + id;
45 }
46 exports.makeID = makeID;
48 function simulateCommand(ele) {
49 let window = ele.ownerDocument.defaultView;
50 let { document } = window;
51 var evt = document.createEvent('XULCommandEvent');
52 evt.initCommandEvent('command', true, true, window,
53 0, false, false, false, false, null);
54 ele.dispatchEvent(evt);
55 }
56 exports.simulateCommand = simulateCommand;
58 function simulateClick(ele) {
59 let window = ele.ownerDocument.defaultView;
60 let { document } = window;
61 let evt = document.createEvent('MouseEvents');
62 evt.initMouseEvent('click', true, true, window,
63 0, 0, 0, 0, 0, false, false, false, false, 0, null);
64 ele.dispatchEvent(evt);
65 }
66 exports.simulateClick = simulateClick;
68 // OSX and Windows exhibit different behaviors when 'checked' is false,
69 // so compare against the consistent 'true'. See bug 894809.
70 function isChecked(node) {
71 return node.getAttribute('checked') === 'true';
72 };
73 exports.isChecked = isChecked;