tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ParentNode-querySelector-All-xht.xht (5635B)


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