mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-10 02:08:38 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
60
testing/web-platform/tests/domxpath/001.html
Normal file
60
testing/web-platform/tests/domxpath/001.html
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf8">
|
||||
<title>XPath in text/html: elements</title>
|
||||
<link rel="help" href="http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#Interfaces">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body>
|
||||
<div id="log"><span></span></div>
|
||||
<div><span></span></div>
|
||||
<dØdd></dØdd>
|
||||
<svg>
|
||||
<path />
|
||||
<path />
|
||||
</svg>
|
||||
|
||||
<script>
|
||||
function test_xpath_succeeds(path, expected, resolver) {
|
||||
resolver = resolver ? resolver : null;
|
||||
var res = document.evaluate(path, document, resolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
|
||||
actual = [];
|
||||
for (var i=0;;i++) {
|
||||
var node = res.snapshotItem(i);
|
||||
if (node === null) {
|
||||
break;
|
||||
}
|
||||
actual.push(node);
|
||||
}
|
||||
assert_array_equals(actual, expected);
|
||||
}
|
||||
|
||||
function test_xpath_throws(path, error_code, resolver) {
|
||||
resolver = resolver ? resolver : null;
|
||||
assert_throws(error_code, function() {document.evaluate(path, document, resolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)})
|
||||
}
|
||||
|
||||
function ns_resolver(x) {
|
||||
map = {"html":"http://www.w3.org/1999/xhtml",
|
||||
"svg":"http://www.w3.org/2000/svg",
|
||||
"math":"http://www.w3.org/1998/Math/MathML"};
|
||||
var rv = map.hasOwnProperty(x) ? map[x] : null;
|
||||
return rv;
|
||||
}
|
||||
|
||||
generate_tests(test_xpath_succeeds,[
|
||||
["HTML elements no namespace prefix", "//div", document.getElementsByTagName("div")],
|
||||
["HTML elements namespace prefix", "//html:div", document.getElementsByTagName("div"), ns_resolver],
|
||||
["HTML elements mixed use of prefix", "//html:div/span", document.getElementsByTagName("span"), ns_resolver],
|
||||
["SVG elements no namespace prefix", "//path", []],
|
||||
["SVG elements namespace prefix", "//svg:path", document.getElementsByTagName("path"), ns_resolver],
|
||||
["HTML elements mixed case", "//DiV", document.getElementsByTagName("div")],
|
||||
["SVG elements mixed case selector", "//svg:PatH", [], ns_resolver],
|
||||
["Non-ascii HTML element", "//dØdd", document.getElementsByTagName("dØdd"), ns_resolver],
|
||||
["Non-ascii HTML element2", "//dødd", [], ns_resolver],
|
||||
["Non-ascii HTML element3", "//DØDD", document.getElementsByTagName("dØdd"), ns_resolver]
|
||||
])
|
||||
|
||||
generate_tests(test_xpath_throws, [
|
||||
["Throw with invalid prefix", "//invalid:path", "NAMESPACE_ERR"],
|
||||
])
|
||||
</script>
|
||||
60
testing/web-platform/tests/domxpath/002.html
Normal file
60
testing/web-platform/tests/domxpath/002.html
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<!doctype html>
|
||||
<meta charset="utf8">
|
||||
<title>XPath in text/html: attributes</title>
|
||||
<link rel="help" href="http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#Interfaces">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<body>
|
||||
<div id="log" nonÄsciiAttribute><span></span></div>
|
||||
<svg xmlns="http://www.w3.org/2000/svg", xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<path id="a" refx />
|
||||
<path id="b" nonÄscii xlink:href />
|
||||
</svg>
|
||||
|
||||
<script>
|
||||
function test_xpath_succeeds(path, expected, resolver) {
|
||||
resolver = resolver ? resolver : null;
|
||||
var res = document.evaluate(path, document, resolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
|
||||
actual = [];
|
||||
for (var i=0;;i++) {
|
||||
var node = res.snapshotItem(i);
|
||||
if (node === null) {
|
||||
break;
|
||||
}
|
||||
actual.push(node);
|
||||
}
|
||||
assert_array_equals(actual, expected);
|
||||
}
|
||||
|
||||
function test_xpath_throws(path, error_code, resolver) {
|
||||
resolver = resolver ? resolver : null;
|
||||
assert_throws(error_code, function() {document.evaluate(path, document, resolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)})
|
||||
}
|
||||
|
||||
function ns_resolver(x) {
|
||||
map = {"html":"http://www.w3.org/1999/xhtml",
|
||||
"svg":"http://www.w3.org/2000/svg",
|
||||
"math":"http://www.w3.org/1998/Math/MathML",
|
||||
"xlink":"http://www.w3.org/1999/xlink"};
|
||||
var rv = map.hasOwnProperty(x) ? map[x] : null;
|
||||
return rv;
|
||||
}
|
||||
|
||||
generate_tests(test_xpath_succeeds,[
|
||||
["Select html element based on attribute", "//div[@id='log']", [document.getElementById("log")]],
|
||||
["Select html element based on attribute mixed case", "//div[@Id='log']", [document.getElementById("log")]],
|
||||
["Select both HTML and SVG elements based on attribute", "//*[@id]", [document.getElementById("log")].concat(Array.prototype.slice.call(document.getElementsByTagName("path")))],
|
||||
["Select HTML element with non-ascii attribute 1", "//*[@nonÄsciiattribute]", [document.getElementById("log")]],
|
||||
["Select HTML element with non-ascii attribute 2", "//*[@nonäsciiattribute]", []],
|
||||
["Select HTML element with non-ascii attribute 3", "//*[@nonÄsciiAttribute]", [document.getElementById("log")]],
|
||||
["Select SVG element based on mixed case attribute", "//svg:path[@Id]", [], ns_resolver],
|
||||
["Select both HTML and SVG elements based on mixed case attribute", "//*[@Id]", [document.getElementById("log")]],
|
||||
["Select SVG elements with refX attribute", "//*[@refX]", [document.getElementById("a")]],
|
||||
["Select SVG elements with refX attribute incorrect case", "//*[@Refx]", []],
|
||||
["Select SVG elements with refX attribute lowercase", "//*[@refx]", []],
|
||||
["Select SVG element with non-ascii attribute 1", "//*[@nonÄscii]", [document.getElementById("b")]],
|
||||
["Select SVG element with non-ascii attribute 2", "//*[@nonäscii]", []],
|
||||
["xmlns attribute", "//*[@xmlns]", []],
|
||||
["svg element with XLink attribute", "//*[@xlink:href]", [document.getElementById("b")], ns_resolver]
|
||||
])
|
||||
</script>
|
||||
3
testing/web-platform/tests/domxpath/OWNERS
Normal file
3
testing/web-platform/tests/domxpath/OWNERS
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
@gsnedders
|
||||
@zqzhang
|
||||
@deniak
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>XPathEvaluator constructor</title>
|
||||
<link rel=help href="http://wiki.whatwg.org/wiki/DOM_XPath">
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div id=log></div>
|
||||
<script>
|
||||
test(function() {
|
||||
var x = new XPathEvaluator();
|
||||
assert_true(x instanceof XPathEvaluator);
|
||||
}, "Constructor with 'new'");
|
||||
test(function() {
|
||||
assert_throws(new TypeError(), "var x = XPathEvaluator()");
|
||||
}, "Constructor without 'new'");
|
||||
</script>
|
||||
51
testing/web-platform/tests/domxpath/xml_xpath_runner.html
Normal file
51
testing/web-platform/tests/domxpath/xml_xpath_runner.html
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<!doctype html>
|
||||
<title>XPath tests</title>
|
||||
<script src='/resources/testharness.js'></script>
|
||||
<script src='/resources/testharnessreport.js'></script>
|
||||
<script>
|
||||
setup({ explicit_done: true });
|
||||
|
||||
function find_child_element(context, element) {
|
||||
for (var i = 0; i < context.childNodes.length; i++) {
|
||||
var child = context.childNodes[i];
|
||||
if (child.nodeType === Node.ELEMENT_NODE && child.tagName === element)
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
function xpath_test(test_el) {
|
||||
/* note this func adopts the tree! */
|
||||
var new_doc = document.implementation.createDocument("", "");
|
||||
var xpath = find_child_element(test_el, "xpath");
|
||||
var tree = find_child_element(test_el, "tree");
|
||||
var actual_tree = new_doc.adoptNode(tree.firstElementChild);
|
||||
new_doc.appendChild(actual_tree);
|
||||
test(function() {
|
||||
var result = new_doc.evaluate(xpath.textContent, // expression
|
||||
actual_tree, // context node
|
||||
new_doc.createNSResolver(actual_tree), // resolver
|
||||
XPathResult.ANY_TYPE, // type
|
||||
null); // result
|
||||
var matched = [];
|
||||
var cur;
|
||||
while ((cur = result.iterateNext()) !== null) {
|
||||
matched.push(cur);
|
||||
}
|
||||
assert_equals(matched.length, 1, "Should match one node");
|
||||
});
|
||||
}
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "xml_xpath_tests.xml");
|
||||
xhr.onload = function(e) {
|
||||
var tests = xhr.responseXML.documentElement;
|
||||
for (var i = 0; i < tests.childNodes.length; i++) {
|
||||
var child = tests.childNodes[i];
|
||||
if (child.nodeType === Node.ELEMENT_NODE) {
|
||||
xpath_test(child);
|
||||
}
|
||||
}
|
||||
done();
|
||||
};
|
||||
xhr.send();
|
||||
</script>
|
||||
29799
testing/web-platform/tests/domxpath/xml_xpath_tests.xml
Normal file
29799
testing/web-platform/tests/domxpath/xml_xpath_tests.xml
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue