1 <p>This tests for HIERARCHY_REQUEST_ERRs when calling Range::surroundContents.
</p>
2 <div id=
"select" style=
"border: 1px solid blue;">Hello world.
</div>
3 <div id=
"insert" style=
"border: 1px solid red;"></div>
7 var li
= document
.createElement("li");
8 li
.appendChild(document
.createTextNode(str
));
9 var console
= document
.getElementById("console");
10 console
.appendChild(li
);
13 var range
= document
.createRange();
14 var select
= document
.getElementById("select");
15 var text
= select
.firstChild
;
17 var insert
= document
.getElementById("insert");
19 range
.setStart(text
, 0);
20 range
.setEnd(text
, text
.length
);
23 range
.surroundContents(select
);
25 var error
= "HierarchyRequestError: Failed to execute 'surroundContents' on 'Range': The node provided contains the insertion point; it may not be inserted into itself.";
27 log ("Failure, expected: " + error
+ "Was " + e
);
31 range
.surroundContents(insert
);
33 log ("Failure: " + error
);