<!doctype html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script>
if (window.testRunner)
	testRunner.dumpAsText();
</script>
</head>
<body>
	<sibling></sibling>
	<target id="theTarget" webkit="fast"></target>
</body>
<script>
description('This test makes sure that :scope works correctly with the closest() API.');

var theTarget = document.getElementById('theTarget');
var body = document.body;

shouldBe('theTarget.closest(":scope")', 'theTarget');
shouldBe('theTarget.closest(":not(:scope)")', 'body');

shouldBe('theTarget.closest("body :scope")', 'theTarget');
shouldBe('theTarget.closest("body > :scope")', 'theTarget');
shouldBeNull('theTarget.closest("body:scope")');

shouldBe('theTarget.closest("sibling + :scope")', 'theTarget');
shouldBe('theTarget.closest("sibling ~ :scope")', 'theTarget');

shouldBe('theTarget.closest("#theTarget:scope")', 'theTarget');
shouldBe('theTarget.closest(":scope#theTarget")', 'theTarget');

shouldBe('theTarget.closest("[webkit]:scope#theTarget")', 'theTarget');
shouldBeNull('theTarget.closest(":not([webkit=fast]):scope#theTarget")');

shouldBeNull('theTarget.closest(":scope target")');
shouldBeNull('theTarget.closest(":scope > target")');
shouldBeNull('theTarget.closest(":scope + target")');
shouldBeNull('theTarget.closest(":scope ~ target")');

shouldBeNull('theTarget.closest(":scope *")');
shouldBeNull('theTarget.closest(":scope > *")');
shouldBeNull('theTarget.closest(":scope + *")');
shouldBeNull('theTarget.closest(":scope ~ *")');
</script>
<script src="../../resources/js-test-post.js"></script>
</html>
