Skip to content

Commit

Permalink
Auto merge of #14080 - nox:scope, r=SimonSapin
Browse files Browse the repository at this point in the history
Properly expect a syntax error with :scope selectors in Element.closest

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14080)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Nov 6, 2016
2 parents c62ce53 + 1037fec commit dbf43c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
12 changes: 0 additions & 12 deletions tests/wpt/metadata/dom/nodes/Element-closest.html.ini
Expand Up @@ -4,15 +4,3 @@
bug: https://github.com/servo/servo/issues/10781
expected: FAIL

[Element.closest with context node 'test4' and selector ':scope']
expected: FAIL

[Element.closest with context node 'test4' and selector 'select > :scope']
expected: FAIL

[Element.closest with context node 'test4' and selector 'div > :scope']
expected: FAIL

[Element.closest with context node 'test4' and selector ':has(> :scope)']
expected: FAIL

18 changes: 14 additions & 4 deletions tests/wpt/web-platform-tests/dom/nodes/Element-closest.html
Expand Up @@ -56,10 +56,11 @@
do_test(":first-child" , "test12", "test3");
do_test(":invalid" , "test11", "test2");

do_test(":scope" , "test4", "test4");
do_test("select > :scope" , "test4", "test4");
do_test("div > :scope" , "test4", "");
do_test(":has(> :scope)" , "test4", "test3");
do_scope_test(":scope" , "test4");
do_scope_test("select > :scope" , "test4");
do_scope_test("div > :scope" , "test4");
do_scope_test(":has(> :scope)" , "test4");

function do_test(aSelector, aElementId, aTargetId) {
test(function() {
var el = document.getElementById(aElementId).closest(aSelector);
Expand All @@ -70,4 +71,13 @@
}
}, "Element.closest with context node '" + aElementId + "' and selector '" + aSelector + "'");
}

function do_scope_test(aSelector, aElementId) {
test(function() {
var el = document.getElementById(aElementId);
assert_throws("SYNTAX_ERR", function() {
el.closest(aSelector);
});
}, "Element.closest with context node '" + aElementId + "' and selector '" + aSelector + "' should throw");
}
</script>

0 comments on commit dbf43c9

Please sign in to comment.