Changeset 18575 for lang/javascript

Show
Ignore:
Timestamp:
09/01/08 14:07:14 (3 months ago)
Author:
amachang
Message:

[John Resig's test] force support IE

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/javascript-xpath/trunk/test/misc/ejohn_s_selectors_api_test.html

    r18567 r18575  
    225225  <script> 
    226226        window.onload = function(){ 
     227        // for IE 
     228        if (!('DOMException' in window)) { 
     229            window.DOMException = { 
     230                SYNTAX_ERR: 12, 
     231                NAMESPACE_ERR: 14 
     232            }; 
     233        } 
     234 
    227235                document.getElementById("toggle").onclick = function(){ 
    228236                        document.documentElement.className = this.checked ? "unitTest nopass" : "unitTest"; 
     
    239247                var cache = {}; 
    240248 
    241                 var css = document.getElementById("test").firstChild.nodeValue.split("\n"); 
     249                var css = document.getElementById("test").innerHTML.split("\n"); 
    242250                for ( var i = 0; i < css.length; i++ ) { 
    243251                        css[i] = css[i].replace(/\/\*.*?\*\//g, "") 
     
    245253                } 
    246254 
    247                 var ecss = document.getElementById("error").firstChild.nodeValue.split("\n"); 
     255                var ecss = document.getElementById("error").innerHTML.split("\n"); 
    248256                for ( var i = 0; i < ecss.length; i++ ) { 
    249257                        ecss[i] = ecss[i].replace(/\/\*.*?\*\//g, "") 
     
    435443 
    436444                function check( type, root, expect, fragment ){ 
     445 
     446            (function(div) { 
     447 
     448                if (div.nodeType == 1) { 
     449                    if ( (div.getAttribute("class") || "").toString().indexOf("unitTest") > -1 && 
     450                            (!fragment || div.getAttribute("id") !== "nofragment") ) { 
     451                        //var bg = div.style.backgroundColor; 
     452                        var win = document.defaultView || document.parentWindow; 
     453                        try { 
     454                            var view = win.getComputedStyle(div, null); 
     455                        } 
     456                        catch(e) { 
     457                            view = div.currentStyle; 
     458                        } 
     459                        try { 
     460                            var bg = view.getPropertyValue("background-color") || div.style.backgroundColor; 
     461                        } 
     462                        catch(e) { 
     463                            var bg = view.backgroundColor || div.style.backgroundColor; 
     464                        } 
     465 
     466                        var pass = bg && bg.indexOf("(255, 0, 0") == -1 && bg.indexOf("#ff0000") == -1 && bg.indexOf("red") == -1; 
     467                        //var pass = bg && bg.indexOf("(255, 0, 0") == -1 && bg.indexOf("#ff0000") == -1; 
     468                        assert(pass === expect, type + ": " + (div.title || div.parentNode.title)); 
     469                    } 
     470                } 
     471 
     472                for (var child = div.firstChild; child; child = child.nextSibling) arguments.callee(child); 
     473            })(root); 
     474/* 
    437475                        var walker = document.createTreeWalker( root, NodeFilter.SHOW_ELEMENT, { acceptNode: function(){ return 1; } }, false ); 
    438476 
     
    450488                                } 
    451489                        } 
     490*/ 
    452491                } 
    453492 
     
    463502                        function query(q, resolver){ 
    464503                                try { 
    465                                         return root[select](q, resolver); 
     504                    if (resolver === void(0)) { 
     505                                            return root[select](q); 
     506                    } 
     507                    else { 
     508                                            return root[select](q, resolver); 
     509                    } 
    466510                                } catch(e){ 
     511                    if (e.number == -2147467259) { 
     512                        return [] 
     513                    } 
    467514                                  if ( e.message.indexOf("ERR") > -1 || e.code == DOMException.NAMESPACE_ERR || 
    468515                                                        e.code == DOMException.SYNTAX_ERR)