addon-sdk/source/lib/sdk/private-browsing/window/utils.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 };
    10 const privateNS = require('../../core/namespace').ns();
    12 function getOwnerWindow(thing) {
    13   try {
    14     // check for and return associated window
    15     let fn = (privateNS(thing.prototype) || privateNS(thing) || {}).getOwnerWindow;
    17     if (fn)
    18       return fn.apply(fn, [thing].concat(arguments));
    19   }
    20   // stuff like numbers and strings throw errors with namespaces
    21   catch(e) {}
    22   // default
    23   return undefined;
    24 }
    25 getOwnerWindow.define = function(Type, fn) {
    26   privateNS(Type.prototype).getOwnerWindow = fn;
    27 }
    29 getOwnerWindow.implement = function(instance, fn) {
    30   privateNS(instance).getOwnerWindow = fn;
    31 }
    33 exports.getOwnerWindow = getOwnerWindow;

mercurial