Opened 5 years ago

Closed 5 years ago

#8302 closed defect (fixed)

Dynamic dojox.image.LightboxDialog causes invalid GET requests to server in IE6

Reported by: Arech Owned by: dante
Priority: high Milestone: 1.3
Component: DojoX Widgets Version: 1.2.3
Keywords: Cc:
Blocked by: Blocking:

Description

During page load or while processing .show(), dojox.image.LightboxDialog causes Internet Explorer 6 (WinXP) to emit invalid GET requests to the server that hosts page.
Say you have a page that uses dojox.image.LightboxDialog at http://your_site/test/test.html. During dojox.image.LightboxDialog usage in IE you may observe an http GET requests to http://your_site/test. Most of them will be aborted very soon by IE, but some will succeed possibly causing your server to overload.

I) To reproduce invalid GET requests on page load do the folling:
1) create test html file with the content:
============= start of bad_lightbox_in_IE.html ==============
<!DOCTYPE HTML PUBLIC "-W3CDTD HTML 4.01EN"

"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>

<title>dojox.image.LightboxDialog causes bad GET requests in IE</title>

<!-- required: a default theme file -->
<link rel="stylesheet" id="themeStyles" href="/js/dojo/dijit/themes/tundra/tundra.css">
<link rel="stylesheet" href="/js/dojo/dojox/image/resources/image.css">


<style type="text/css">

@import "/js/dojo/dojo/resources/dojo.css";
@import "/js/dojo/dijit/tests/css/dijitTests.css";
body, html { width:100%; height:100%; margin:0; padding:0; }

</style>


<!-- required: dojo.js -->
<script type="text/javascript" src="/js/dojo/dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script>

<!-- for debugging: -->
<script type="text/javascript" src="/js/dojo/dojox/image/Lightbox.js"></script>
<script type="text/javascript">

dojo.require("dojox.image.Lightbox");

</script>

<script type="text/javascript">

lightbox=null;

function init(){

lightbox = new dojox.image.LightboxDialog;
lightbox.startup();
lightbox.addImage({title: 'image', href: 'http://dojocampus.org/dojotoolkit/dojox/image/tests/images/imageVert.jpg'}, 'test');

}
dojo.addOnLoad(init);

showlb = function(){

lightbox.show({title: 'image', href: 'http://dojocampus.org/dojotoolkit/dojox/image/tests/images/imageVert.jpg'});

}

</script>

</head>
<body class="tundra">
<div onclick='showlb();'>Click me to open Lightbox!</div>
</body>
</html>
============= end of bad_lightbox_in_IE.html ==============
Dojo should be located in /js/dojo subdirectory of your htdocs.
2) upload the html to your web server
3) open IE, open HTTP monitor (I use IEWebDeveloperV2).
4) type the page address to IE address bar and press enter
5) see during the page load requests:
GET 200 1.05 K text/html http://your_site/js/dojo/dojox/image/resources/Lightbox.html
GET Aborted 0 (None) http://your_site/test/
GET Aborted 0 (None) http://your_site/test/
GET 200 6.24 K text/html http://your_site/test/

I think, thats is happening because LightboxDialog.imgUrl property is defined as "" (empty string) and when it gets inserted in Lightbox template, and the template gets inserted into DOM, IE tries to load image with src= and it leads to http://your_site/test/ request.
To prove it, please, change line 147 of .\dojo\dojox\image\Lightbox.js from

imgUrl: "",

to

imgUrl: dojo.moduleUrl("dojox.image","resources/images/warning.png"),

and reload the page (remember to upload it to server and to clean IE cache before). You will not see any GET http://your_site/test/ requests then. (They will be changed to GET http://your_site/js/dojo/dojox/resources/images/warning.png)

II) There is at least one similar error in dojox.image.LightboxDialog, but I failed to reproduce it in test page though it exists on my production site.
The problem is in LightboxDialog.show() function - it causes the same GET http://your_site/test/ request on every but first execution.
The problem hides in the following code starting at line 211 of .\dojo\dojox\image\Lightbox.js:

if(this._wasStyled){

ugly fix for IE being stupid:
dojo._destroyElement(_t.imgNode);
_t.imgNode = dojo.clone(_t._clone);
dojo.place(_t.imgNode,_t.imageContainer,"first");
_t._makeAnims();
_t._wasStyled = false;

}

dojo.style(_t.imgNode,"opacity","0");
dojo.style(_t.titleNode,"opacity","0");

_t._imageReady = false;
_t.imgNode.src = groupData.href;

If the cloning node (_t._clone) don't have src attribute specified, then after it get inserted to DOM with dojo.place(), IE will generate invalid GET http://your_site/test/ that can be completed before execution of _t.imgNode.src = groupData.href; on slow PCs in some rare cases.

So, I would advice to correct this code at least to

_t._imageReady = false;
if(this._wasStyled){

ugly fix for IE being stupid:
dojo._destroyElement(_t.imgNode);
_t.imgNode = dojo.clone(_t._clone);
_t.imgNode.src = groupData.href;
dojo.place(_t.imgNode,_t.imageContainer,"first");
_t._makeAnims();
_t._wasStyled = false;

}else{

_t.imgNode.src = groupData.href;

}

dojo.style(_t.imgNode,"opacity","0");
dojo.style(_t.titleNode,"opacity","0");

I hope all correction I offered are clean & easy to be included in the very next Dojo minor release.

Please, feel free to contact me over email arech2004 at mail dot ru, if any assistance needed.

Attachments (1)

bad_lightbox_in_IE.html (1.5 KB) - added by Arech 5 years ago.
test page to demonstrate invalid GET requests in IE during page load.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by Arech

test page to demonstrate invalid GET requests in IE during page load.

comment:1 Changed 5 years ago by dante

  • Milestone changed from tbd to 1.4
  • Priority changed from normal to high
  • Status changed from new to assigned

so there are some critical things I want to look at for lightbox wrt to 1.3, but doubt that is going to happen even. ff3 is giving me much trouble, and there is a css issue with contentpane perhaps. i want to get all lightbox things cleaned up by 1.4 - so marking as such.

comment:2 Changed 5 years ago by dante

  • Milestone changed from 1.4 to 1.3
  • Resolution set to fixed
  • Status changed from assigned to closed

i fixed most of this in the latest changes (imgUrl is set to the default blank image in dijit by default)

please open a new ticket it the other issue still exists.

Note: See TracTickets for help on using tickets.