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.

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

mercurial