Skip to content

Commit dffeb3a

Browse files
author
Ahmad Saleem
committed
Sync domxpath from WPT upstream
https://bugs.webkit.org/show_bug.cgi?id=293427 rdar://151854809 Reviewed by Tim Nguyen. Upstream commit: web-platform-tests/wpt@faf875d * LayoutTests/imported/w3c/resources/resource-files.json: * LayoutTests/imported/w3c/web-platform-tests/domxpath/001.html: Removed. * LayoutTests/imported/w3c/web-platform-tests/domxpath/002-expected.txt: Removed. * LayoutTests/imported/w3c/web-platform-tests/domxpath/002.html: Removed. * LayoutTests/imported/w3c/web-platform-tests/domxpath/META.yml: * LayoutTests/imported/w3c/web-platform-tests/domxpath/callback-interface-expected.txt: Removed. * LayoutTests/imported/w3c/web-platform-tests/domxpath/callback-interface.html: Removed. * LayoutTests/imported/w3c/web-platform-tests/domxpath/fn-lang-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/domxpath/fn-lang.html: * LayoutTests/imported/w3c/web-platform-tests/domxpath/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/domxpath/xpath-evaluate-crash.html: * LayoutTests/imported/w3c/web-platform-tests/domxpath/evaluator-cross-realm.tentative-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/domxpath/evaluator-cross-realm.tentative.html: * LayoutTests/imported/w3c/web-platform-tests/domxpath/evaluator-different-document.tentative-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/domxpath/evaluator-different-document.tentative.html: * LayoutTests/imported/w3c/web-platform-tests/domxpath/expression-cross-realm.tentative-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/domxpath/expression-cross-realm.tentative.html: * LayoutTests/imported/w3c/web-platform-tests/domxpath/expression-different-document.tentative-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/domxpath/expression-different-document.tentative.html: * LayoutTests/imported/w3c/web-platform-tests/domxpath/resolver-callback-interface-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/domxpath/resolver-callback-interface.html: * LayoutTests/imported/w3c/web-platform-tests/domxpath/resolver-non-string-result-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/domxpath/resolver-non-string-result.html: * LayoutTests/imported/w3c/web-platform-tests/domxpath/resources/w3c-import.log: * LayoutTests/imported/w3c/web-platform-tests/domxpath/text-html-attributes-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/domxpath/text-html-attributes.html: * LayoutTests/imported/w3c/web-platform-tests/domxpath/text-html-elements-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/domxpath/text-html-elements.html: Canonical link: https://commits.webkit.org/295302@main
1 parent 53b3d1c commit dffeb3a

25 files changed

+630
-164
lines changed

LayoutTests/imported/w3c/resources/resource-files.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8326,8 +8326,6 @@
83268326
"web-platform-tests/dom/xslt/encoding-single-chunk-ref.html",
83278327
"web-platform-tests/dom/xslt/large-cdata-ref.html",
83288328
"web-platform-tests/dom/xslt/sort-ref.html",
8329-
"web-platform-tests/domxpath/001.html",
8330-
"web-platform-tests/domxpath/xml_xpath_tests.xml",
83318329
"web-platform-tests/editing/crashtests/support/unloading-editor-in-subdocument-containing-misspelled-word-iframe.html",
83328330
"web-platform-tests/encoding/eof-shift_jis-ref.html",
83338331
"web-platform-tests/encoding/eof-utf-8-one-ref.html",

LayoutTests/imported/w3c/web-platform-tests/domxpath/001.html

Lines changed: 0 additions & 60 deletions
This file was deleted.

LayoutTests/imported/w3c/web-platform-tests/domxpath/002.html

Lines changed: 0 additions & 60 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
spec: https://www.w3.org/TR/DOM-Level-3-XPath/
22
suggested_reviewers:
3-
- zqzhang
43
- deniak
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
PASS evaluator from realm with XML associated document, context node in XML document, no namespace resolver
3+
PASS evaluator from realm with XML associated document, context node in HTML document, no namespace resolver
4+
PASS evaluator from realm with HTML associated document, context node in XML document, no namespace resolver
5+
PASS evaluator from realm with HTML associated document, context node in HTML document, no namespace resolver
6+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>Cross-realm XPath evaluator</title>
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<body>
7+
<script>
8+
function toArray(result) {
9+
var a = [];
10+
while (true) {
11+
var node = result.iterateNext();
12+
if (node === null) break;
13+
a.push(node);
14+
}
15+
return a;
16+
}
17+
18+
var html_ns = "http://www.w3.org/1999/xhtml";
19+
var xml_doc = document.implementation.createDocument(html_ns, "html");
20+
var html_doc = document.implementation.createHTMLDocument();
21+
22+
promise_test(async (t) => {
23+
const iframe = document.createElement("iframe");
24+
iframe.src = "/common/dummy.xml";
25+
document.body.appendChild(iframe);
26+
await new Promise(resolve => {
27+
iframe.addEventListener("load", resolve, {once: true});
28+
});
29+
t.add_cleanup(() => iframe.remove());
30+
const iframe_evaluator = new iframe.contentWindow.XPathEvaluator();
31+
assert_array_equals(toArray(iframe_evaluator.evaluate("//html", xml_doc)), []);
32+
}, "evaluator from realm with XML associated document, context node in XML document, no namespace resolver");
33+
34+
promise_test(async (t) => {
35+
const iframe = document.createElement("iframe");
36+
iframe.src = "/common/dummy.xml";
37+
document.body.appendChild(iframe);
38+
await new Promise(resolve => {
39+
iframe.addEventListener("load", resolve, {once: true});
40+
});
41+
t.add_cleanup(() => iframe.remove());
42+
const iframe_evaluator = new iframe.contentWindow.XPathEvaluator();
43+
assert_array_equals(toArray(iframe_evaluator.evaluate("//html", html_doc)), [html_doc.documentElement]);
44+
}, "evaluator from realm with XML associated document, context node in HTML document, no namespace resolver");
45+
46+
promise_test(async (t) => {
47+
const iframe = document.createElement("iframe");
48+
iframe.src = "/common/blank.html";
49+
document.body.appendChild(iframe);
50+
await new Promise(resolve => {
51+
iframe.addEventListener("load", resolve, {once: true});
52+
});
53+
t.add_cleanup(() => iframe.remove());
54+
const iframe_evaluator = new iframe.contentWindow.XPathEvaluator();
55+
assert_array_equals(toArray(iframe_evaluator.evaluate("//html", xml_doc)), []);
56+
}, "evaluator from realm with HTML associated document, context node in XML document, no namespace resolver");
57+
58+
promise_test(async (t) => {
59+
const iframe = document.createElement("iframe");
60+
iframe.src = "/common/blank.html";
61+
document.body.appendChild(iframe);
62+
await new Promise(resolve => {
63+
iframe.addEventListener("load", resolve, {once: true});
64+
});
65+
t.add_cleanup(() => iframe.remove());
66+
const iframe_evaluator = new iframe.contentWindow.XPathEvaluator();
67+
assert_array_equals(toArray(iframe_evaluator.evaluate("//html", html_doc)), [html_doc.documentElement]);
68+
}, "evaluator from realm with HTML associated document, context node in HTML document, no namespace resolver");
69+
</script>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
PASS evaluate operation on XML document, context node in XML document, no namespace resolver
3+
PASS evaluate operation on HTML document, context node in HTML document, no namespace resolver
4+
PASS evaluate operation on XML document, context node in HTML document, no namespace resolver
5+
PASS evaluate operation on HTML document, context node in XML document, no namespace resolver
6+
PASS evaluate operation on XML document, context node in XML document, with namespace resolver
7+
PASS evaluate operation on HTML document, context node in HTML document, with namespace resolver
8+
PASS evaluate operation on XML document, context node in HTML document, with namespace resolver
9+
PASS evaluate operation on HTML document, context node in XML document, with namespace resolver
10+
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>Cross-document XPath evaluation</title>
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<body>
7+
<script>
8+
function toArray(result) {
9+
var a = [];
10+
while (true) {
11+
var node = result.iterateNext();
12+
if (node === null) break;
13+
a.push(node);
14+
}
15+
return a;
16+
}
17+
18+
var html_ns = "http://www.w3.org/1999/xhtml";
19+
var xml_doc = document.implementation.createDocument(html_ns, "html");
20+
var html_doc = document.implementation.createHTMLDocument();
21+
22+
function ns_resolver(x) {
23+
if (x === "html") {
24+
return html_ns;
25+
} else {
26+
return null;
27+
}
28+
}
29+
30+
test(function() {
31+
assert_array_equals(toArray(xml_doc.evaluate("//html", xml_doc)), []);
32+
}, "evaluate operation on XML document, context node in XML document, no namespace resolver");
33+
34+
test(function() {
35+
assert_array_equals(toArray(html_doc.evaluate("//html", html_doc)), [html_doc.documentElement]);
36+
}, "evaluate operation on HTML document, context node in HTML document, no namespace resolver");
37+
38+
test(function() {
39+
assert_array_equals(toArray(xml_doc.evaluate("//html", html_doc)), [html_doc.documentElement]);
40+
}, "evaluate operation on XML document, context node in HTML document, no namespace resolver");
41+
42+
test(function() {
43+
assert_array_equals(toArray(html_doc.evaluate("//html", xml_doc)), []);
44+
}, "evaluate operation on HTML document, context node in XML document, no namespace resolver");
45+
46+
test(function() {
47+
assert_array_equals(toArray(xml_doc.evaluate("//html", xml_doc, ns_resolver)), []);
48+
}, "evaluate operation on XML document, context node in XML document, with namespace resolver");
49+
50+
test(function() {
51+
assert_array_equals(toArray(html_doc.evaluate("//html", html_doc, ns_resolver)), [html_doc.documentElement]);
52+
}, "evaluate operation on HTML document, context node in HTML document, with namespace resolver");
53+
54+
test(function() {
55+
assert_array_equals(toArray(xml_doc.evaluate("//html", html_doc, ns_resolver)), [html_doc.documentElement]);
56+
}, "evaluate operation on XML document, context node in HTML document, with namespace resolver");
57+
58+
test(function() {
59+
assert_array_equals(toArray(html_doc.evaluate("//html", xml_doc, ns_resolver)), []);
60+
}, "evaluate operation on HTML document, context node in XML document, with namespace resolver");
61+
</script>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
PASS expression from realm with XML associated document, context node in XML document, no namespace resolver
3+
PASS expression from realm with XML associated document, context node in HTML document, no namespace resolver
4+
PASS expression from realm with HTML associated document, context node in XML document, no namespace resolver
5+
PASS expression from realm with HTML associated document, context node in HTML document, no namespace resolver
6+
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!DOCTYPE html>
2+
<meta charset="utf-8">
3+
<title>Cross-realm XPath evaluator</title>
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<body>
7+
<script>
8+
function toArray(result) {
9+
var a = [];
10+
while (true) {
11+
var node = result.iterateNext();
12+
if (node === null) break;
13+
a.push(node);
14+
}
15+
return a;
16+
}
17+
18+
var html_ns = "http://www.w3.org/1999/xhtml";
19+
var xml_doc = document.implementation.createDocument(html_ns, "html");
20+
var html_doc = document.implementation.createHTMLDocument();
21+
22+
promise_test(async (t) => {
23+
const iframe = document.createElement("iframe");
24+
iframe.src = "/common/dummy.xml";
25+
document.body.appendChild(iframe);
26+
await new Promise(resolve => {
27+
iframe.addEventListener("load", resolve, {once: true});
28+
});
29+
t.add_cleanup(() => iframe.remove());
30+
const iframe_expression = iframe.contentDocument.createExpression("//html");
31+
assert_array_equals(toArray(iframe_expression.evaluate(xml_doc)), []);
32+
}, "expression from realm with XML associated document, context node in XML document, no namespace resolver");
33+
34+
promise_test(async (t) => {
35+
const iframe = document.createElement("iframe");
36+
iframe.src = "/common/dummy.xml";
37+
document.body.appendChild(iframe);
38+
await new Promise(resolve => {
39+
iframe.addEventListener("load", resolve, {once: true});
40+
});
41+
t.add_cleanup(() => iframe.remove());
42+
const iframe_expression = iframe.contentDocument.createExpression("//html");
43+
assert_array_equals(toArray(iframe_expression.evaluate(html_doc)), [html_doc.documentElement]);
44+
}, "expression from realm with XML associated document, context node in HTML document, no namespace resolver");
45+
46+
promise_test(async (t) => {
47+
const iframe = document.createElement("iframe");
48+
iframe.src = "/common/blank.html";
49+
document.body.appendChild(iframe);
50+
await new Promise(resolve => {
51+
iframe.addEventListener("load", resolve, {once: true});
52+
});
53+
t.add_cleanup(() => iframe.remove());
54+
const iframe_expression = iframe.contentDocument.createExpression("//html");
55+
assert_array_equals(toArray(iframe_expression.evaluate(xml_doc)), []);
56+
}, "expression from realm with HTML associated document, context node in XML document, no namespace resolver");
57+
58+
promise_test(async (t) => {
59+
const iframe = document.createElement("iframe");
60+
iframe.src = "/common/blank.html";
61+
document.body.appendChild(iframe);
62+
await new Promise(resolve => {
63+
iframe.addEventListener("load", resolve, {once: true});
64+
});
65+
t.add_cleanup(() => iframe.remove());
66+
const iframe_expression = iframe.contentDocument.createExpression("//html");
67+
assert_array_equals(toArray(iframe_expression.evaluate(html_doc)), [html_doc.documentElement]);
68+
}, "expression from realm with HTML associated document, context node in HTML document, no namespace resolver");
69+
</script>

0 commit comments

Comments
 (0)