dom/base/ObjectWrapper.jsm

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 file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 "use strict"
     7 const Cu = Components.utils;
     8 const Cc = Components.classes;
     9 const Ci = Components.interfaces;
    11 this.EXPORTED_SYMBOLS = ["ObjectWrapper"];
    13 // Makes sure that we expose correctly chrome JS objects to content.
    15 const TypedArrayThings = [
    16   "Int8Array",
    17   "Uint8Array",
    18   "Uint8ClampedArray",
    19   "Int16Array",
    20   "Uint16Array",
    21   "Int32Array",
    22   "Uint32Array",
    23   "Float32Array",
    24   "Float64Array",
    25 ];
    27 this.ObjectWrapper = {
    28   getObjectKind: function objWrapper_getObjectKind(aObject) {
    29     if (aObject === null || aObject === undefined) {
    30       return "primitive";
    31     } else if (Array.isArray(aObject)) {
    32       return "array";
    33     } else if (aObject instanceof Ci.nsIDOMFile) {
    34       return "file";
    35     } else if (aObject instanceof Ci.nsIDOMBlob) {
    36       return "blob";
    37     } else if (aObject instanceof Date) {
    38       return "date";
    39     } else if (TypedArrayThings.indexOf(aObject.constructor.name) !== -1) {
    40       return aObject.constructor.name;
    41     } else if (typeof aObject == "object") {
    42       return "object";
    43     } else {
    44       return "primitive";
    45     }
    46   },
    48   wrap: function objWrapper_wrap(aObject, aCtxt) {
    49     dump("-*- ObjectWrapper is deprecated. Use Components.utils.cloneInto() instead.\n");
    50     return Cu.cloneInto(aObject, aCtxt, { cloneFunctions: true });
    51   }
    52 }

mercurial