SimpleTest: a Test.Simple replacement

16 views
Skip to first unread message

Leonardo Soto

unread,
Feb 6, 2006, 9:52:08 PM2/6/06
to moch...@googlegroups.com
Hi all!,

I'm working a Test.Simple replacement, that basically inherits the
simplicity of Test.Simple but:

* Works on IE5.5
* Don't require you to count the tests
* Tests that requires elements visible in the browser works in the
TestRunner (Harness).
* Display the test results nicer (IMO).

I wrote this as a solution to the the previous problems encountered
while developing a widget library based on MochiKit.

We are considering supporting IE5.5 on the widget library, and if
that's the case, we need to test MochiKit itself on IE5.5 and patch it
where needed. A patch that uses SimpleTest instead of Test.Simple is
attached.

The downsides:

* SimpleTest itself depends on MochiKit.DOM (once you start working
with MochiKit you start including it almost everywhere ;-) ). If
testing MochiKit with a library that depends on MochiKit is a problem,
the dependency can be avoided.
* SimpleTest only provides ok, is and isDeeply. Nothing more by now.
Anyway, copy and paste from Test.Builder and Test.More is not
difficult at all.

--
Leonardo Soto M.

MochiKit-SimpleTest-dist.diff
MochiKit-SimpleTest-Migration.diff

Bob Ippolito

unread,
Feb 6, 2006, 11:00:49 PM2/6/06
to Leonardo Soto, moch...@googlegroups.com

On Feb 6, 2006, at 6:52 PM, Leonardo Soto wrote:

> Hi all!,
>
> I'm working a Test.Simple replacement, that basically inherits the
> simplicity of Test.Simple but:
>
> * Works on IE5.5
> * Don't require you to count the tests
> * Tests that requires elements visible in the browser works in the
> TestRunner (Harness).
> * Display the test results nicer (IMO).

Great! Did you see that some of this was already done in MochiKit/
Test.js? That's why the non-DOM tests were factored out into
separate .js files, so I could run them with the standalone
SpiderMonkey.

I didn't do the browser stuff though, so I'm just going to take this
as-is and we can look into merging the two soon.

-bob

Bob Ippolito

unread,
Feb 6, 2006, 11:34:29 PM2/6/06
to Leonardo Soto, MochiKit

The test runner doesn't seem to quite work in Safari. I see all of
the results, but the page never quite finishes loading and thus isn't
interactive so I can't see the failures in the Signal tests unless I
go to the HTML directly. I'll see if I can fix this before I check
it in.

-bob

Bob Ippolito

unread,
Feb 7, 2006, 1:16:41 AM2/7/06
to Leonardo Soto, MochiKit

Test.Simple is gone! I made some changes to SimpleTest so that it
works in Safari and Firefox. I have not tested elsewhere.

-bob

Leonardo Soto M

unread,
Feb 7, 2006, 8:03:33 AM2/7/06
to MochiKit
Bob Ippolito wrote:

> [...]


> Test.Simple is gone! I made some changes to SimpleTest so that it
> works in Safari and Firefox. I have not tested elsewhere.

It worked for me on FF 1.5, Opera 8.5, IE 6 and IE 5.5 (Well, not "pure
5.5", I'm using the hack that allows you to have IE 5, 5.5 and 6 on the
same Windows installation).

What stopped SimpleTest from working on Safari?. I've no access to the
Mac world.

The relevant parts of the diff seems to be:

* SimpleTest.waitForExplicitFinish() has been invoked.
**/
SimpleTest.finish = function() {
+ // doesn't fix Safari's incorrect complete count, but it does
+ // make it show everything as loaded in the activity monitor
+ var _doFinish = function () {
SimpleTest.showReport();
SimpleTest.talkToRunner();
+ }
+ setTimeout(_doFinish, 1);
}

/**
* Toggle element visibility
**/
TestRunner._toggle = function(el) {
- if (computedStyle(el, 'display') == 'block') {
- el.style.display = 'none';
+ if (el.className == "noshow") {
+ el.className = "";
+ el.style.cssText = "";
} else {
- el.style.display = 'block';
+ el.className = "noshow";
+ el.style.cssText = "width:0px; height:0px; border:0px;";
}
-}
+};

TestRunner._makeIframe = function (url) {
var iframe = document.createElement('iframe');
- iframe.setAttribute('src', url);
- iframe.setAttribute('name', url);
- iframe.setAttribute('width', '500');
+ iframe.src = url;
+ iframe.name = url;
+ iframe.width = "500";
var tbody = TestRunner._summaryDiv.getElementsByTagName("tbody")[0];
var tr = TR(null, TD({'colspan': '3'}, iframe));
iframe._row = tr;
tbody.appendChild(tr);
return iframe;
-}
+};

What was the problem with manipulating style.display on Safari's
iframes?. What problem the setTimeout hack addresses (on
SimpleTest.finish())?

Just that I'm not familiar with Safari and want to know some of the
pitfalls.

Thanks for the corrections Bob,

--
Leonardo Soto M.

Bob Ippolito

unread,
Feb 7, 2006, 8:14:43 AM2/7/06
to Leonardo Soto M, MochiKit

On Feb 7, 2006, at 5:03 AM, Leonardo Soto M wrote:

>
> Bob Ippolito wrote:
>
> > [...]
> > Test.Simple is gone! I made some changes to SimpleTest so that it
> > works in Safari and Firefox. I have not tested elsewhere.
>
> It worked for me on FF 1.5, Opera 8.5, IE 6 and IE 5.5 (Well, not
> "pure 5.5", I'm using the hack that allows you to have IE 5, 5.5
> and 6 on the same Windows installation).
>
> What stopped SimpleTest from working on Safari?. I've no access to
> the Mac world.

"display:none" stopped SimpleTest from working. It seems that doing
that unloads (or never loads, depending on when you do it) the
iframe. The setTimeout might not be necessary and the change from
setAttribute to attribute setting is definitely not relevant, but
it's less code and more clear.

http://www.google.com/search?q=iframe+safari+display+none
http://developer.apple.com/internet/webcontent/iframe.html

-bob

Reply all
Reply to author
Forward
0 new messages