dom/base/ObjectWrapper.jsm

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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