Banner and Rerun links don't work when loading file directly

Banner and Rerun links don't work when loading file directly

This may be just an IE issue. I haven't tried this with other browsers.
Create an html file such as MyTests.htm. Run it by going to the command line and simply use:
MyTests.htm<CR>.
Do this instead of using something like http://localhost/MyTests.htm.
IE will bring up the tests and they run fine. However, clicks on Rerun or the Banner are ignored.
I debugged thus and found the bug. It appears that the code to create the URL only understands HTTP://. Not FILE://. I created a work around in our code. I've included it below:
 
Line 56 of qunit.js version 1.10:
a.href = QUnit.url({ testNumber: this .testNumber });
 
Replace with:
var qurl = QUnit.url({ testNumber: this.testNumber });
if (QUnit.isLocal) {
    qurl = "file://" + qurl.substring(1);
}
a.href = qurl;




At line 971:
if ( banner ) {
    banner.innerHTML = "<a href='" + QUnit.url({ filter: undefined, module: undefined, testNumber: undefined }) + "'>" + banner.innerHTML + "</a> ";
}
Replace with:
if ( banner ) {
    var qurl = QUnit.url({ filter: undefined, module: undefined, testNumber: undefined });
    if (QUnit.isLocal) {
        qurl = "file://" + qurl.substring(1);
    }
  banner.innerHTML = "<a href=" + qurl + ">" + banner.innerHTML + "</a>";
}






Perhaps the QUnit.url function could be fixed itself. I didn't go that far.
 
 
 
    • Topic Participants

    • bradt