Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/ParentNode-querySelector-All-xht.xht

Issue 2482213003: Import WPT tests which require non-test HTML resources. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html id="html" lang="en" xmlns="http://www.w3.org/1999/xhtml">
3 <head id="head">
4 <title>Selectors-API Test Suite: XHTML</title>
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <script src="selectors.js"></script>
8 <script src="ParentNode-querySelector-All.js"></script>
9 <style>iframe { visibility: hidden; position: absolute; }</style>
10 </head>
11 <body>
12 <div id="log">This test requires JavaScript.</div>
13
14 <script><![CDATA[
15 async_test(function() {
16 var frame = document.createElement("iframe");
17 frame.onload = this.step_func_done(init);
18 frame.src = "ParentNode-querySelector-All-content.xht#target";
19 document.body.appendChild(frame);
20 })
21
22 function init(e) {
23 /*
24 * This test suite tests Selectors API methods in 4 different contexts:
25 * 1. Document node
26 * 2. In-document Element node
27 * 3. Detached Element node (an element with no parent, not in the document)
28 * 4. Document Fragment node
29 *
30 * For each context, the following tests are run:
31 *
32 * The interface check tests ensure that each type of node exposes the Selecto rs API methods
33 *
34 * The special selector tests verify the result of passing special values for the selector parameter,
35 * to ensure that the correct WebIDL processing is performed, such as stringif ication of null and
36 * undefined and missing parameter. The universal selector is also tested here , rather than with the
37 * rest of ordinary selectors for practical reasons.
38 *
39 * The static list verification tests ensure that the node lists returned by t he method remain unchanged
40 * due to subsequent document modication, and that a new list is generated eac h time the method is
41 * invoked based on the current state of the document.
42 *
43 * The invalid selector tests ensure that SyntaxError is thrown for invalid fo rms of selectors
44 *
45 * The valid selector tests check the result from querying many different type s of selectors, with a
46 * list of expected elements. This checks that querySelector() always returns the first result from
47 * querySelectorAll(), and that all matching elements are correctly returned i n tree-order. The tests
48 * can be limited by specifying the test types to run, using the testType vari able. The constants for this
49 * can be found in selectors.js.
50 *
51 * All the selectors tested for both the valid and invalid selector tests are found in selectors.js.
52 * See comments in that file for documentation of the format used.
53 *
54 * The ParentNode-querySelector-All.js file contains all the common test funct ions for running each of the aforementioned tests
55 */
56
57 var testType = TEST_QSA;
58 var docType = "xhtml"; // Only run tests suitable for XHTML
59
60 // Prepare the nodes for testing
61 var doc = e.target.contentDocument; // Document Node tests
62
63 var element = doc.getElementById("root"); // In-document Element Node tests
64
65 //Setup the namespace tests
66 setupSpecialElements(doc, element);
67
68 var outOfScope = element.cloneNode(true); // Append this to the body before running the in-document
69 // Element tests, but after runni ng the Document tests. This
70 // tests that no elements that ar e not descendants of element
71 // are selected.
72
73 traverse(outOfScope, function(elem) { // Annotate each element as being a clone; used for verifying
74 elem.setAttribute("data-clone", ""); // that none of these elements ever match.
75 });
76
77
78 var detached = element.cloneNode(true); // Detached Element Node tests
79
80 var fragment = doc.createDocumentFragment(); // Fragment Node tests
81 fragment.appendChild(element.cloneNode(true));
82
83 // Setup Tests
84 interfaceCheck("Document", doc);
85 interfaceCheck("Detached Element", detached);
86 interfaceCheck("Fragment", fragment);
87 interfaceCheck("In-document Element", element);
88
89 runSpecialSelectorTests("Document", doc);
90 runSpecialSelectorTests("Detached Element", detached);
91 runSpecialSelectorTests("Fragment", fragment);
92 runSpecialSelectorTests("In-document Element", element);
93
94 verifyStaticList("Document", doc, doc);
95 verifyStaticList("Detached Element", doc, detached);
96 verifyStaticList("Fragment", doc, fragment);
97 verifyStaticList("In-document Element", doc, element);
98
99 runInvalidSelectorTest("Document", doc, invalidSelectors);
100 runInvalidSelectorTest("Detached Element", detached, invalidSelectors);
101 runInvalidSelectorTest("Fragment", fragment, invalidSelectors);
102 runInvalidSelectorTest("In-document Element", element, invalidSelectors);
103
104 runValidSelectorTest("Document", doc, validSelectors, testType, docType);
105 runValidSelectorTest("Detached Element", detached, validSelectors, testType, d ocType);
106 runValidSelectorTest("Fragment", fragment, validSelectors, testType, docType);
107
108 doc.body.appendChild(outOfScope); // Append before in-document Element tests.
109 // None of these elements should match
110 runValidSelectorTest("In-document Element", element, validSelectors, testType, docType);
111 }
112 ]]></script>
113 </body>
114 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698