On a related note, I am encountering another issue in trying to write
a test to cover one of our scenarios and I don't know if it's a FF2
compatibility issue or if I'm just asking too much of the simulated
environment provided by crosscheck, or what... but the scenario is
basically this:
We have code that creates an iframe and then periodically goes in and
updates one of the divs in the document in the iframe. I can't post
the raw code, but the code that does this looks roughly like this:
updateXXX: function(name)
{
var newString = '[Prefix] - ' + name;
var iframe = this._previouslyStoredReferenceToIFrame;
if (iframe)
{
var doc = iframe.contentWindow || iframe.contentDocument;
if (doc.document)
{
doc = doc.document;
}
doc.getElementById('theIdOfTheElementToBeUpdated').innerHTML =
newString;
}
else
{
LOG.debug('Could not get iframe.')
}
}
The test I wrote to test this code looks roughly like this:
testUpdateXXX: function() {
var scwm = new ObjectUnderTest();
var expected = '[Prefix] - Example';
var iframe = document.createElement('iframe');
iframe.id = 'someSpecificId';
document.body.appendChild(iframe);
if (iframe)
{
var doc = iframe.contentWindow || iframe.contentDocument;
assertNotNull(doc);
if (doc.document)
{
doc = doc.document;
}
var div = doc.createElement('theIdOfTheElementToBeUpdated');
assertEquals('Something', div.innerHTML);
assertNotEquals(expected, div.innerHTML);
scwm.updateXXX('Example')
assertEquals(expected, div.innerHTML);
}
else
{
fail('Could not get iframe')
}
}
And my test class always bombs at the assertNotNull(doc) line --
presumably because the simulated environment is not doing everything
the real browser does when I create an iframe element and add it to
the DOM? Am I wrong in my hypothesis? Is this actually a FF2
compatibility issue? If not, is there an alternative (ideally
easier?) way for me to test code that does something like this?
Thanks,
-
John
On Mar 25, 10:59 pm, "
wadswo...@thefrontside.net"