PDA

View Full Version : HTA mode fails to load Ext



Flavour
31 Jan 2011, 3:29 PM
Ext version tested:


Ext 3.3.1



Adapter used:


ext
jquery



css used:


only default ext-all.css
no CSS



Browser versions tested against:


IE8



Operating System:


Win7



Description:


When running in HTA mode, Ext fails to load when loaded in Head. Unfortunately Selenium uses HTA mode, so this means that IE is untestable with Selenium :/



Test Case:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://extjs.cachefly.net/ext-3.3.1/adapter/ext/ext-base.js" type="text/javascript"></script>
<script src="http://extjs.cachefly.net/ext-3.3.1/ext-all-debug.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>


Steps to reproduce the problem:


Create HTML above
Point a Selenium test at it



The result that was expected:


Page loads without error



The result that occurs instead:


ext-all-debug.js +4907 char 13
'body' is null or not an object



Debugging already done:


Have passed the <meta http-equiv="X-UA-Compatible" content="IE=edge"> & patched Ext to recognise this (as per http://www.sencha.com/forum/showthread.php?100792-INFOREQ-1032-IE8-browser-detection-problem-on-intranet), so I can see that IE renders as IE8 & Ext also has isIE8 set properly: make sno odds to this issue
Have put a setTimeout loop checking doc.body before the doc.body.appendChild(div); (inspired by http://www.sencha.com/forum/showthread.php?118139-JS-error-in-supportTests%28%29-because-DOM-ready-event-firing-too-early as the error I have is in the same function, although comes earlier)
Everything works fine if the Ext scripts are loaded in the body instead of the head (unfortunately this isn't at all easy in my real app!)



Many thanks for taking a look :)

Fran.

stashx
4 Feb 2011, 4:05 AM
Hello Fran,

I had this error with a recent project i had. I don't use Selenium. I didn't even know about it but anyway.

I can reproduce the error using HTA, extjs and raphael.js . If you save your html code in an .hta file and run it, it works fine. you can even set the <HTA:Application> tag and work just fine. but for an unknow reason when raphael.js is present, Ext js reports to have some errors only if you have the hta tag before the Javascript library loading. for example, copy the following code in a .hta file and double click it to open with mshta:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<HTA:APPLICATION id="MyApp" applicationName="My Application" >

<script src="http://extjs.cachefly.net/ext-3.3.1/adapter/ext/ext-base.js" type="text/javascript"></script>
<script src="http://extjs.cachefly.net/ext-3.3.1/ext-all-debug.js" type="text/javascript"></script>
<script type="text/javascript" src="https://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"></script>

</head>
<body>
</body>
</html>

You can fix the above code by ether closing the HTA:application tag (witch most people don't, as the most examples on msdn don't close it. go figure...) like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<HTA:APPLICATION id="MyApp" applicationName="My Application" />

<script src="http://extjs.cachefly.net/ext-3.3.1/adapter/ext/ext-base.js" type="text/javascript"></script>
<script src="http://extjs.cachefly.net/ext-3.3.1/ext-all-debug.js" type="text/javascript"></script>
<script type="text/javascript" src="https://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"></script>

</head>
<body>
</body>
</html>

or by adding the HTA:application tag at the and of the head tag like i do here (with or without closing it):


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="http://extjs.cachefly.net/ext-3.3.1/adapter/ext/ext-base.js" type="text/javascript"></script>
<script src="http://extjs.cachefly.net/ext-3.3.1/ext-all-debug.js" type="text/javascript"></script>
<script type="text/javascript" src="https://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"></script>

<HTA:APPLICATION id="MyApp" applicationName="My Application" />
</head>
<body>
</body>
</html>


I have no idea why this error happens but my guess, on your case, is that Selenium adds the HTA:application tag combined with a script on your page. can you right click on the selenium output and view the source? If so, please report the generated source.


Sorry for using the direct link scripts. i don't do that on my projects.

Hope that helps you solving this bug (?).
StashX


EDIT:
PS: does anyone have to contribute something in my previous post (http://www.sencha.com/forum/showthread.php?99838-CLOSED-Rendering-problem-in-IE8&p=564258&viewfull=1#post564258)? i had replied on a closed thread and i'm not actually sure if anyone inspected it... it is HTA related.

Flavour
4 Feb 2011, 5:48 AM
Thanks for the reply - unfortunately this doesn't seem related enough:
I can indeed right-click & 'View Source' - there are no HTA tags being injected into the application's HTML when browsed by *iehta

More comments/suggestions welcomed :)

F

stashx
4 Feb 2011, 6:17 AM
there are no HTA tags being injected into the application's HTML when browsed by *iehta
you mean that you actully did "Point a Selenium test at it", right?

What happens if you copy the source from the "Selenium output" in a new .hta file and run it?? I'm asking this because i have seen some projects that extend the mshta runtime and that could be the case of Selenium. In this case it could internally change the html code in runtime.

have you tried to test my "working" (2nd or 3rd code) example with Selenium?

StashX

EDIT: Just ignore this post. I had no clue on how this HTA mode of Selenium is implemented...

stashx
4 Feb 2011, 7:24 AM
Ok i managed to test this Selenium hta mode. Could they make it more difficult to understand what you have to do???....

Anyway i found that the bug is not related with ext in this case but the Selenium it self....

In order to fix the issues with the ExtJs, you have to edit the "TestRunner.hta" and go to line 169.

There is the iframe tag where you sould add the Application attribute (http://msdn.microsoft.com/en-us/library/ms536474%28v=vs.85%29.aspx) like this:


<iframe name="selenium_myiframe" id="selenium_myiframe" src="TestRunner-splash.html" application="yes"></iframe>

Doing so, TestJavaScriptAttributes will fail but i think it shouldn't because it actually alerts the "foo" msg.
I noticed that this same test passes without the application attribute but there is no alert shown. Isn't this behavior wrong??

Enough said about the Selenium.. Use my patch and you'll be just fine i guess... If not, i suggest you should seek for more help on the Selenium community.

let me know if it actually work for you ;) ..

StashX

stashx
4 Feb 2011, 7:38 AM
You can also avoid editing the Selenium and get your case work, if you include ExtJs from local resources. This error seams to happen in your case due to HTA's security policy (http://msdn.microsoft.com/en-us/library/ms536496%28v=vs.85%29.aspx#Security). You are trying to load external javascript in a non trusted iframe (that's what the previous patch do, lets the iframe page to be trusted)...

So download ExtJS, extract it in a folder named "extjs" in the same path with your testing html and make your testing html look like this code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="extjs/adapter/ext/ext-base.js" type="text/javascript"></script>
<script src="extjs/ext-all-debug.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>

Cheers,
StashX

Flavour
4 Feb 2011, 11:17 AM
I just tried with the HTA tag &, as you predicted, it doesn't help.
I actually used local resources to start with - this doesn't help.
I will now try to compile a new .jar with the modified TestRunner.hta

Thanks for your interest/help :)

F

Flavour
4 Feb 2011, 12:10 PM
I see that TestRunner.hta does have the HTA tag at the top of HEAD.
However it is very hard to change this code which is embedded inside the .jar (I am using RC not Core).

Digging around I have managed to find a workaround:
Using *piiexplore mode instead of *iehta mode

Many thanks!
Fran