File: Element-matches-init.js

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (65 lines) | stat: -rw-r--r-- 2,987 bytes parent folder | download | duplicates (30)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function init(e, method) {
  /*
   * This test suite tests Selectors API methods in 4 different contexts:
   * 1. Document node
   * 2. In-document Element node
   * 3. Detached Element node (an element with no parent, not in the document)
   * 4. Document Fragment node
   *
   * For each context, the following tests are run:
   *
   * The interface check tests ensure that each type of node exposes the Selectors API methods.
   *
   * The matches() tests are run
   * All the selectors tested for both the valid and invalid selector tests are found in selectors.js.
   * See comments in that file for documentation of the format used.
   *
   * The level2-lib.js file contains all the common test functions for running each of the aforementioned tests
   */

  var docType  = "html"; // Only run tests suitable for HTML

  // Prepare the nodes for testing
  var doc = e.target.contentDocument;                 // Document Node tests

  var element = doc.getElementById("root");   // In-document Element Node tests

  //Setup the namespace tests
  setupSpecialElements(doc, element);

  var outOfScope = element.cloneNode(true);   // Append this to the body before running the in-document
                                               // Element tests, but after running the Document tests. This
                                               // tests that no elements that are not descendants of element
                                               // are selected.

  traverse(outOfScope, function(elem) {        // Annotate each element as being a clone; used for verifying
    elem.setAttribute("data-clone", "");     // that none of these elements ever match.
  });


  var detached = element.cloneNode(true);     // Detached Element Node tests

  var fragment = doc.createDocumentFragment(); // Fragment Node tests
  fragment.appendChild(element.cloneNode(true));

  // Setup Tests
  interfaceCheckMatches(method, "Document", doc);
  interfaceCheckMatches(method, "Detached Element", detached);
  interfaceCheckMatches(method, "Fragment", fragment);
  interfaceCheckMatches(method, "In-document Element", element);

  runSpecialMatchesTests(method, "DIV Element", element);
  runSpecialMatchesTests(method, "NULL Element", document.createElement("null"));
  runSpecialMatchesTests(method, "UNDEFINED Element", document.createElement("undefined"));

  runInvalidSelectorTestMatches(method, "Document", doc, invalidSelectors);
  runInvalidSelectorTestMatches(method, "Detached Element", detached, invalidSelectors);
  runInvalidSelectorTestMatches(method, "Fragment", fragment, invalidSelectors);
  runInvalidSelectorTestMatches(method, "In-document Element", element, invalidSelectors);

  runMatchesTest(method, "In-document", doc, validSelectors, "html");
  runMatchesTest(method, "Detached", detached, validSelectors, "html");
  runMatchesTest(method, "Fragment", fragment, validSelectors, "html");

  runMatchesTest(method, "In-document", doc, scopedSelectors, "html");
}