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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/dom/nodes/Element-matches.html

Issue 2657583002: Import wpt@cf62b859e6b890abc34f8140d185ba91df95c5b6 (Closed)
Patch Set: Modify TestExpectations or download new baselines for tests. Created 3 years, 10 months 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 <meta charset="UTF-8">
3 <title>Selectors-API Level 2 Test Suite: HTML with Selectors Level 3</title>
4 <!-- Selectors API Test Suite Version 3 -->
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 <script src="/dom/nodes/selectors.js"></script>
8 <script src="/dom/nodes/ParentNode-querySelector-All.js"></script>
9 <script src="Element-matches.js"></script>
10 <style>iframe { visibility: hidden; position: absolute; }</style>
11
12 <div id="log">This test requires JavaScript.</div>
13
14 <script>
15 async_test(function() {
16 var frame = document.createElement("iframe");
17 frame.onload = this.step_func_done(init);
18 frame.src = "/dom/nodes/ParentNode-querySelector-All-content.html#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 matches() tests are run
35 * All the selectors tested for both the valid and invalid selector tests are found in selectors.js.
36 * See comments in that file for documentation of the format used.
37 *
38 * The level2-lib.js file contains all the common test functions for running e ach of the aforementioned tests
39 */
40
41 var docType = "html"; // Only run tests suitable for HTML
42
43 // Prepare the nodes for testing
44 var doc = e.target.contentDocument; // Document Node tests
45
46 var element = doc.getElementById("root"); // In-document Element Node tests
47
48 //Setup the namespace tests
49 setupSpecialElements(doc, element);
50
51 var outOfScope = element.cloneNode(true); // Append this to the body before running the in-document
52 // Element tests, but after runni ng the Document tests. This
53 // tests that no elements that ar e not descendants of element
54 // are selected.
55
56 traverse(outOfScope, function(elem) { // Annotate each element as being a clone; used for verifying
57 elem.setAttribute("data-clone", ""); // that none of these elements ever match.
58 });
59
60
61 var detached = element.cloneNode(true); // Detached Element Node tests
62
63 var fragment = doc.createDocumentFragment(); // Fragment Node tests
64 fragment.appendChild(element.cloneNode(true));
65
66 // Setup Tests
67 interfaceCheckMatches("Document", doc);
68 interfaceCheckMatches("Detached Element", detached);
69 interfaceCheckMatches("Fragment", fragment);
70 interfaceCheckMatches("In-document Element", element);
71
72 runSpecialMatchesTests("DIV Element", element);
73 runSpecialMatchesTests("NULL Element", document.createElement("null"));
74 runSpecialMatchesTests("UNDEFINED Element", document.createElement("undefined" ));
75
76 runInvalidSelectorTestMatches("Document", doc, invalidSelectors);
77 runInvalidSelectorTestMatches("Detached Element", detached, invalidSelectors);
78 runInvalidSelectorTestMatches("Fragment", fragment, invalidSelectors);
79 runInvalidSelectorTestMatches("In-document Element", element, invalidSelectors );
80
81 runMatchesTest("In-document", doc, validSelectors, "html");
82 runMatchesTest("Detached", detached, validSelectors, "html");
83 runMatchesTest("Fragment", fragment, validSelectors, "html");
84
85 runMatchesTest("In-document", doc, scopedSelectors, "html");
86 }
87 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698