fixing wired IE security errors "Permission denied", seems reload of opener caused references to egw and template cache in opener.top.etemplate2.prototype.templates becomming inaccessible, catching this errors and falling back to a window-local object

This commit is contained in:
Ralf Becker 2015-10-26 21:13:34 +00:00
parent 1f2c9e641a
commit b18d373624
6 changed files with 55 additions and 39 deletions

View File

@ -952,7 +952,7 @@ var et2_widget = ClassWithAttributes.extend(
* @param {string} _part name of array mgr to return * @param {string} _part name of array mgr to return
*/ */
getArrayMgr: function(_part) { getArrayMgr: function(_part) {
if (typeof this._mgrs[_part] != "undefined") if (this._mgrs && typeof this._mgrs[_part] != "undefined")
{ {
return this._mgrs[_part]; return this._mgrs[_part];
} }

View File

@ -627,4 +627,4 @@ et2_register_widget(et2_taglist_ro, ["taglist_ro","taglist_email_ro", "taglist_a
// Require css // Require css
// TODO: merge into etemplate2.css with all other widgets when done // TODO: merge into etemplate2.css with all other widgets when done
if(typeof egw != 'undefined') egw(window).includeCSS(egw.webserverUrl + "/phpgwapi/js/jquery/magicsuggest/magicsuggest.css"); if(typeof egw == 'function') egw(window).includeCSS(egw.webserverUrl + "/phpgwapi/js/jquery/magicsuggest/magicsuggest.css");

View File

@ -108,16 +108,20 @@ try {
{ {
etemplate2.prototype.templates = opener.etemplate2.prototype.templates; etemplate2.prototype.templates = opener.etemplate2.prototype.templates;
} }
else if (top.etemplate2)
{
etemplate2.prototype.templates = top.etemplate2.prototype.templates;
}
} }
catch (e) { catch (e) {
// catch security exception if opener is from a different domain // catch security exception if opener is from a different domain
console.log('Security exception accessing etemplate2.prototype of opener or top!');
} }
if (typeof etemplate2.prototype.templates == "undefined") if (typeof etemplate2.prototype.templates == "undefined")
{ {
etemplate2.prototype.templates = top.etemplate2.prototype.templates || {}; etemplate2.prototype.templates = {};
} }
/** /**
* Calls the resize event of all widgets * Calls the resize event of all widgets
* *
@ -552,8 +556,22 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback)
// Load & process // Load & process
if(!this.templates[_name]) try {
if (this.templates[_name])
{ {
// Set array managers first, or errors will happen
this.widgetContainer.setArrayMgrs(this._createArrayManagers(_data));
// Already have it
_load.apply(this,[]);
return;
}
}
catch (e) {
// wired security exception in IE denying access to template cache in opener
//this.templates =
etemplate2.prototype.templates = {};
}
// Asynchronously load the XET file // Asynchronously load the XET file
et2_loadXMLFromURL(_url, function(_xmldoc) { et2_loadXMLFromURL(_url, function(_xmldoc) {
@ -570,15 +588,6 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback)
// Split the given data into array manager objects and pass those to the // Split the given data into array manager objects and pass those to the
// widget container - do this here because file is loaded async // widget container - do this here because file is loaded async
this.widgetContainer.setArrayMgrs(this._createArrayManagers(_data)); this.widgetContainer.setArrayMgrs(this._createArrayManagers(_data));
}
else
{
// Set array managers first, or errors will happen
this.widgetContainer.setArrayMgrs(this._createArrayManagers(_data));
// Already have it
_load.apply(this,[]);
}
}, this); }, this);
}; };

View File

@ -17,10 +17,7 @@
*/ */
// Need CSS, or it doesn't really work // Need CSS, or it doesn't really work
if(typeof egw != 'undefined') if(typeof egw == 'function') egw(window).includeCSS(egw.webserverUrl + "/phpgwapi/js/egw_action/test/skins/dhtmlxmenu_egw.css");
{
egw(window).includeCSS(egw.webserverUrl + "/phpgwapi/js/egw_action/test/skins/dhtmlxmenu_egw.css");
}
function egwMenuImpl(_structure) function egwMenuImpl(_structure)
{ {
//Create a new dhtmlxmenu object //Create a new dhtmlxmenu object

View File

@ -129,6 +129,16 @@
window.location.search += window.location.search ? "&cd=yes" : "?cd=yes"; window.location.search += window.location.search ? "&cd=yes" : "?cd=yes";
} }
} }
try {
egw(window).message;
}
catch (e) {
console.log('Security exception accessing window specific egw object --> creating new one', e);
window.egw = {
prefsOnly: true,
webserverUrl: egw_webserverUrl
};
}
// focus window / call window.focus(), if data-window-focus is specified // focus window / call window.focus(), if data-window-focus is specified
var window_focus = egw_script.getAttribute('data-window-focus'); var window_focus = egw_script.getAttribute('data-window-focus');