Bug 1363961. Fix the order of arguments to FindInReadable in AttrHasSubstring. r=heycam

MozReview-Commit-ID: BAsd9bN4dtA
This commit is contained in:
Boris Zbarsky 2017-05-11 13:25:14 -04:00
parent 9669157cae
commit 3ec9d2495f
3 changed files with 50 additions and 5 deletions

View File

@ -388,9 +388,9 @@ fuzzy-if(Android&&isDebugBuild,229,45) == 315920-13b.html 315920-13-ref.html # b
== 315920-18b.html 315920-18-ref.html
== 315920-18c.html 315920-18-ref.html
== 315920-18d.html 315920-18-ref.html
fails-if(stylo) == 315920-18e.html 315920-18-ref.html
fails-if(stylo) == 315920-18f.html 315920-18-ref.html
fails-if(stylo) == 315920-18g.html 315920-18-ref.html
== 315920-18e.html 315920-18-ref.html
== 315920-18f.html 315920-18-ref.html
== 315920-18g.html 315920-18-ref.html
== 315920-18h.html 315920-18-ref.html
== 315920-18i.html 315920-18-ref.html
== 315920-19.html 315920-19-ref.html
@ -1457,7 +1457,7 @@ fuzzy-if(skiaContent,1,50) == 526463-1.html 526463-1-ref.html
fuzzy-if(Android,2,48) == 531200-1.html 531200-1-ref.html
== 531371-1.html 531371-1-ref.html
== 534526-1a.html 534526-1-ref.html
fails-if(stylo) == 534526-1b.html 534526-1-ref.html
== 534526-1b.html 534526-1-ref.html
== 534804-1.html 534804-1-ref.html
== 534808-1.html 534808-1-ref.html
== 534808-2.html 534808-2-ref.html

View File

@ -797,7 +797,7 @@ AttrHasSubstring(Implementor* aElement, nsIAtom* aNS, nsIAtom* aName,
auto match = [aStr](const nsAttrValue* aValue) {
nsAutoString str;
aValue->ToString(str);
return FindInReadable(str, nsDependentAtomString(aStr));
return FindInReadable(nsDependentAtomString(aStr), str);
};
return DoMatch(aElement, aNS, aName, match);
}

View File

@ -395,6 +395,51 @@ function run() {
test_balanced_unparseable("[attr*=]");
test_balanced_unparseable("[attr*=foo bar]");
// And now tests for correctness of matching of attr selectors.
var attrTestBody =
// Paragraphs 1-5
"<p attr></p> <p attr=''></p> <p attr='foo'></p> <p att></p> <p></p>" +
// Paragraphs 6-8
"<p attr='foo bar'></p> <p attr='foo-bar'></p> <p attr='foobar'></p>" +
// Paragraphs 9-10
"<p attr='foo bar baz'></p> <p attr='foo-bar-baz'></p>" +
// Paragraphs 11-12
"<p attr='foo-bar baz'></p> <p attr=' foo-bar '></p> " +
// Paragraph 13-15
"<p attr=' foo '></p> <p attr='fo'></p> <p attr='bar baz-foo'></p>";
test_selector_in_html(
"[attr]", attrTestBody,
pset([1,2,3,6,7,8,9,10,11,12,13,14,15]), pset([4,5]));
test_selector_in_html(
"[attr=foo]", attrTestBody,
pset([3]), pset([1,2,4,5,6,7,8,9,10,11,12,13,14,15]));
test_selector_in_html(
"[attr~=foo]", attrTestBody,
pset([3,6,9,13]), pset([1,2,4,5,7,8,10,11,12,14,15]));
test_selector_in_html(
"[attr~=bar]", attrTestBody,
pset([6,9,15]), pset([1,2,3,4,5,7,8,10,11,12,13,14]));
test_selector_in_html(
"[attr~=baz]", attrTestBody,
pset([9,11]), pset([1,2,3,4,5,6,7,8,10,12,13,14,15]));
test_selector_in_html(
"[attr|=foo]", attrTestBody,
pset([3,7,10,11]), pset([1,2,4,5,6,8,9,12,13,14,15]));
test_selector_in_html(
"[attr|='bar baz']", attrTestBody,
pset([15]), pset([1,2,3,4,5,6,7,8,9,10,11,12,13,14]));
test_selector_in_html(
"[attr$=foo]", attrTestBody,
pset([3,15]), pset([1,2,4,5,6,7,8,9,10,11,12,13,14]));
test_selector_in_html(
"[attr$=bar]", attrTestBody,
pset([6,7,8]), pset([1,2,3,4,5,9,10,11,12,13,14,15]));
test_selector_in_html(
"[attr^=foo]", attrTestBody,
pset([3,6,7,8,9,10,11]), pset([1,2,4,5,12,13,14,15]));
test_selector_in_html(
"[attr*=foo]", attrTestBody,
pset([3,6,7,8,9,10,11,12,13,15]), pset([1,2,4,5,14]));
// Bug 420814
test_selector_in_html(