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:11:47 +00:00
parent 865ba17efb
commit ac6dbad373
6 changed files with 55 additions and 36 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

@ -325,7 +325,7 @@ var et2_tabbox = et2_valueWidget.extend([et2_IInput,et2_IResizeable],
if (entry.widget_options && typeof entry.widget_options.class != 'undefined')
{
entry.flagDiv.addClass(entry.widget_options.class);
}
}
entry.flagDiv.text(entry.label || "Tab");
if(entry.hidden)
{
@ -431,13 +431,13 @@ var et2_tabbox = et2_valueWidget.extend([et2_IInput,et2_IResizeable],
return null;
}
},
set_tab_height: function (_height)
{
this.tab_height = _height;
this.tabContainer.css("height", _height);
},
set_height: function(_value) {
this.height = _value;
@ -469,7 +469,7 @@ var et2_tabbox = et2_valueWidget.extend([et2_IInput,et2_IResizeable],
isValid: function(messages) {
return true;
},
resize: function (_height)
{
if(_height)

View File

@ -188,7 +188,7 @@ var et2_taglist = et2_selectbox.extend(
// Unbind change handler of widget's ancestor to stop it from bubbling
// taglist has its own onchange
$j(this.getDOMNode()).unbind('change.et2_inputWidget');
// onChange
if(this.options.onchange && typeof this.options.onchange == 'function')
{
@ -261,7 +261,7 @@ var et2_taglist = et2_selectbox.extend(
{
var label = jQuery('<span>').text(item.label);
if (typeof item.title != 'undefined') label.attr('title', item.title);
return label;
},
@ -560,7 +560,7 @@ var et2_taglist_email = et2_taglist.extend(
for(var i=0; i < parts.length; ++i)
{
items.push({id: parts[i], label: parts[i]});
}
taglist.addToSelection(items);
}, 10);
@ -610,4 +610,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

@ -107,16 +107,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
*
@ -541,33 +545,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);
};
@ -596,7 +605,7 @@ etemplate2.prototype.autocomplete_fixer = function ()
{
var self = this;
var form = self.DOMContainer;
// Safari always do the autofill for password field regardless of autocomplete = off
// and since there's no other way to switch the autocomplete of, we should switch the
// form autocomplete off (e.g. compose dialog, attachment password field)
@ -605,7 +614,7 @@ etemplate2.prototype.autocomplete_fixer = function ()
{
return;
}
if (form)
{
// Stop submit propagation in order to not fire other possible submit events

View File

@ -17,7 +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');