Bug 350558: work around the fact that arrays from a sandbox are only instanceof sandbox.Array (and not instanceof Array), patch by Simon Bünzli <zeniko@gmail.com>, r=mano

git-svn-id: svn://10.0.0.236/trunk@213417 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
gavin%gavinsharp.com
2006-10-10 13:46:21 +00:00
parent dcd82fe780
commit 2734d7a2c8

View File

@@ -124,6 +124,9 @@ const CAPABILITIES = [
"Subframes", "Plugins", "Javascript", "MetaRedirects", "Images"
];
// sandbox to evaluate JavaScript code from non-trustable sources
var EVAL_SANDBOX = new Components.utils.Sandbox("about:blank");
function debug(aMsg) {
aMsg = ("SessionStore: " + aMsg).replace(/\S{80}/g, "$&\n");
Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService)
@@ -1218,8 +1221,7 @@ SessionStoreService.prototype = {
}
}
if (winData._closedTabs && (root._firstTabs || aOverwriteTabs)) {
//XXXzeniko remove the slice call as soon as _closedTabs instanceof Array
this._windows[aWindow.__SSi]._closedTabs = winData._closedTabs.slice();
this._windows[aWindow.__SSi]._closedTabs = winData._closedTabs;
}
this.restoreHistoryPrecursor(aWindow, winData.tabs, (aOverwriteTabs ?
@@ -1870,8 +1872,7 @@ SessionStoreService.prototype = {
* safe eval'ing
*/
_safeEval: function sss_safeEval(aStr) {
var s = new Components.utils.Sandbox("about:blank");
return Components.utils.evalInSandbox(aStr, s);
return Components.utils.evalInSandbox(aStr, EVAL_SANDBOX);
},
/**
@@ -1913,7 +1914,7 @@ SessionStoreService.prototype = {
else if (aObj == null) {
parts.push("null");
}
else if (aObj instanceof Array) {
else if (aObj instanceof Array || aObj instanceof EVAL_SANDBOX.Array) {
parts.push("[");
for (var i = 0; i < aObj.length; i++) {
jsonIfy(aObj[i]);