Move the lookupPrefix content test.

This commit is contained in:
Ms2ger 2015-04-17 10:14:50 +02:00
parent 4fd4370a96
commit 25e8bc8ed8
3 changed files with 57 additions and 48 deletions

View file

@ -1,48 +0,0 @@
<!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>

View file

@ -411,6 +411,12 @@
"url": "/_mozilla/mozilla/node_isEqualNode.html"
}
],
"mozilla/node_lookupPrefix.html": [
{
"path": "mozilla/node_lookupPrefix.html",
"url": "/_mozilla/mozilla/node_lookupPrefix.html"
}
],
"mozilla/node_normalize.html": [
{
"path": "mozilla/node_normalize.html",

View file

@ -0,0 +1,51 @@
<!doctype html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<x xarg="xval">
<!--comment-->
<?test test?>
TEST
<x/>
</x>
<script>
test(function() {
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
assert_equals(document.lookupPrefix(""), null);
assert_equals(document.lookupPrefix(null), null);
// Element step 1
assert_equals(yprefix.lookupPrefix("ynamespace"), "yprefix");
assert_equals(ynoprefix.lookupPrefix("ynamespace"), null);
// Element step 2
assert_equals(x.lookupPrefix("test"), "t");
assert_equals(ynoprefix.lookupPrefix("yval"), "yattr");
// analogous to wpt - https://github.com/w3c/web-platform-tests/blob/master/dom/nodes/Node-lookupPrefix.xhtml
assert_equals(document.lookupPrefix("test"), "x");
assert_equals(x.lookupPrefix("test"), "t");
assert_equals(x.lookupPrefix("http://www.w3.org/1999/xhtml"), null);
assert_equals(x.lookupPrefix("something"), null);
assert_equals(x.lookupPrefix(null), null);
assert_equals(x.parentNode.lookupPrefix("test"), "s");
assert_equals(x.firstChild.lookupPrefix("test"), "t");
assert_equals(x.childNodes[1].lookupPrefix("test"), "t");
assert_equals(x.childNodes[2].lookupPrefix("test"), "t");
assert_equals(x.lastChild.lookupPrefix("test"), "t");
});
</script>
</body>
</html>