Skip to content

Commit

Permalink
added test case to exercise NodeList#indexOf()
Browse files Browse the repository at this point in the history
  • Loading branch information
karunasagark committed Mar 6, 2011
1 parent ee24f5e commit 701cbb3
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/browser/index.js
Expand Up @@ -212,5 +212,44 @@ exports.tests = {
var document = dom.createDocument(null, null, doctype);
assertTrue('Doctype did not serialize correctly',
/^\s*<!DOCTYPE foo SYSTEM \'foo "bar".dtd\'>/.test(document.outerHTML));
},
basic_nodelist_indexOf : function() {
var doc = new browser.Document();

var html = doc.createElement("html");
doc.appendChild(html);

var body = doc.createElement("body");
html.appendChild(body);

var p = doc.createElement("p");
body.appendChild(p);

var div = doc.createElement("div");
body.appendChild(div);

var span = doc.createElement("span");
body.appendChild(span);

var index = body.childNodes.indexOf(span);
assertEquals("indexOf 'span' in childNodes", 2, index);
},
nonexistant_nodelist_indexOf : function() {
var doc = new browser.Document();

var html = doc.createElement("html");
doc.appendChild(html);

var body = doc.createElement("body");
html.appendChild(body);

var p = doc.createElement("p");
body.appendChild(p);

var div = doc.createElement("div");
p.appendChild(div);

var index = body.childNodes.indexOf(div);
assertEquals("indexOf 'span' in childNodes", -1, index);
}
};

0 comments on commit 701cbb3

Please sign in to comment.