| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <meta charset="UTF-8"> | 2 <meta charset="UTF-8"> |
| 3 <title>Selectors-API Test Suite: HTML</title> | 3 <title>Selectors-API Test Suite: HTML</title> |
| 4 <script src="/resources/testharness.js"></script> | 4 <script src="/resources/testharness.js"></script> |
| 5 <script src="/resources/testharnessreport.js"></script> | 5 <script src="/resources/testharnessreport.js"></script> |
| 6 <script src="selectors.js"></script> | 6 <script src="selectors.js"></script> |
| 7 <script src="ParentNode-querySelector-All.js"></script> | 7 <script src="ParentNode-querySelector-All.js"></script> |
| 8 <style>iframe { visibility: hidden; position: absolute; }</style> | 8 <style>iframe { visibility: hidden; position: absolute; }</style> |
| 9 | 9 |
| 10 <div id="log">This test requires JavaScript.</div> | 10 <div id="log">This test requires JavaScript.</div> |
| 11 | 11 |
| 12 <script> | 12 <script> |
| 13 async_test(function() { | 13 async_test(function() { |
| 14 var frame = document.createElement("iframe"); | 14 var frame = document.createElement("iframe"); |
| 15 frame.onload = this.step_func_done(init); | 15 var self = this; |
| 16 frame.onload = function() { |
| 17 // :target doesn't work before a page rendering on some browsers. We run |
| 18 // tests after an animation frame because it may be later than the first |
| 19 // page rendering. |
| 20 requestAnimationFrame(self.step_func_done(init.bind(self, frame))); |
| 21 }; |
| 16 frame.src = "ParentNode-querySelector-All-content.html#target"; | 22 frame.src = "ParentNode-querySelector-All-content.html#target"; |
| 17 document.body.appendChild(frame); | 23 document.body.appendChild(frame); |
| 18 }); | 24 }); |
| 19 | 25 |
| 20 function init(e) { | 26 function init(target) { |
| 21 /* | 27 /* |
| 22 * This test suite tests Selectors API methods in 4 different contexts: | 28 * This test suite tests Selectors API methods in 4 different contexts: |
| 23 * 1. Document node | 29 * 1. Document node |
| 24 * 2. In-document Element node | 30 * 2. In-document Element node |
| 25 * 3. Detached Element node (an element with no parent, not in the document) | 31 * 3. Detached Element node (an element with no parent, not in the document) |
| 26 * 4. Document Fragment node | 32 * 4. Document Fragment node |
| 27 * | 33 * |
| 28 * For each context, the following tests are run: | 34 * For each context, the following tests are run: |
| 29 * | 35 * |
| 30 * The interface check tests ensure that each type of node exposes the Selecto
rs API methods | 36 * The interface check tests ensure that each type of node exposes the Selecto
rs API methods |
| (...skipping 18 matching lines...) Expand all Loading... |
| 49 * All the selectors tested for both the valid and invalid selector tests are
found in selectors.js. | 55 * All the selectors tested for both the valid and invalid selector tests are
found in selectors.js. |
| 50 * See comments in that file for documentation of the format used. | 56 * See comments in that file for documentation of the format used. |
| 51 * | 57 * |
| 52 * The ParentNode-querySelector-All.js file contains all the common test funct
ions for running each of the aforementioned tests | 58 * The ParentNode-querySelector-All.js file contains all the common test funct
ions for running each of the aforementioned tests |
| 53 */ | 59 */ |
| 54 | 60 |
| 55 var testType = TEST_QSA; | 61 var testType = TEST_QSA; |
| 56 var docType = "html"; // Only run tests suitable for HTML | 62 var docType = "html"; // Only run tests suitable for HTML |
| 57 | 63 |
| 58 // Prepare the nodes for testing | 64 // Prepare the nodes for testing |
| 59 var doc = e.target.contentDocument; // Document Node tests | 65 var doc = target.contentDocument; // Document Node tests |
| 60 | 66 |
| 61 var element = doc.getElementById("root"); // In-document Element Node tests | 67 var element = doc.getElementById("root"); // In-document Element Node tests |
| 62 | 68 |
| 63 //Setup the namespace tests | 69 //Setup the namespace tests |
| 64 setupSpecialElements(doc, element); | 70 setupSpecialElements(doc, element); |
| 65 | 71 |
| 66 var outOfScope = element.cloneNode(true); // Append this to the body before
running the in-document | 72 var outOfScope = element.cloneNode(true); // Append this to the body before
running the in-document |
| 67 // Element tests, but after runni
ng the Document tests. This | 73 // Element tests, but after runni
ng the Document tests. This |
| 68 // tests that no elements that ar
e not descendants of element | 74 // tests that no elements that ar
e not descendants of element |
| 69 // are selected. | 75 // are selected. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 107 |
| 102 runValidSelectorTest("Document", doc, validSelectors, testType, docType); | 108 runValidSelectorTest("Document", doc, validSelectors, testType, docType); |
| 103 runValidSelectorTest("Detached Element", detached, validSelectors, testType, d
ocType); | 109 runValidSelectorTest("Detached Element", detached, validSelectors, testType, d
ocType); |
| 104 runValidSelectorTest("Fragment", fragment, validSelectors, testType, docType); | 110 runValidSelectorTest("Fragment", fragment, validSelectors, testType, docType); |
| 105 | 111 |
| 106 doc.body.appendChild(outOfScope); // Append before in-document Element tests. | 112 doc.body.appendChild(outOfScope); // Append before in-document Element tests. |
| 107 // None of these elements should match | 113 // None of these elements should match |
| 108 runValidSelectorTest("In-document Element", element, validSelectors, testType,
docType); | 114 runValidSelectorTest("In-document Element", element, validSelectors, testType,
docType); |
| 109 } | 115 } |
| 110 </script> | 116 </script> |
| OLD | NEW |