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
*/
getArrayMgr: function(_part) {
if (typeof this._mgrs[_part] != "undefined")
if (this._mgrs && typeof this._mgrs[_part] != "undefined")
{
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
// 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;
}
else if (top.etemplate2)
{
etemplate2.prototype.templates = top.etemplate2.prototype.templates;
}
}
catch (e) {
// 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")
{
etemplate2.prototype.templates = top.etemplate2.prototype.templates || {};
etemplate2.prototype.templates = {};
}
/**
* Calls the resize event of all widgets
*
@ -552,33 +556,38 @@ etemplate2.prototype.load = function(_name, _url, _data, _callback)
// Load & process
if(!this.templates[_name])
{
// Asynchronously load the XET file
et2_loadXMLFromURL(_url, function(_xmldoc) {
try {
if (this.templates[_name])
{
// Set array managers first, or errors will happen
this.widgetContainer.setArrayMgrs(this._createArrayManagers(_data));
// Scan for templates and store them
for(var i = 0; i < _xmldoc.childNodes.length; i++) {
var template = _xmldoc.childNodes[i];
if(template.nodeName.toLowerCase() != "template") continue;
this.templates[template.getAttribute("id")] = template;
if(!_name) this.name = template.getAttribute("id");
}
// Already have it
_load.apply(this,[]);
}, this);
// Split the given data into array manager objects and pass those to the
// widget container - do this here because file is loaded async
this.widgetContainer.setArrayMgrs(this._createArrayManagers(_data));
return;
}
}
else
{
// Set array managers first, or errors will happen
this.widgetContainer.setArrayMgrs(this._createArrayManagers(_data));
catch (e) {
// wired security exception in IE denying access to template cache in opener
//this.templates =
etemplate2.prototype.templates = {};
}
// Asynchronously load the XET file
et2_loadXMLFromURL(_url, function(_xmldoc) {
// Already have it
// Scan for templates and store them
for(var i = 0; i < _xmldoc.childNodes.length; i++) {
var template = _xmldoc.childNodes[i];
if(template.nodeName.toLowerCase() != "template") continue;
this.templates[template.getAttribute("id")] = template;
if(!_name) this.name = template.getAttribute("id");
}
_load.apply(this,[]);
}
}, this);
// Split the given data into array manager objects and pass those to the
// widget container - do this here because file is loaded async
this.widgetContainer.setArrayMgrs(this._createArrayManagers(_data));
}, this);
};

View File

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

View File

@ -129,6 +129,16 @@
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
var window_focus = egw_script.getAttribute('data-window-focus');