gecko-dev/testing/web-platform/tests/dom/nodes/Element-matches.js
James Graham f115b4f38d Bug 1345490 - Update web-platform-tests to revision 7c7db1b516b01394e19fad80094fbb81ab02ce75, a=testonly
MozReview-Commit-ID: 4wsHtf9312c


--HG--
rename : testing/web-platform/tests/html/browsers/windows/support-window-name-echo.html => testing/web-platform/tests/html/browsers/windows/resources/echo-window-name.html
rename : testing/web-platform/tests/html/browsers/windows/support-nested-browsing-contexts.html => testing/web-platform/tests/html/browsers/windows/resources/nested-post-to-opener.html
rename : testing/web-platform/tests/html/browsers/windows/support-named-null-opener.html => testing/web-platform/tests/html/browsers/windows/resources/noreferrer-window-name.html
rename : testing/web-platform/tests/html/browsers/windows/support-post-to-opener.html => testing/web-platform/tests/html/browsers/windows/resources/post-to-opener.html
rename : testing/web-platform/tests/html/browsers/windows/support-close.html => testing/web-platform/tests/html/browsers/windows/resources/window-close-button.html
rename : testing/web-platform/tests/html/browsers/windows/support-opener-null.html => testing/web-platform/tests/html/browsers/windows/resources/window-opener.html
rename : testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-end.https.html => testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-end-manual.https.html
rename : testing/web-platform/tests/notifications/shownotification-resolve-manual.html => testing/web-platform/tests/notifications/shownotification-resolve-manual.https.html
rename : testing/web-platform/tests/service-workers/service-worker/fetch-event-within-sw-manual.html => testing/web-platform/tests/service-workers/service-worker/fetch-event-within-sw-manual.https.html
rename : testing/web-platform/tests/service-workers/service-worker/fetch-event-within-sw.html => testing/web-platform/tests/service-workers/service-worker/fetch-event-within-sw.https.html
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-cue-text-parsing-rules/buildtests.py => testing/web-platform/tests/webvtt/parsing/cue-text-parsing/buildtests.py
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-cue-text-parsing-rules/common.js => testing/web-platform/tests/webvtt/parsing/cue-text-parsing/common.js
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-cue-text-parsing-rules/dat/entities.dat => testing/web-platform/tests/webvtt/parsing/cue-text-parsing/dat/entities.dat
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-cue-text-parsing-rules/dat/tags.dat => testing/web-platform/tests/webvtt/parsing/cue-text-parsing/dat/tags.dat
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-cue-text-parsing-rules/dat/timestamps.dat => testing/web-platform/tests/webvtt/parsing/cue-text-parsing/dat/timestamps.dat
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-cue-text-parsing-rules/dat/tree-building.dat => testing/web-platform/tests/webvtt/parsing/cue-text-parsing/dat/tree-building.dat
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-cue-text-parsing-rules/tests/entities.html => testing/web-platform/tests/webvtt/parsing/cue-text-parsing/tests/entities.html
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-cue-text-parsing-rules/tests/tags.html => testing/web-platform/tests/webvtt/parsing/cue-text-parsing/tests/tags.html
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-cue-text-parsing-rules/tests/timestamps.html => testing/web-platform/tests/webvtt/parsing/cue-text-parsing/tests/timestamps.html
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-cue-text-parsing-rules/tests/tree-building.html => testing/web-platform/tests/webvtt/parsing/cue-text-parsing/tests/tree-building.html
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/signature-formfeed.vtt => testing/web-platform/tests/webvtt/parsing/file-parsing/support/signature-formfeed.vtt
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/signature-lowercase.vtt => testing/web-platform/tests/webvtt/parsing/file-parsing/support/signature-lowercase.vtt
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/signature-null.vtt => testing/web-platform/tests/webvtt/parsing/file-parsing/support/signature-null.vtt
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/signature-too-short.vtt => testing/web-platform/tests/webvtt/parsing/file-parsing/support/signature-partial.vtt
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/signature-two-boms.vtt => testing/web-platform/tests/webvtt/parsing/file-parsing/support/signature-two-boms.vtt
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/signature-websrt.vtt => testing/web-platform/tests/webvtt/parsing/file-parsing/support/signature-websrt.vtt
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/signature-bom.vtt => testing/web-platform/tests/webvtt/parsing/file-parsing/tests/support/signature-bom.vtt
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/signature-no-newline.vtt => testing/web-platform/tests/webvtt/parsing/file-parsing/tests/support/signature-no-newline.vtt
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/signature-space-no-newline.vtt => testing/web-platform/tests/webvtt/parsing/file-parsing/tests/support/signature-space-no-newline.vtt
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/signature-space.vtt => testing/web-platform/tests/webvtt/parsing/file-parsing/tests/support/signature-space.vtt
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/signature-tab-no-newline.vtt => testing/web-platform/tests/webvtt/parsing/file-parsing/tests/support/signature-tab-no-newline.vtt
rename : testing/web-platform/tests/webvtt/webvtt-file-format-parsing/webvtt-file-parsing/support/signature-tab.vtt => testing/web-platform/tests/webvtt/parsing/file-parsing/tests/support/signature-tab.vtt
2017-03-17 14:34:25 +00:00

131 lines
4.6 KiB
JavaScript

/*
* Check that the matches() method exists on the given Node
*/
function interfaceCheckMatches(method, type, obj) {
if (obj.nodeType === obj.ELEMENT_NODE) {
test(function() {
assert_idl_attribute(obj, method, type + " supports " + method);
}, type + " supports " + method)
} else {
test(function() {
assert_false(method in obj, type + " supports " + method);
}, type + " should not support " + method)
}
}
function runSpecialMatchesTests(method, type, element) {
test(function() { // 1
if (element.tagName.toLowerCase() === "null") {
assert_true(element[method](null), "An element with the tag name '" + element.tagName.toLowerCase() + "' should match.");
} else {
assert_false(element[method](null), "An element with the tag name '" + element.tagName.toLowerCase() + "' should not match.");
}
}, type + "." + method + "(null)")
test(function() { // 2
if (element.tagName.toLowerCase() === "undefined") {
assert_true(element[method](undefined), "An element with the tag name '" + element.tagName.toLowerCase() + "' should match.");
} else {
assert_false(element[method](undefined), "An element with the tag name '" + element.tagName.toLowerCase() + "' should not match.");
}
}, type + "." + method + "(undefined)")
test(function() { // 3
assert_throws(TypeError(), function() {
element[method]();
}, "This should throw a TypeError.")
}, type + "." + method + " no parameter")
}
/*
* Execute queries with the specified invalid selectors for matches()
* Only run these tests when errors are expected. Don't run for valid selector tests.
*/
function runInvalidSelectorTestMatches(method, type, root, selectors) {
if (root.nodeType === root.ELEMENT_NODE) {
for (var i = 0; i < selectors.length; i++) {
var s = selectors[i];
var n = s["name"];
var q = s["selector"];
test(function() {
assert_throws("SyntaxError", function() {
root[method](q)
})
}, type + "." + method + ": " + n + ": " + q);
}
}
}
function runMatchesTest(method, type, root, selectors, docType) {
var nodeType = getNodeType(root);
for (var i = 0; i < selectors.length; i++) {
var s = selectors[i];
var n = s["name"];
var q = s["selector"];
var e = s["expect"];
var u = s["unexpected"];
var ctx = s["ctx"];
var ref = s["ref"];
if ((!s["exclude"] || (s["exclude"].indexOf(nodeType) === -1 && s["exclude"].indexOf(docType) === -1))
&& (s["testType"] & TEST_MATCH) ) {
if (ctx && !ref) {
test(function() {
var j, element, refNode;
for (j = 0; j < e.length; j++) {
element = root.querySelector("#" + e[j]);
refNode = root.querySelector(ctx);
assert_true(element[method](q, refNode), "The element #" + e[j] + " should match the selector.")
}
if (u) {
for (j = 0; j < u.length; j++) {
element = root.querySelector("#" + u[j]);
refNode = root.querySelector(ctx);
assert_false(element[method](q, refNode), "The element #" + u[j] + " should not match the selector.")
}
}
}, type + " Element." + method + ": " + n + " (with refNode Element): " + q);
}
if (ref) {
test(function() {
var j, element, refNodes;
for (j = 0; j < e.length; j++) {
element = root.querySelector("#" + e[j]);
refNodes = root.querySelectorAll(ref);
assert_true(element[method](q, refNodes), "The element #" + e[j] + " should match the selector.")
}
if (u) {
for (j = 0; j < u.length; j++) {
element = root.querySelector("#" + u[j]);
refNodes = root.querySelectorAll(ref);
assert_false(element[method](q, refNodes), "The element #" + u[j] + " should not match the selector.")
}
}
}, type + " Element." + method + ": " + n + " (with refNodes NodeList): " + q);
}
if (!ctx && !ref) {
test(function() {
for (var j = 0; j < e.length; j++) {
var element = root.querySelector("#" + e[j]);
assert_true(element[method](q), "The element #" + e[j] + " should match the selector.")
}
if (u) {
for (j = 0; j < u.length; j++) {
element = root.querySelector("#" + u[j]);
assert_false(element[method](q), "The element #" + u[j] + " should not match the selector.")
}
}
}, type + " Element." + method + ": " + n + " (with no refNodes): " + q);
}
}
}
}