Auto merge of #5650 - ienzam:issue/1826, r=jdm

Tracking issue #1826 - implemented one of the three methods.

This is follow up of #5402. Rebased and squashed and made the method iterative.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5650)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-04-16 13:07:20 -05:00
commit e3756f9e3f
3 changed files with 97 additions and 4 deletions

View file

@ -0,0 +1,48 @@
<!doctype html>
<html>
<head>
<script src="harness.js"></script>
</head>
<body>
<x xarg="xval">
<!--comment-->
<?test test?>
TEST
<x/>
</x>
<script>
document.documentElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:x", "test");
document.body.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:s", "test");
var x = document.getElementsByTagName("x")[0];
x.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:t", "test");
var yprefix = document.createElementNS("ynamespace", "yprefix:ylocalname");
var ynoprefix = document.createElementNS("ynamespace", "ylocalname");
ynoprefix.setAttribute("ynoprefixattr", "yval");
ynoprefix.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:yattr", "yval");
// Step 1
is(document.lookupPrefix(""), null);
is(document.lookupPrefix(null), null);
// Element step 1
is(yprefix.lookupPrefix("ynamespace"), "yprefix");
is(ynoprefix.lookupPrefix("ynamespace"), null);
// Element step 2
is(x.lookupPrefix("test"), "t");
is(ynoprefix.lookupPrefix("yval"), "yattr");
// analogous to wpt - https://github.com/w3c/web-platform-tests/blob/master/dom/nodes/Node-lookupPrefix.xhtml
is(document.lookupPrefix("test"), "x");
is(x.lookupPrefix("test"), "t");
is(x.lookupPrefix("http://www.w3.org/1999/xhtml"), null);
is(x.lookupPrefix("something"), null);
is(x.lookupPrefix(null), null);
is(x.parentNode.lookupPrefix("test"), "s");
is(x.firstChild.lookupPrefix("test"), "t");
is(x.childNodes[1].lookupPrefix("test"), "t");
is(x.childNodes[2].lookupPrefix("test"), "t");
is(x.lastChild.lookupPrefix("test"), "t");
</script>
</body>
</html>