<!doctype html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="../../assert_selection.js"></script>
<div id="log"></div>
<script>
test(() => {
assert_selection(
'<div>^foo|</div>',
selection => {
selection.setBaseAndExtent(null, 0, null, 0);
},
'<div>foo</div>',
'Setting both null clears selection');
assert_selection(
'<div>^foo|</div>',
selection => {
selection.setBaseAndExtent(null, 1, null, 2);
},
'<div>foo</div>',
'Setting both null clears selection');
assert_selection(
'<div>^foo|</div>',
selection => selection.setBaseAndExtent(null, 1, selection.document.querySelector('div'), 1),
'<div>foo</div>',
'Setting only base null clears selection');
assert_selection(
'<div>foo</div>',
selection => selection.setBaseAndExtent(selection.document.querySelector('div'), 0, null, 2),
'<div>|foo</div>',
'Setting base non-null and extent null behaves as collapse.' +
'This is under discussion: https://github.com/w3c/selection-api/issues/72');
}, 'setBaseAndExtent with null.');
</script>