mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 811615 - Miss file name when passing file by Web Activity (part 2, ObjectWrapper.jsm). r=fabrice, a=blocking-basecamp
This commit is contained in:
parent
bc4bf082d3
commit
a7017b68e1
@ -13,14 +13,16 @@ this.EXPORTED_SYMBOLS = ["ObjectWrapper"];
|
||||
// Makes sure that we expose correctly chrome JS objects to content.
|
||||
|
||||
this.ObjectWrapper = {
|
||||
getObjectKind: function objWrapper_getobjectkind(aObject) {
|
||||
getObjectKind: function objWrapper_getObjectKind(aObject) {
|
||||
if (!aObject) {
|
||||
return "null";
|
||||
}
|
||||
|
||||
if (Array.isArray(aObject)) {
|
||||
return "array";
|
||||
} else if (aObject.mozSlice && (typeof aObject.mozSlice == "function")) {
|
||||
} else if (aObject instanceof Ci.nsIDOMFile) {
|
||||
return "file";
|
||||
} else if (aObject instanceof Ci.nsIDOMBlob) {
|
||||
return "blob";
|
||||
} else if (typeof aObject == "object") {
|
||||
return "object";
|
||||
@ -30,48 +32,35 @@ this.ObjectWrapper = {
|
||||
},
|
||||
|
||||
wrap: function objWrapper_wrap(aObject, aCtxt) {
|
||||
if (!aObject) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// First check wich kind of object we have.
|
||||
let kind = this.getObjectKind(aObject);
|
||||
if (kind == "array") {
|
||||
if (kind == "null") {
|
||||
return null;
|
||||
} else if (kind == "array") {
|
||||
let res = Cu.createArrayIn(aCtxt);
|
||||
aObject.forEach(function(aObj) {
|
||||
res.push(this.wrap(aObj, aCtxt));
|
||||
}, this);
|
||||
return res;
|
||||
} else if (kind == "file") {
|
||||
return new aCtxt.File(aObject,
|
||||
{ name: aObject.name,
|
||||
type: aObject.type });
|
||||
} else if (kind == "blob") {
|
||||
return new aCtxt.Blob([aObject]);
|
||||
} else if (kind == "primitive") {
|
||||
return aObject;
|
||||
}
|
||||
|
||||
// Fall-through, we now have a dictionnary object.
|
||||
// Fall-through, we now have a dictionnary object.
|
||||
let res = Cu.createObjectIn(aCtxt);
|
||||
let propList = { };
|
||||
for (let prop in aObject) {
|
||||
let value;
|
||||
let objProp = aObject[prop];
|
||||
let propKind = this.getObjectKind(objProp);
|
||||
if (propKind == "array") {
|
||||
value = Cu.createArrayIn(aCtxt);
|
||||
objProp.forEach(function(aObj) {
|
||||
value.push(this.wrap(aObj, aCtxt));
|
||||
}, this);
|
||||
} else if (propKind == "blob") {
|
||||
value = new aCtxt.Blob([objProp]);
|
||||
} else if (propKind == "object") {
|
||||
value = this.wrap(objProp, aCtxt);
|
||||
} else {
|
||||
value = objProp;
|
||||
}
|
||||
propList[prop] = {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: value
|
||||
value: this.wrap(aObject[prop], aCtxt)
|
||||
}
|
||||
}
|
||||
Object.defineProperties(res, propList);
|
||||
|
Loading…
Reference in New Issue
Block a user