mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-12 06:08:24 +02:00
MozReview-Commit-ID: 3HXcvTYpAkA --HG-- rename : testing/web-platform/tests/fonts/matching/README.md => testing/web-platform/tests/css-fonts/matching/README.md rename : testing/web-platform/tests/fonts/matching/fixed-stretch-style-over-weight-ref.html => testing/web-platform/tests/css-fonts/matching/fixed-stretch-style-over-weight-ref.html rename : testing/web-platform/tests/fonts/matching/fixed-stretch-style-over-weight.html => testing/web-platform/tests/css-fonts/matching/fixed-stretch-style-over-weight.html rename : testing/web-platform/tests/fonts/matching/font-matching.css => testing/web-platform/tests/css-fonts/matching/font-matching.css rename : testing/web-platform/tests/fonts/matching/resources/variabletest_matching.ttf => testing/web-platform/tests/css-fonts/matching/resources/variabletest_matching.ttf rename : testing/web-platform/tests/fonts/matching/stretch-distance-over-weight-distance-ref.html => testing/web-platform/tests/css-fonts/matching/stretch-distance-over-weight-distance-ref.html rename : testing/web-platform/tests/fonts/matching/stretch-distance-over-weight-distance.html => testing/web-platform/tests/css-fonts/matching/stretch-distance-over-weight-distance.html rename : testing/web-platform/tests/fonts/matching/style-ranges-over-weight-direction-ref.html => testing/web-platform/tests/css-fonts/matching/style-ranges-over-weight-direction-ref.html rename : testing/web-platform/tests/fonts/matching/style-ranges-over-weight-direction.html => testing/web-platform/tests/css-fonts/matching/style-ranges-over-weight-direction.html rename : testing/web-platform/tests/payment-request/OWNERS => testing/web-platform/tests/payment-method-id/OWNERS rename : testing/web-platform/tests/storage/interfaces.worker.js => testing/web-platform/tests/storage/interfaces.https.worker.js rename : testing/web-platform/tests/tools/browserutils/requirements.txt => testing/web-platform/tests/tools/wpt/requirements.txt rename : testing/web-platform/tests/tools/browserutils/utils.py => testing/web-platform/tests/tools/wpt/utils.py rename : testing/web-platform/tests/tools/wptrunner/wptrunner/executors/reftest-wait.js => testing/web-platform/tests/tools/wptrunner/wptrunner/executors/reftest-wait_marionette.js rename : testing/web-platform/tests/uievents/keyboard/key-manual.css => testing/web-platform/tests/uievents/keyboard/key.css rename : testing/web-platform/tests/uievents/keyboard/key-manual.js => testing/web-platform/tests/uievents/keyboard/key.js
65 lines
2.9 KiB
JavaScript
65 lines
2.9 KiB
JavaScript
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");
|
|
}
|