Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: LayoutTests/editing/selection/selection-invalid-offset.html

Issue 225303002: Let Selection.collapse remember a raw Position instead of a canonicalized one. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix setSelectedRange arguments Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/editing/selection/selection-invalid-offset.html
diff --git a/LayoutTests/editing/selection/selection-invalid-offset.html b/LayoutTests/editing/selection/selection-invalid-offset.html
index 8393b16e3187df2c741c47b7e2785a8e0ed823ab..d0f8bc64f92eaf9a7355937aea5ada00ac2559ed 100644
--- a/LayoutTests/editing/selection/selection-invalid-offset.html
+++ b/LayoutTests/editing/selection/selection-invalid-offset.html
@@ -1,37 +1,29 @@
<body>
-You should see six OKs below (and not hang): <br>
+You should see 7 OKs below (and not hang): <br>
<script>
if (window.testRunner)
testRunner.dumpAsText();
var body = document.body;
var selection = window.getSelection();
-try {
-selection.collapse(body, -1);
-} catch (e) {document.write(((e.code==DOMException.INDEX_SIZE_ERR) ? "OK" : "FAIL")+"<br>"); }
-try {
-selection.setBaseAndExtent(body, -1, body, 0);
-} catch (e) {document.write(((e.code==DOMException.INDEX_SIZE_ERR) ? "OK" : "FAIL")+"<br>"); }
+function shouldThrowIndexSizeErrorException(script)
+{
+ try {
+ eval(script);
+ } catch (e) {
+ document.write(((e.code == DOMException.INDEX_SIZE_ERR) ? "OK" : "FAIL") + "<br>");
+ }
+}
-try {
-selection.setBaseAndExtent(body, 0, body, -1);
-} catch (e) {document.write(((e.code==DOMException.INDEX_SIZE_ERR) ? "OK" : "FAIL")+"<br>"); }
-
-try {
-selection.collapse(body, -1);
-} catch (e) {document.write(((e.code==DOMException.INDEX_SIZE_ERR) ? "OK" : "FAIL")+"<br>"); }
-
-try {
-selection.getRangeAt(-1);
-} catch (e) {document.write(((e.code==DOMException.INDEX_SIZE_ERR) ? "OK" : "FAIL")+"<br>"); }
-
-try {
-selection.getRangeAt(10000);
-} catch (e) {document.write(((e.code==DOMException.INDEX_SIZE_ERR) ? "OK" : "FAIL")+"<br>"); }
+shouldThrowIndexSizeErrorException("selection.collapse(body, -1);");
+shouldThrowIndexSizeErrorException("selection.setBaseAndExtent(body, -1, body, 0);");
+shouldThrowIndexSizeErrorException("selection.setBaseAndExtent(body, 0, body, -1);");
+shouldThrowIndexSizeErrorException("selection.collapse(body, -1);");
+shouldThrowIndexSizeErrorException("selection.getRangeAt(-1);");
+shouldThrowIndexSizeErrorException("selection.getRangeAt(10000);");
+shouldThrowIndexSizeErrorException("selection.collapse(body, 10000);");
// these should throw as well but don't at the moment. Just checking they don't crash.
-selection.collapse(body, 10000);
selection.setBaseAndExtent(body, 1000, body, 0);
selection.setBaseAndExtent(body, 0, body, 10000);
-selection.collapse(body, 10000);
</script>

Powered by Google App Engine
This is Rietveld 408576698