Bug 1048780 - Call the standard matches() rather than the proprietary mozMatchesSelector(); r=jst

This also includes a test that mozMatchesSelector is still exposed and works.

--HG--
rename : js/xpconnect/tests/chrome/test_mozMatchesSelector.xul => js/xpconnect/tests/chrome/test_matches.xul
rename : js/xpconnect/tests/mochitest/file_mozMatchesSelector.html => js/xpconnect/tests/mochitest/file_matches.html
This commit is contained in:
Ms2ger 2014-08-12 14:30:59 +02:00
parent f10bc818e5
commit 5b546538b2
72 changed files with 197 additions and 185 deletions

View File

@ -571,8 +571,7 @@ let gHistorySwipeAnimation = {
return;
this.active = false;
this.isLTR = document.documentElement.mozMatchesSelector(
":-moz-locale-dir(ltr)");
this.isLTR = document.documentElement.matches(":-moz-locale-dir(ltr)");
this._trackedSnapshots = [];
this._startingIndex = -1;
this._historyIndex = -1;

View File

@ -648,7 +648,7 @@ nsContextMenu.prototype = {
else if ((this.target instanceof HTMLEmbedElement ||
this.target instanceof HTMLObjectElement ||
this.target instanceof HTMLAppletElement) &&
this.target.mozMatchesSelector(":-moz-handler-clicktoplay")) {
this.target.matches(":-moz-handler-clicktoplay")) {
this.onCTPPlugin = true;
}

View File

@ -4145,7 +4145,7 @@ OverflowableToolbar.prototype = {
this._hideTimeoutId = null;
}
this._hideTimeoutId = window.setTimeout(() => {
if (!this._panel.firstChild.mozMatchesSelector(":hover")) {
if (!this._panel.firstChild.matches(":hover")) {
this._panel.hidePopup();
}
}, OVERFLOW_PANEL_HIDE_DELAY_MS);

View File

@ -487,7 +487,7 @@ function checkContextMenu(aContextMenu, aExpectedEntries, aWindow=window) {
}
let selector = aExpectedEntries[i][0];
ok(menuitem.mozMatchesSelector(selector), "menuitem should match " + selector + " selector");
ok(menuitem.matches(selector), "menuitem should match " + selector + " selector");
let commandValue = menuitem.getAttribute("command");
let relatedCommand = commandValue ? aWindow.document.getElementById(commandValue) : null;
let menuItemDisabled = relatedCommand ?

View File

@ -587,7 +587,7 @@ gTests.push({
handleStub.restore();
}
ok(!firstItem.mozMatchesSelector("richgriditem[value]"), "Released slot doesn't match binding selector");
ok(!firstItem.matches("richgriditem[value]"), "Released slot doesn't match binding selector");
ok(isNotBoundByRichGrid_Item(firstItem), "Released slot is no longer bound");
waitForCondition(() => isNotBoundByRichGrid_Item(firstItem));

View File

@ -521,7 +521,7 @@
var key = +new Date + ":" + Math.random();
function report(item, shouldMatch) {
assert( item.mozMatchesSelector(q) === shouldMatch,
assert( item.matches(q) === shouldMatch,
item + (shouldMatch ? "does not match" : "matches")
+ " selector '" + q + "'" );
}

View File

@ -600,6 +600,7 @@ skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #TIMED_OUT, SSL_REQU
skip-if = buildapp == 'b2g' || toolkit == 'android' || e10s #TIMED_OUT, SSL_REQUIRED
[test_mozfiledataurl.html]
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' || e10s #TIMED_OUT
[test_mozMatchesSelector.html]
[test_mutationobservers.html]
skip-if = buildapp == 'b2g' || e10s # b2g(bug 901385, showmodaldialog) b2g-debug(bug 901385, showmodaldialog) b2g-desktop(bug 901385, showmodaldialog)
[test_nodelist_holes.html]

View File

@ -20,7 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=562169
/** Test for Bug 562169 **/
/** Test that a newly created element has ltr directionality **/
ok(document.createElement("div").mozMatchesSelector(":-moz-dir(ltr)"),
ok(document.createElement("div").matches(":-moz-dir(ltr)"),
"Element should be ltr on creation");
</script>

View File

@ -20,7 +20,7 @@ var elmt = document.createElement("div");
var caught = false;
try {
elmt.mozMatchesSelector("!!");
elmt.matches("!!");
} catch(e) {
ok(e.name == "SyntaxError", "Error should be SyntaxError");
ok(e.code == DOMException.SYNTAX_ERR, "Error code should be SYNTAX_ERR");

View File

@ -19,11 +19,9 @@ function doTest() {
var monitor = document.getElementById("monitor");
var html = document.documentElement;
var results;
var matches = html.matchesSelector || html.mozMatchesSelector;
try {
results = "return: " +
matches.call(html, "[test!='']:sizzle") + "\n";
results = "return: " + html.matches("[test!='']:sizzle") + "\n";
} catch (e) {
results = "throws: " + e + "\n";
}

View File

@ -0,0 +1,14 @@
<!doctype html>
<meta charset=utf-8>
<title>Test for legacy mozMatchesSelector</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<div id=test></div>
<script>
test(function() {
var element = document.getElementById("test");
assert_true(element.matches("#test"), "matches");
assert_true(element.mozMatchesSelector("#test"), "mozMatchesSelector");
});
</script>

View File

@ -62,7 +62,7 @@ function enter1(event) {
ok(document.mozFullScreen, "1. Should be in full-screen mode (first time)");
is(event.target, document, "2. Event target should be full-screen document #1");
is(document.mozFullScreenElement, fullScreenElement(), "3. Full-screen element should be div element.");
ok(document.mozFullScreenElement.mozMatchesSelector(":-moz-full-screen"), "4. FSE should match :-moz-full-screen");
ok(document.mozFullScreenElement.matches(":-moz-full-screen"), "4. FSE should match :-moz-full-screen");
var fse = fullScreenElement();
addFullscreenChangeContinuation("exit", exit1);
fse.parentNode.removeChild(fse);
@ -158,9 +158,9 @@ function enter4(event) {
var n = container;
do {
ok(n.mozMatchesSelector(":-moz-full-screen-ancestor"), "Ancestor " + n + " should match :-moz-full-screen-ancestor")
ok(n.matches(":-moz-full-screen-ancestor"), "Ancestor " + n + " should match :-moz-full-screen-ancestor")
n = n.parentNode;
} while (n && n.mozMatchesSelector);
} while (n && n.matches);
// Remove full-screen ancestor element from document, verify it stops being reported as current FSE.
addFullscreenChangeContinuation("exit", exit4);

View File

@ -43,7 +43,7 @@ function checkValidEmailAddress(element)
ok(!gInvalid, "The invalid event should not have been thrown");
is(element.validationMessage, '',
"Validation message should be the empty string");
ok(element.mozMatchesSelector(":valid"), ":valid pseudo-class should apply");
ok(element.matches(":valid"), ":valid pseudo-class should apply");
}
function checkInvalidEmailAddress(element)
@ -56,7 +56,7 @@ function checkInvalidEmailAddress(element)
ok(gInvalid, "The invalid event should have been thrown");
is(element.validationMessage, "Please enter an email address.",
"Validation message is not valid");
ok(element.mozMatchesSelector(":invalid"), ":invalid pseudo-class should apply");
ok(element.matches(":invalid"), ":invalid pseudo-class should apply");
}
function testEmailAddress(aElement, aValue, aMultiple, aValidity)

View File

@ -78,7 +78,7 @@ function checkIsValid(element, infoStr)
ok(!gInvalid, "The invalid event should not have been thrown for " + infoStr);
is(element.validationMessage, '',
"Validation message should be the empty string for " + infoStr);
ok(element.mozMatchesSelector(":valid"), ":valid pseudo-class should apply for " + infoStr);
ok(element.matches(":valid"), ":valid pseudo-class should apply for " + infoStr);
}
function checkIsInvalid(element, infoStr)
@ -90,7 +90,7 @@ function checkIsInvalid(element, infoStr)
ok(gInvalid, "The invalid event should have been thrown for " + infoStr);
is(element.validationMessage, "Please enter a number.",
"Validation message is not the expected message for " + infoStr);
ok(element.mozMatchesSelector(":invalid"), ":invalid pseudo-class should apply for " + infoStr);
ok(element.matches(":invalid"), ":invalid pseudo-class should apply for " + infoStr);
}
</script>

View File

@ -35,7 +35,7 @@ function checkValidURL(element)
ok(!gInvalid, "The invalid event should not have been thrown");
is(element.validationMessage, '',
"Validation message should be the empty string");
ok(element.mozMatchesSelector(":valid"), ":valid pseudo-class should apply");
ok(element.matches(":valid"), ":valid pseudo-class should apply");
}
function checkInvalidURL(element)
@ -48,7 +48,7 @@ function checkInvalidURL(element)
ok(gInvalid, "The invalid event should have been thrown");
is(element.validationMessage, "Please enter a URL.",
"Validation message should be related to invalid URL");
ok(element.mozMatchesSelector(":invalid"),
ok(element.matches(":invalid"),
":invalid pseudo-class should apply");
}

View File

@ -76,19 +76,19 @@ function checkValidity(aElement, aValidity, aApply, aRangeApply)
is(aElement.validationMessage,
aValidity ? "" : overflowMsg, "Checking range overflow validation message");
is(aElement.mozMatchesSelector(":valid"), aElement.willValidate && aValidity,
is(aElement.matches(":valid"), aElement.willValidate && aValidity,
(aElement.willValidate && aValidity) ? ":valid should apply" : "valid shouldn't apply");
is(aElement.mozMatchesSelector(":invalid"), aElement.willValidate && !aValidity,
is(aElement.matches(":invalid"), aElement.willValidate && !aValidity,
(aElement.wil && aValidity) ? ":invalid shouldn't apply" : "valid should apply");
if (!aRangeApply) {
ok(!aElement.mozMatchesSelector(":in-range"), ":in-range should not match");
ok(!aElement.mozMatchesSelector(":out-of-range"),
ok(!aElement.matches(":in-range"), ":in-range should not match");
ok(!aElement.matches(":out-of-range"),
":out-of-range should not match");
} else {
is(aElement.mozMatchesSelector(":in-range"), aValidity,
is(aElement.matches(":in-range"), aValidity,
":in-range matches status should be " + aValidity);
is(aElement.mozMatchesSelector(":out-of-range"), !aValidity,
is(aElement.matches(":out-of-range"), !aValidity,
":out-of-range matches status should be " + !aValidity);
}
}

View File

@ -25,7 +25,7 @@ function checkOptimum(aElement, aValue, aOptimum, expectedResult)
aElement.setAttribute('value', aValue);
aElement.setAttribute('optimum', aOptimum);
is(aElement.mozMatchesSelector(":-moz-meter-optimum"),
is(aElement.matches(":-moz-meter-optimum"),
expectedResult, errorString);
}
@ -37,7 +37,7 @@ function checkSubOptimum(aElement, aValue, aOptimum, expectedResult)
}
aElement.setAttribute('value', aValue);
aElement.setAttribute('optimum', aOptimum);
is(aElement.mozMatchesSelector(":-moz-meter-sub-optimum"),
is(aElement.matches(":-moz-meter-sub-optimum"),
expectedResult, errorString);
}
@ -49,7 +49,7 @@ function checkSubSubOptimum(aElement, aValue, aOptimum, expectedResult)
}
aElement.setAttribute('value', aValue);
aElement.setAttribute('optimum', aOptimum);
is(aElement.mozMatchesSelector(":-moz-meter-sub-sub-optimum"),
is(aElement.matches(":-moz-meter-sub-sub-optimum"),
expectedResult, errorString);
}

View File

@ -76,19 +76,19 @@ function checkValidity(aElement, aValidity, aApply, aRangeApply)
is(aElement.validationMessage,
aValidity ? "" : underflowMsg, "Checking range underflow validation message");
is(aElement.mozMatchesSelector(":valid"), aElement.willValidate && aValidity,
is(aElement.matches(":valid"), aElement.willValidate && aValidity,
(aElement.willValidate && aValidity) ? ":valid should apply" : "valid shouldn't apply");
is(aElement.mozMatchesSelector(":invalid"), aElement.willValidate && !aValidity,
is(aElement.matches(":invalid"), aElement.willValidate && !aValidity,
(aElement.wil && aValidity) ? ":invalid shouldn't apply" : "valid should apply");
if (!aRangeApply) {
ok(!aElement.mozMatchesSelector(":in-range"), ":in-range should not match");
ok(!aElement.mozMatchesSelector(":out-of-range"),
ok(!aElement.matches(":in-range"), ":in-range should not match");
ok(!aElement.matches(":out-of-range"),
":out-of-range should not match");
} else {
is(aElement.mozMatchesSelector(":in-range"), aValidity,
is(aElement.matches(":in-range"), aValidity,
":in-range matches status should be " + aValidity);
is(aElement.mozMatchesSelector(":out-of-range"), !aValidity,
is(aElement.matches(":out-of-range"), !aValidity,
":out-of-range matches status should be " + !aValidity);
}
}

View File

@ -111,8 +111,8 @@ testCases.forEach(function(testCase) {
var option = content.querySelector('option');
is(option.getAttribute('disabled'), result.attr, "disabled content attribute value should be " + result.attr);
is(option.disabled, result.idl, "disabled idl attribute value should be " + result.idl);
is(option.mozMatchesSelector(":disabled"), result.pseudo, ":disabled state should be " + result.pseudo);
is(option.mozMatchesSelector(":enabled"), !result.pseudo, ":enabled state should be " + !result.pseudo);
is(option.matches(":disabled"), result.pseudo, ":disabled state should be " + result.pseudo);
is(option.matches(":enabled"), !result.pseudo, ":enabled state should be " + !result.pseudo);
content.innerHTML = "";
});

View File

@ -187,7 +187,7 @@ function checkIndeterminatePseudoClass()
aElement.removeAttribute('max');
}
is(aElement.mozMatchesSelector("progress:indeterminate"), aIndeterminate,
is(aElement.matches("progress:indeterminate"), aIndeterminate,
"<progress> indeterminate state should be " + aIndeterminate);
}

View File

@ -30,15 +30,15 @@ function checkNotSufferingFromBeingMissing(element, doNotApply)
"Validation message should be the empty string");
if (doNotApply) {
ok(!element.mozMatchesSelector(':valid'), ":valid should not apply");
ok(!element.mozMatchesSelector(':invalid'), ":invalid should not apply");
ok(!element.mozMatchesSelector(':-moz-ui-valid'), ":-moz-ui-valid should not apply");
ok(!element.mozMatchesSelector(':-moz-ui-invalid'), ":-moz-ui-invalid should not apply");
ok(!element.matches(':valid'), ":valid should not apply");
ok(!element.matches(':invalid'), ":invalid should not apply");
ok(!element.matches(':-moz-ui-valid'), ":-moz-ui-valid should not apply");
ok(!element.matches(':-moz-ui-invalid'), ":-moz-ui-invalid should not apply");
} else {
ok(element.mozMatchesSelector(':valid'), ":valid should apply");
ok(!element.mozMatchesSelector(':invalid'), ":invalid should not apply");
ok(element.mozMatchesSelector(':-moz-ui-valid'), ":-moz-ui-valid should apply");
ok(!element.mozMatchesSelector(':-moz-ui-invalid'), ":-moz-ui-invalid should not apply");
ok(element.matches(':valid'), ":valid should apply");
ok(!element.matches(':invalid'), ":invalid should not apply");
ok(element.matches(':-moz-ui-valid'), ":-moz-ui-valid should apply");
ok(!element.matches(':-moz-ui-invalid'), ":-moz-ui-invalid should not apply");
}
}
@ -73,10 +73,10 @@ function checkSufferingFromBeingMissing(element, hasMozUIInvalid)
"Validation message is wrong");
}
ok(!element.mozMatchesSelector(':valid'), ":valid should apply");
ok(element.mozMatchesSelector(':invalid'), ":invalid should not apply");
ok(!element.mozMatchesSelector(':-moz-ui-valid'), ":-moz-ui-valid should not apply");
is(element.mozMatchesSelector(':-moz-ui-invalid'), hasMozUIInvalid, ":-moz-ui-invalid expected state is " + hasMozUIInvalid);
ok(!element.matches(':valid'), ":valid should apply");
ok(element.matches(':invalid'), ":invalid should not apply");
ok(!element.matches(':-moz-ui-valid'), ":-moz-ui-valid should not apply");
is(element.matches(':-moz-ui-invalid'), hasMozUIInvalid, ":-moz-ui-invalid expected state is " + hasMozUIInvalid);
}
function checkTextareaRequiredValidity()

View File

@ -81,9 +81,9 @@ function checkValidity(aElement, aValidity, aApply, aData)
}
}
is(aElement.mozMatchesSelector(":valid"), aElement.willValidate && aValidity,
is(aElement.matches(":valid"), aElement.willValidate && aValidity,
(aElement.willValidate && aValidity) ? ":valid should apply" : "valid shouldn't apply");
is(aElement.mozMatchesSelector(":invalid"), aElement.willValidate && !aValidity,
is(aElement.matches(":invalid"), aElement.willValidate && !aValidity,
(aElement.wil && aValidity) ? ":invalid shouldn't apply" : "valid should apply");
}

View File

@ -25,19 +25,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=598833
/** Test for Bug 598833 **/
var s = $("s");
is(s.mozMatchesSelector(":invalid"), false, "Disabled select should not be invalid");
is(s.mozMatchesSelector(":valid"), false, "Disabled select should not be valid");
is(s.matches(":invalid"), false, "Disabled select should not be invalid");
is(s.matches(":valid"), false, "Disabled select should not be valid");
var p = s.parentNode;
p.removeChild(s);
is(s.mozMatchesSelector(":invalid"), true,
is(s.matches(":invalid"), true,
"Required valueless select not in tree should be invalid");
is(s.mozMatchesSelector(":valid"), false,
is(s.matches(":valid"), false,
"Required valueless select not in tree should not be valid");
p.appendChild(s);
p.disabled = false;
is(s.mozMatchesSelector(":invalid"), true,
is(s.matches(":invalid"), true,
"Required valueless select should be invalid");
is(s.mozMatchesSelector(":valid"), false,
is(s.matches(":valid"), false,
"Required valueless select should not be valid");
</script>
</pre>

View File

@ -37,8 +37,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=605124
function checkPseudoClass(aElement, aExpected)
{
is(aElement.mozMatchesSelector(":-moz-ui-invalid"), aExpected,
"mozMatchesSelector(':-moz-ui-invalid') should return " + aExpected + " for " + aElement);
is(aElement.matches(":-moz-ui-invalid"), aExpected,
"matches(':-moz-ui-invalid') should return " + aExpected + " for " + aElement);
}
var os = SpecialPowers.Cc['@mozilla.org/observer-service;1']

View File

@ -31,8 +31,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=605124
function checkPseudoClass(aElement, aExpected)
{
is(aElement.mozMatchesSelector(":-moz-ui-invalid"), aExpected,
"mozMatchesSelector(':-moz-ui-invalid') should return " + aExpected + " for " + aElement);
is(aElement.matches(":-moz-ui-invalid"), aExpected,
"matches(':-moz-ui-invalid') should return " + aExpected + " for " + aElement);
}
function checkElement(aElement)

View File

@ -43,8 +43,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=605125
function checkPseudoClass(aElement, aExpected)
{
is(aElement.mozMatchesSelector(":-moz-ui-valid"), aExpected,
"mozMatchesSelector(':-moz-ui-valid') should return " + aExpected + " for " + aElement);
is(aElement.matches(":-moz-ui-valid"), aExpected,
"matches(':-moz-ui-valid') should return " + aExpected + " for " + aElement);
}
var os = SpecialPowers.Cc['@mozilla.org/observer-service;1']

View File

@ -31,8 +31,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=605125
function checkPseudoClass(aElement, aExpected)
{
is(aElement.mozMatchesSelector(":-moz-ui-valid"), aExpected,
"mozMatchesSelector(':-moz-ui-valid') should return " + aExpected + " for " + aElement);
is(aElement.matches(":-moz-ui-valid"), aExpected,
"matches(':-moz-ui-valid') should return " + aExpected + " for " + aElement);
}
function checkElement(aElement)

View File

@ -29,15 +29,15 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=610687
function checkPseudoClasses(aElement, aValid, aValidUI, aInvalidUI)
{
if (aValid) {
ok(aElement.mozMatchesSelector(":valid"), ":valid should apply");
ok(aElement.matches(":valid"), ":valid should apply");
} else {
ok(aElement.mozMatchesSelector(":invalid"), ":invalid should apply");
ok(aElement.matches(":invalid"), ":invalid should apply");
}
is(aElement.mozMatchesSelector(":-moz-ui-valid"), aValidUI,
is(aElement.matches(":-moz-ui-valid"), aValidUI,
aValid ? ":-moz-ui-valid should apply" : ":-moz-ui-valid should not apply");
is(aElement.mozMatchesSelector(":-moz-ui-invalid"), aInvalidUI,
is(aElement.matches(":-moz-ui-invalid"), aInvalidUI,
aInvalidUI ? ":-moz-ui-invalid should apply" : ":-moz-ui-invalid should not apply");
if (aInvalidUI && (aValid || aValidUI)) {

View File

@ -34,9 +34,9 @@ function runTest()
isnot(select.selectedIndex, -1, "Something should have been selected");
ok(!select.mozMatchesSelector(":-moz-ui-valid"),
ok(!select.matches(":-moz-ui-valid"),
":-moz-ui-valid should not apply");
todo(!select.mozMatchesSelector(":-moz-ui-invalid"),
todo(!select.matches(":-moz-ui-invalid"),
":-moz-ui-invalid should not apply");
SimpleTest.finish();

View File

@ -24,7 +24,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=619278
function doElementMatchesSelector(aElement, aSelector)
{
ok(aElement.mozMatchesSelector(aSelector),
ok(aElement.matches(aSelector),
aSelector + " should match for " + aElement);
}

View File

@ -29,9 +29,9 @@ if (navigator.platform.startsWith("Win")) {
function checkSelectors(aElement)
{
ok(aElement.mozMatchesSelector(":-moz-ui-invalid"),
ok(aElement.matches(":-moz-ui-invalid"),
":-moz-ui-invalid should match for " + aElement);
ok(!aElement.mozMatchesSelector(":-moz-ui-valid"),
ok(!aElement.matches(":-moz-ui-valid"),
":-moz-ui-valid should not match for " + aElement);
}

View File

@ -33,10 +33,10 @@ var button = form.elements[3];
function checkPseudoClasses(aElement, aValid, aInvalid)
{
is(aElement.mozMatchesSelector(":-moz-ui-valid"), aValid,
is(aElement.matches(":-moz-ui-valid"), aValid,
aValid ? aElement + " should match :-moz-ui-valid"
: aElement + " should not match :-moz-ui-valid");
is(aElement.mozMatchesSelector(":-moz-ui-invalid"), aInvalid,
is(aElement.matches(":-moz-ui-invalid"), aInvalid,
aInvalid ? aElement + " should match :-moz-ui-invalid"
: aElement + " should not match :-moz-ui-invalid");
if (aValid && aInvalid) {

View File

@ -19,10 +19,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=787134
var div = document.createElement('div');
div.innerHTML = '<a href=#></a>';
var a = div.firstChild;
ok(a.mozMatchesSelector(':link'), "Should match a link not in a document");
ok(a.matches(':link'), "Should match a link not in a document");
is(div.querySelector(':link'), a, "Should find a link not in a document");
a = document.querySelector('#link-test1');
ok(a.mozMatchesSelector(':link'), "Should match a link in a document with an invalid URL");
ok(a.matches(':link'), "Should match a link in a document with an invalid URL");
</script>
</pre>
</body>

View File

@ -33,33 +33,33 @@ SimpleTest.waitForExplicitFinish();
function tests() {
synthesizeMouseAtCenter($("label1"), { type: "mousemove" });
yield undefined;
is($("button1").mozMatchesSelector(":hover"), true,
is($("button1").matches(":hover"), true,
"Button 1 should be hovered after mousemove over label1");
is($("label1").mozMatchesSelector(":hover"), true,
is($("label1").matches(":hover"), true,
"Label 1 should be hovered after mousemove over label1");
is($("button2").mozMatchesSelector(":hover"), false,
is($("button2").matches(":hover"), false,
"Button 2 should not be hovered after mousemove over label1");
is($("label2").mozMatchesSelector(":hover"), false,
is($("label2").matches(":hover"), false,
"Label 2 should not be hovered after mousemove over label1");
synthesizeMouseAtCenter($("button2"), { type: "mousemove" });
yield undefined;
is($("button1").mozMatchesSelector(":hover"), false,
is($("button1").matches(":hover"), false,
"Button 1 should not be hovered after mousemove over button2");
is($("label1").mozMatchesSelector(":hover"), false,
is($("label1").matches(":hover"), false,
"Label 1 should not be hovered after mousemove over button2");
is($("button2").mozMatchesSelector(":hover"), true,
is($("button2").matches(":hover"), true,
"Button 2 should be hovered after mousemove over button2");
is($("label2").mozMatchesSelector(":hover"), false,
is($("label2").matches(":hover"), false,
"Label 2 should not be hovered after mousemove over label2");
synthesizeMouseAtCenter($("label2"), { type: "mousemove" });
yield undefined;
is($("button1").mozMatchesSelector(":hover"), false,
is($("button1").matches(":hover"), false,
"Button 1 should not be hovered after mousemove over label2");
is($("label1").mozMatchesSelector(":hover"), false,
is($("label1").matches(":hover"), false,
"Label 1 should not be hovered after mousemove over label2");
is($("button2").mozMatchesSelector(":hover"), true,
is($("button2").matches(":hover"), true,
"Button 2 should be hovered after mousemove over label2");
is($("label2").mozMatchesSelector(":hover"), true,
is($("label2").matches(":hover"), true,
"Label 2 should be hovered after mousemove over label2");
SimpleTest.finish();
}

View File

@ -85,7 +85,7 @@ skip-if = buildapp == 'mulet'
[test_exposeInDerived.xul]
[test_getweakmapkeys.xul]
[test_localstorage_with_nsEp.xul]
[test_mozMatchesSelector.xul]
[test_matches.xul]
[test_nodelists.xul]
[test_paris_weakmap_keys.xul]
[test_precisegc.xul]

View File

@ -13,7 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=533596
<!-- test results are displayed in the html:body -->
<body xmlns="http://www.w3.org/1999/xhtml">
<iframe src="http://example.org/tests/js/xpconnect/tests/mochitest/file_mozMatchesSelector.html"
<iframe src="http://example.org/tests/js/xpconnect/tests/mochitest/file_matches.html"
onload="runTest(this)">
</iframe>
</body>
@ -26,22 +26,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=533596
var doc = ifr.contentDocument;
var docElem = doc.documentElement;
var res = doc.createElement('div').mozMatchesSelector('div');
is(res, true, "mozMatchesSelector call through xray, regular case");
var res = doc.createElement('div').matches('div');
is(res, true, "matches call through xray, regular case");
res = docElem.mozMatchesSelector.call(
res = docElem.matches.call(
doc.createElement('div'), 'div');
is(res, true, "mozMatchesSelector call through xray, with .call");
is(res, true, "matches call through xray, with .call");
var sb = new Components.utils.Sandbox(ifr.contentWindow);
sb.doc = doc;
var str = "doc.documentElement.mozMatchesSelector.call(doc.createElement( 'div' ),'div')";
var str = "doc.documentElement.matches.call(doc.createElement( 'div' ),'div')";
res = Components.utils.evalInSandbox(str, sb);
is(res, true, "mozMatchesSelector call through xray (same origin), with .call");
is(res, true, "matches call through xray (same origin), with .call");
docElem.mozMatchesSelector = function(){return false};
res = docElem.mozMatchesSelector.call(doc.createElement( 'div' ),'div');
is(res, false, "shadowing mozMatchesSelector with an expando on the xray wrapper");
docElem.matches = function(){return false};
res = docElem.matches.call(doc.createElement( 'div' ),'div');
is(res, false, "shadowing matches with an expando on the xray wrapper");
SimpleTest.finish();
}

View File

@ -31,7 +31,7 @@ support-files =
file_evalInSandbox.html
file_exnstack.html
file_expandosharing.html
file_mozMatchesSelector.html
file_matches.html
file_nodelists.html
file_wrappers-2.html
inner.html

View File

@ -43,7 +43,7 @@ function testLockEnabled() {
is(window.getComputedStyle(button).color, defaultColor,
"color is default color before locking on");
is(button.mozMatchesSelector(":disabled"), false,
is(button.matches(":disabled"), false,
"doesn't match selector at start");
/* lock */
@ -55,7 +55,7 @@ function testLockEnabled() {
is(window.getComputedStyle(button).color, disabledColor,
":disabled style applied after adding lock");
is(button.mozMatchesSelector(":disabled"), true,
is(button.matches(":disabled"), true,
"matches selector after adding lock");
/* change state to disabled */
@ -64,7 +64,7 @@ function testLockEnabled() {
is(window.getComputedStyle(button).color, disabledColor,
":disabled style still applied after really disabling");
is(button.mozMatchesSelector(":disabled"), true,
is(button.matches(":disabled"), true,
"matches selector after adding lock");
/* remove lock */
@ -76,7 +76,7 @@ function testLockEnabled() {
is(window.getComputedStyle(button).color, disabledColor,
":disabled style still applied after removing lock");
is(button.mozMatchesSelector(":disabled"), true,
is(button.matches(":disabled"), true,
"matches selector after removing lock");
/* change state to enabled */
@ -85,7 +85,7 @@ function testLockEnabled() {
is(window.getComputedStyle(button).color, defaultColor,
"back to default style after un-disabling");
is(button.mozMatchesSelector(":disabled"), false,
is(button.matches(":disabled"), false,
"doesn't match selector after enabling");
}
@ -102,7 +102,7 @@ function testLockDisabled() {
is(window.getComputedStyle(button).color, disabledColor,
"color is :disabled color before locking");
is(button.mozMatchesSelector(":disabled"), true,
is(button.matches(":disabled"), true,
"matches selector before locking");
/* lock */
@ -114,7 +114,7 @@ function testLockDisabled() {
is(window.getComputedStyle(button).color, disabledColor,
":disabled style still applied after adding on lock");
is(button.mozMatchesSelector(":disabled"), true,
is(button.matches(":disabled"), true,
"matches selector after locking");
/* change state to enabled */
@ -123,7 +123,7 @@ function testLockDisabled() {
is(window.getComputedStyle(button).color, disabledColor,
":disabled style applied after enabling");
is(button.mozMatchesSelector(":disabled"), true,
is(button.matches(":disabled"), true,
"matches selector after enabling with lock on");
/* remove lock */
@ -135,7 +135,7 @@ function testLockDisabled() {
is(window.getComputedStyle(button).color, defaultColor,
"default style applied after removing lock");
is(button.mozMatchesSelector(":disabled"), false,
is(button.matches(":disabled"), false,
"doesn't match selector after unlocking");
/* change state to disabled */
@ -144,7 +144,7 @@ function testLockDisabled() {
is(window.getComputedStyle(button).color, disabledColor,
":disabled style applied after disabling after unlocking");
is(button.mozMatchesSelector(":disabled"), true,
is(button.matches(":disabled"), true,
"matches selector again after disabling");
}
@ -223,7 +223,7 @@ function testMultiple() {
is(window.getComputedStyle(div).getPropertyValue(style.property),
style.value, "style for pseudo-class is applied after locking");
is(div.mozMatchesSelector(pseudo), true,
is(div.matches(pseudo), true,
"matches selector after locking");
}
@ -236,7 +236,7 @@ function testMultiple() {
is(window.getComputedStyle(div).getPropertyValue(style.property),
style.defaultValue, "style is back to default after clearing");
is(div.mozMatchesSelector(pseudo), false,
is(div.matches(pseudo), false,
"doesn't match selector after unlocking");
}
}

View File

@ -5,7 +5,7 @@
it should be affected by :-moz-ui-invalid pseudo-class. -->
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i').checked = false;
if (!document.getElementById('i').mozMatchesSelector(':-moz-ui-invalid')) {
if (!document.getElementById('i').matches(':-moz-ui-invalid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -4,7 +4,7 @@
and its checkedness hasn't changed,
it should not be affected by :-moz-ui-invalid pseudo-class. -->
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="if (document.getElementById('i').mozMatchesSelector(':-moz-ui-invalid')) {
<body onload="if (document.getElementById('i').matches(':-moz-ui-invalid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -5,8 +5,8 @@
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i1').checked = false;
document.getElementById('i1').setCustomValidity('foo');
if (!document.getElementById('i1').mozMatchesSelector(':-moz-ui-invalid') ||
document.getElementById('i2').mozMatchesSelector(':-moz-ui-invalid')) {
if (!document.getElementById('i1').matches(':-moz-ui-invalid') ||
document.getElementById('i2').matches(':-moz-ui-invalid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -4,8 +4,8 @@
group, all radio should not suffer from being missing. -->
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i1').checked = true;
if (document.getElementById('i1').mozMatchesSelector(':-moz-ui-invalid') ||
document.getElementById('i2').mozMatchesSelector(':-moz-ui-invalid')) {
if (document.getElementById('i1').matches(':-moz-ui-invalid') ||
document.getElementById('i2').matches(':-moz-ui-invalid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -5,8 +5,8 @@
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i1').checked = true;
document.getElementById('i1').required = false;
if (document.getElementById('i1').mozMatchesSelector(':-moz-ui-invalid') ||
document.getElementById('i2').mozMatchesSelector(':-moz-ui-invalid')) {
if (document.getElementById('i1').matches(':-moz-ui-invalid') ||
document.getElementById('i2').matches(':-moz-ui-invalid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -2,7 +2,7 @@
<html class="reftest-wait">
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i').checked = true;
if (document.getElementById('i').mozMatchesSelector(':-moz-ui-invalid')) {
if (document.getElementById('i').matches(':-moz-ui-invalid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -2,7 +2,7 @@
<html class="reftest-wait">
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i').checked = false;
if (!document.getElementById('i').mozMatchesSelector(':-moz-ui-invalid')) {
if (!document.getElementById('i').matches(':-moz-ui-invalid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -5,7 +5,7 @@
it should be affected by :-moz-ui-invalid pseudo-class. -->
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i').checked = false;
if (!document.getElementById('i').mozMatchesSelector(':-moz-ui-invalid')) {
if (!document.getElementById('i').matches(':-moz-ui-invalid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -4,7 +4,7 @@
and its checkedness hasn't changed,
it should not be affected by :-moz-ui-invalid pseudo-class. -->
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="if (document.getElementById('i').mozMatchesSelector(':-moz-ui-invalid')) {
<body onload="if (document.getElementById('i').matches(':-moz-ui-invalid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -5,8 +5,8 @@
pseudo-class. -->
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i1').checked = false;
if (!document.getElementById('i1').mozMatchesSelector(':-moz-ui-invalid') ||
!document.getElementById('i2').mozMatchesSelector(':-moz-ui-invalid')) {
if (!document.getElementById('i1').matches(':-moz-ui-invalid') ||
!document.getElementById('i2').matches(':-moz-ui-invalid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -4,7 +4,7 @@
it should be affected by :-moz-ui-valid pseudo-class. -->
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i').checked = false;
if (!document.getElementById('i').mozMatchesSelector(':-moz-ui-valid')) {
if (!document.getElementById('i').matches(':-moz-ui-valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -3,7 +3,7 @@
<!-- Test: if input is valid and its checkedness hasn't changed,
it should not be affected by :-moz-ui-valid pseudo-class. -->
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="if (document.getElementById('i').mozMatchesSelector(':-moz-ui-valid')) {
<body onload="if (document.getElementById('i').matches(':-moz-ui-valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -3,8 +3,8 @@
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i1').checked = false;
document.getElementById('i1').setCustomValidity('foo');
if (document.getElementById('i1').mozMatchesSelector(':-moz-ui-valid') ||
!document.getElementById('i2').mozMatchesSelector(':-moz-ui-valid')) {
if (document.getElementById('i1').matches(':-moz-ui-valid') ||
!document.getElementById('i2').matches(':-moz-ui-valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -2,8 +2,8 @@
<html class="reftest-wait">
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i1').checked = true;
if (!document.getElementById('i1').mozMatchesSelector(':-moz-ui-valid') ||
!document.getElementById('i2').mozMatchesSelector(':-moz-ui-valid')) {
if (!document.getElementById('i1').matches(':-moz-ui-valid') ||
!document.getElementById('i2').matches(':-moz-ui-valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -3,8 +3,8 @@
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i1').checked = true;
document.getElementById('i1').required = false;
if (!document.getElementById('i1').mozMatchesSelector(':-moz-ui-valid') ||
!document.getElementById('i2').mozMatchesSelector(':-moz-ui-valid')) {
if (!document.getElementById('i1').matches(':-moz-ui-valid') ||
!document.getElementById('i2').matches(':-moz-ui-valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -2,7 +2,7 @@
<html class="reftest-wait">
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i').checked = true;
if (!document.getElementById('i').mozMatchesSelector(':-moz-ui-valid')) {
if (!document.getElementById('i').matches(':-moz-ui-valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -2,7 +2,7 @@
<html class="reftest-wait">
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i').checked = false;
if (document.getElementById('i').mozMatchesSelector(':-moz-ui-valid')) {
if (document.getElementById('i').matches(':-moz-ui-valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -2,8 +2,8 @@
<html class="reftest-wait">
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i1').checked = false;
if (document.getElementById('i1').mozMatchesSelector(':-moz-ui-valid') ||
document.getElementById('i2').mozMatchesSelector(':-moz-ui-valid')) {
if (document.getElementById('i1').matches(':-moz-ui-valid') ||
document.getElementById('i2').matches(':-moz-ui-valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -4,7 +4,7 @@
it should be affected by :-moz-ui-valid pseudo-class. -->
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i').checked = false;
if (!document.getElementById('i').mozMatchesSelector(':-moz-ui-valid')) {
if (!document.getElementById('i').matches(':-moz-ui-valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -3,7 +3,7 @@
<!-- Test: if input is valid and its checkedness hasn't changed,
it should not be affected by :-moz-ui-valid pseudo-class. -->
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="if (document.getElementById('i').mozMatchesSelector(':-moz-ui-valid')) {
<body onload="if (document.getElementById('i').matches(':-moz-ui-valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -2,8 +2,8 @@
<html class="reftest-wait">
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i1').setCustomValidity('foo');
if (document.getElementById('i1').mozMatchesSelector(':valid') ||
!document.getElementById('i2').mozMatchesSelector(':valid')) {
if (document.getElementById('i1').matches(':valid') ||
!document.getElementById('i2').matches(':valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -2,8 +2,8 @@
<html class="reftest-wait">
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i1').checked = true;
if (!document.getElementById('i1').mozMatchesSelector(':valid') ||
!document.getElementById('i2').mozMatchesSelector(':valid')) {
if (!document.getElementById('i1').matches(':valid') ||
!document.getElementById('i2').matches(':valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -2,8 +2,8 @@
<html class="reftest-wait">
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="document.getElementById('i1').required = false;
if (!document.getElementById('i1').mozMatchesSelector(':valid') ||
!document.getElementById('i2').mozMatchesSelector(':valid')) {
if (!document.getElementById('i1').matches(':valid') ||
!document.getElementById('i2').matches(':valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html class="reftest-wait">
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="if (!document.getElementById('i').mozMatchesSelector(':valid')) {
<body onload="if (!document.getElementById('i').matches(':valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html class="reftest-wait">
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="if (document.getElementById('i').mozMatchesSelector(':valid')) {
<body onload="if (document.getElementById('i').matches(':valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -1,8 +1,8 @@
<!DOCTYPE html>
<html class="reftest-wait">
<link rel='stylesheet' type='text/css' href='style.css'>
<body onload="if (document.getElementById('i1').mozMatchesSelector(':valid') ||
document.getElementById('i2').mozMatchesSelector(':valid')) {
<body onload="if (document.getElementById('i1').matches(':valid') ||
document.getElementById('i2').matches(':valid')) {
document.body.textContent='FAIL';
} else {
document.body.textContent='SUCCESS';

View File

@ -31,13 +31,13 @@ is(emptyList.length, 0, "Unexpected empty list length");
is(document.querySelectorAll("div > ::after").length, 0,
"Pseudo-element matched something?");
is(document.body.mozMatchesSelector("::first-line"), false,
is(document.body.matches("::first-line"), false,
"body shouldn't match ::first-line");
is(document.body.mozMatchesSelector("::first-line, body"), true,
is(document.body.matches("::first-line, body"), true,
"body should match 'body'");
is(document.body.mozMatchesSelector("::first-line, body, ::first-letter"), true,
is(document.body.matches("::first-line, body, ::first-letter"), true,
"body should match 'body' here too");
</script>

View File

@ -236,7 +236,7 @@ function run() {
{
try {
// Test that it is also unparseable when followed by EOF.
ifdoc.body.mozMatchesSelector(selector);
ifdoc.body.matches(selector);
ok(false, "selector '" + selector + "' plus EOF is parse error");
} catch(ex) {
is(ex.name, "SyntaxError",
@ -251,7 +251,7 @@ function run() {
var threw = false;
try {
// Test that a selector is parseable when followed by EOF.
ifdoc.body.mozMatchesSelector(selector);
ifdoc.body.matches(selector);
} catch(ex) {
threw = true;
}
@ -924,7 +924,7 @@ function run() {
test_parseable(":-moz-locale-dir(rtl)");
test_parseable(":-moz-locale-dir(rTl)");
test_parseable(":-moz-locale-dir(LTR)");
if (document.body.mozMatchesSelector(":-moz-locale-dir(ltr)")) {
if (document.body.matches(":-moz-locale-dir(ltr)")) {
test_selector_in_html("a:-moz-locale-dir(LTr)", single_a,
set_single, empty_set);
test_selector_in_html("a:-moz-locale-dir(ltR)", single_a,
@ -958,7 +958,7 @@ function run() {
test_parseable(":-moz-dir(rtl)");
test_parseable(":-moz-dir(rTl)");
test_parseable(":-moz-dir(LTR)");
if (document.body.mozMatchesSelector(":-moz-dir(ltr)")) {
if (document.body.matches(":-moz-dir(ltr)")) {
test_selector_in_html("a:-moz-dir(LTr)", single_a,
set_single, empty_set);
test_selector_in_html("a:-moz-dir(ltR)", single_a,

View File

@ -77,14 +77,14 @@ function run_tests()
is(subwin.getComputedStyle(visitedlink, "").color, "rgb(0, 0, 255)",
"getComputedStyle on visited link should report color is blue");
// Test mozMatchesSelector.
is(unvisitedlink.mozMatchesSelector(":link"), true,
// Test matches.
is(unvisitedlink.matches(":link"), true,
"unvisited link matches :link");
is(visitedlink.mozMatchesSelector(":link"), true,
is(visitedlink.matches(":link"), true,
"visited link matches :link");
is(unvisitedlink.mozMatchesSelector(":visited"), false,
is(unvisitedlink.matches(":visited"), false,
"unvisited link does not match :visited");
is(visitedlink.mozMatchesSelector(":visited"), false,
is(visitedlink.matches(":visited"), false,
"visited link does not match :visited");
SimpleTest.finish();

View File

@ -447,8 +447,8 @@ var SelectionHandler = {
if (selection.focusNode != focusNode) {
let nextContainer = (selection.focusNode instanceof Text) ?
selection.focusNode.parentNode : selection.focusNode;
if (nextContainer.mozMatchesSelector &&
nextContainer.mozMatchesSelector(PHONE_NUMBER_CONTAINERS)) {
if (nextContainer.matches &&
nextContainer.matches(PHONE_NUMBER_CONTAINERS)) {
// Backout the undesired selection extend, and we're done.
selection.collapse(selection.anchorNode, selection.anchorOffset);
selection.extend(focusNode, focusOffset);

View File

@ -2094,8 +2094,8 @@ var NativeWindow = {
SelectorContext: function(aSelector) {
return {
matches: function(aElt) {
if (aElt.mozMatchesSelector)
return aElt.mozMatchesSelector(aSelector);
if (aElt.matches)
return aElt.matches(aSelector);
return false;
}
};
@ -5120,7 +5120,7 @@ var BrowserEventHandler = {
if (checkElem) {
if ((elem.scrollTopMax > 0 || elem.scrollLeftMax > 0) &&
(this._hasScrollableOverflow(elem) ||
elem.mozMatchesSelector("textarea")) ||
elem.matches("textarea")) ||
(elem instanceof HTMLInputElement && elem.mozIsTextField(false)) ||
(elem instanceof HTMLSelectElement && (elem.size > 1 || elem.multiple))) {
scrollable = true;
@ -5255,14 +5255,14 @@ const ElementTouchHelper = {
let threshold = Number.POSITIVE_INFINITY;
for (let i = 0; i < nodes.length; i++) {
let current = nodes[i];
if (!current.mozMatchesSelector || !this.isElementClickable(current, unclickableCache, true))
if (!current.matches || !this.isElementClickable(current, unclickableCache, true))
continue;
let rect = current.getBoundingClientRect();
let distance = this._computeDistanceFromRect(aX, aY, rect);
// increase a little bit the weight for already visited items
if (current && current.mozMatchesSelector("*:visited"))
if (current && current.matches("*:visited"))
distance *= (this.weight.visited / 100);
if (distance < threshold) {
@ -5286,7 +5286,7 @@ const ElementTouchHelper = {
continue;
if (this._hasMouseListener(elem))
return true;
if (elem.mozMatchesSelector && elem.mozMatchesSelector(selector))
if (elem.matches && elem.matches(selector))
return true;
if (elem instanceof HTMLLabelElement && elem.control != null)
return true;

View File

@ -876,7 +876,7 @@
_showControlsTimeout : 0,
SHOW_CONTROLS_TIMEOUT_MS: 500,
_showControlsFn : function () {
if (Utils.video.mozMatchesSelector("video:hover")) {
if (Utils.video.matches("video:hover")) {
Utils.startFadeIn(Utils.controlBar, false);
Utils._showControlsTimeout = 0;
Utils._controlsHiddenByTimeout = false;

View File

@ -105,7 +105,7 @@ function test2() {
box.style.backgroundColor = "green";
doc.body.appendChild(box);
ok(!box.mozMatchesSelector(":hover"), "Box shouldn't be hovered (since the mouse isn't over it and since it's in a non-clickthrough iframe in a background window)");
ok(!box.matches(":hover"), "Box shouldn't be hovered (since the mouse isn't over it and since it's in a non-clickthrough iframe in a background window)");
// A function to waitForFocus and then wait for synthetic mouse
// events to happen. Note that those happen off the refresh driver,
@ -134,25 +134,25 @@ function test2() {
// Move the mouse over the box.
moveMouseTo(100, 150, function () {
ok(!box.mozMatchesSelector(":hover"), "Box shouldn't be hovered (since it's in a non-clickthrough iframe in a background window)");
ok(!box.matches(":hover"), "Box shouldn't be hovered (since it's in a non-clickthrough iframe in a background window)");
// Activate the left window.
changeFocusAndAwaitSyntheticMouse(function () {
ok(gIFrame.mozMatchesSelector(":hover"), "iframe should be hovered");
ok(box.mozMatchesSelector(":hover"), "Box should be hovered");
ok(gIFrame.matches(":hover"), "iframe should be hovered");
ok(box.matches(":hover"), "Box should be hovered");
// De-activate the window (by activating the right window).
changeFocusAndAwaitSyntheticMouse(function () {
ok(!gIFrame.mozMatchesSelector(":hover"), "iframe shouldn't be hovered");
ok(!box.mozMatchesSelector(":hover"), "Box shouldn't be hovered");
ok(!gIFrame.matches(":hover"), "iframe shouldn't be hovered");
ok(!box.matches(":hover"), "Box shouldn't be hovered");
// Re-activate it.
changeFocusAndAwaitSyntheticMouse(function () {
ok(gIFrame.mozMatchesSelector(":hover"), "iframe should be hovered");
ok(box.mozMatchesSelector(":hover"), "Box should be hovered");
ok(gIFrame.matches(":hover"), "iframe should be hovered");
ok(box.matches(":hover"), "Box should be hovered");
// Unhover box and iframe by moving the mouse outside the window.
moveMouseTo(0, 150, function () {
const isOSXSnowLeopard = navigator.userAgent.indexOf("Mac OS X 10.6") != -1;
if (!isOSXSnowLeopard) {
ok(!gIFrame.mozMatchesSelector(":hover"), "iframe shouldn't be hovered");
ok(!box.mozMatchesSelector(":hover"), "box shouldn't be hovered");
ok(!gIFrame.matches(":hover"), "iframe shouldn't be hovered");
ok(!box.matches(":hover"), "box shouldn't be hovered");
}
finalize();
});