diff --git a/lib/Test/TAP/Class.js b/lib/Test/TAP/Class.js index c75316e..c539a24 100644 --- a/lib/Test/TAP/Class.js +++ b/lib/Test/TAP/Class.js @@ -93,7 +93,12 @@ Test.TAP.Class.prototype.run_it = function(method) { // THis avoid conflicts between tests when running multiple tests in a row for(var name in top) { if(!originalGlobal[name]) { - delete top[name] + try { + delete top[name] + } catch (e) { + // Delete threw an error, so just assign undefined + top[name] = undefined + } } } } diff --git a/lib/Test/TAPBrowser.js b/lib/Test/TAPBrowser.js index af30e33..9318a07 100644 --- a/lib/Test/TAPBrowser.js +++ b/lib/Test/TAPBrowser.js @@ -37,7 +37,13 @@ Test.TAPBrowser.prototype = { var url = location.pathname + "#test=" + encodeURIComponent(path.replace(/^\.\//, '')) Test.TAP.prototype.diag('loading: '+path+' (run in a single window)...'); - var req = new XMLHttpRequest(); + var req; + if(navigator.appName == 'Microsoft Internet Explorer') { + req = new ActiveXObject("Microsoft.XMLHTTP"); + } else { + req = new XMLHttpRequest(); + } + if(!req) throw "Can't create XML HTTP Request Object" req.open("GET", path, false); req.send(null); @@ -76,7 +82,14 @@ Test.TAPBrowser.prototype = { } div.className = c; }; - div.addEventListener('click', onclick, true); + + if(div.addEventListener) { + div.addEventListener('click', onclick, true); + } else if(div.attachEvent) { + div.attachEvent('onclick', onclick); + } else { + throw "Can't attach event without addEventListener or attachEvent"; + } div.className = 'test small'; document.body.appendChild(div);