exports.testAPI = assert => { const domain = Math.random().toString(16).substr(2) assert.equal(resolve(`resource://${domain}`), null, "domain isn't mounted"); mount(domain, mountURI); assert.equal(resolve(`resource://${domain}`), mountURI, "domain was mounted"); assert.equal(resolve(`resource://${domain}/foo.js`), `${mountURI}foo.js`, "uri resolves to a file in mounted location"); unmount(domain); assert.equal(resolve(`resource://${domain}`), null, "domain is no longer mounted"); assert.equal(resolve(`resource://${domain}/foo.js`), null, "uris under unmounted domain resolve to null"); };
return prefs.keys(base).reduce((paths, key) => { const value = prefs.get(key); const name = key.replace(base, ""); const path = name.split(".").join("/"); const prefix = path.length ? `${path}/` : path; const uri = value.endsWith("/") ? value : `${value}/`; const root = `extensions.modules.${domain}.commonjs.path.${name}`; mount(root, uri); paths[prefix] = `resource://${root}/`; return paths; }, {});
paths[prefix] = `resource://${root}/`; return paths; }, {}); }; const Bootstrap = function(mountURI) { this.mountURI = mountURI; this.install = this.install.bind(this); this.uninstall = this.uninstall.bind(this); this.startup = this.startup.bind(this); this.shutdown = this.shutdown.bind(this); }; Bootstrap.prototype = { constructor: Bootstrap, mount(domain, rootURI) { mount(domain, rootURI); this.domain = domain; }, unmount() { if (this.domain) { unmount(this.domain); this.domain = null; } }, install(addon, reason) { return new Promise(resolve => resolve()); }, uninstall(addon, reason) { return new Promise(resolve => { const {id} = addon;
exports.main = function (options, callbacks) { // Listen for preference changes prefs.on('largetabs', largeTabsChange); // Register the resource:// alias. mount(RESOURCE_HOST, prefixURI); // Override default preferences utils.setDefaultPrefs(); browserWindows.on('close', function (window) { let win = viewFor(window); if (win.VerticalTabs) { win.VerticalTabs.clearFind(); } }); // Startup VerticalTabs object for each window. for (let window of browserWindows) { //cause no disruption to users when changing the way we handle //the tabsontop pref between v1.26 and v1.27 let win = viewFor(window); let mainWindow = win.document.getElementById('main-window'); let tabbrowser = win.document.getElementById('tabbrowser-tabs'); // opentabstop pref // eslint-disable-next-line no-constant-condition if (mainWindow.getAttribute('doNotReverse') !== 'true' && options.loadReason === 'upgrade' && false) { let reversedTabs = Array.prototype.slice.call(tabbrowser.children).reverse(); for (let tab of reversedTabs) { tabbrowser.appendChild(tab, tabbrowser.firstChild); } } //show onboarding experience in the active window on 'install' if (browserWindows.activeWindow === window && !get('*****@*****.**') && options.loadReason === 'install') { mainWindow.setAttribute('toggledon', 'false'); win.activeInstall = true; } let tabCenterStartup = (options.loadReason === 'startup'); initWindow(window, tabCenterStartup); } windowWatcher.registerNotification({ observe: function observe(subject, topic, data) { try { let window = subject.QueryInterface(Ci.nsIDOMWindow); if (topic === 'domwindowopened') { window.addEventListener('load', () => { initWindow(window); }, {once: true}); } } catch(e) { console.exception(e); // eslint-disable-line no-console } } }); hotkey = Hotkey({ combo: 'accel-shift-l', onPress: function () { let window = viewFor(browserWindows.activeWindow); let input = window.document.getElementById('find-input'); if (input) { let mainWindow = window.document.getElementById('main-window'); let sidebar = window.document.getElementById('verticaltabs-box'); if (mainWindow.getAttribute('tabspinned') === 'true' && input.classList.contains('hide-search')) { return; } if (sidebar.getAttribute('search_expanded') === 'true') { sidebar.removeAttribute('search_expanded'); input.blur(); utils.sendPing('hotkey_off', window); if (mainWindow.getAttribute('tabspinned') !== 'true') { sidebar.removeAttribute('expanded'); window.VerticalTabs.clearFind(); } } else { sidebar.setAttribute('search_expanded', 'true'); sidebar.setAttribute('expanded', 'true'); window.setTimeout(() => { input.focus(); utils.sendPing('hotkey_on', window); }, 150); if (mainWindow.getAttribute('tabspinned') !== 'true') { window.VerticalTabs.recordExpansion(); window.VerticalTabs.adjustCrop(); } } } } }); };