addon-sdk/source/lib/sdk/tabs/helpers.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 module.metadata = {
     7   'stability': 'unstable'
     8 };
    11 // NOTE: This file should only export Tab instances
    14 const { getTabForContentWindow, getTabForBrowser: getRawTabForBrowser } = require('./utils');
    15 const { Tab } = require('./tab');
    16 const { rawTabNS } = require('./namespace');
    18 function getTabForWindow(win) {
    19   let tab = getTabForContentWindow(win);
    20   // We were unable to find the related tab!
    21   if (!tab)
    22     return null;
    24   return getTabForRawTab(tab) || Tab({ tab: tab });
    25 }
    26 exports.getTabForWindow = getTabForWindow;
    28 // only works on fennec atm
    29 function getTabForRawTab(rawTab) {
    30   let tab = rawTabNS(rawTab).tab;
    31   if (tab) {
    32     return tab;
    33   }
    34   return null;
    35 }
    36 exports.getTabForRawTab = getTabForRawTab;
    38 function getTabForBrowser(browser) {
    39   return getTabForRawTab(getRawTabForBrowser(browser));
    40 }
    41 exports.getTabForBrowser = getTabForBrowser;

mercurial