summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/Selection/script-tests/collapseToX-empty-selection.js
blob: c1fd73cd455673c99409d483bab382fdb4be8c57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
description("Test that collapseToStart() and collapseToEnd() throw INVALID_STATE_ERR if no selection is made.");

var sel = window.getSelection();
var textNode = document.createTextNode("abcdef");
document.body.appendChild(textNode);

shouldThrow("sel.collapseToStart()", "'Error: INVALID_STATE_ERR: DOM Exception 11'");
shouldThrow("sel.collapseToEnd()", "'Error: INVALID_STATE_ERR: DOM Exception 11'");

sel.selectAllChildren(textNode);

shouldBe("sel.collapseToStart()", "undefined");
shouldBe("sel.collapseToEnd()", "undefined");

document.body.removeChild(textNode);

var successfullyParsed = true;