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

Unified Diff: LayoutTests/editing/selection/selectAllChildren.html

Issue 817693002: Handle null argument for Selection.selectAllChildren() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | LayoutTests/editing/selection/selectAllChildren-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/editing/selection/selectAllChildren.html
diff --git a/LayoutTests/editing/selection/selectAllChildren.html b/LayoutTests/editing/selection/selectAllChildren.html
index d78066bc108e3cb9584588194a4977661aa43427..3fb94f40d062a746863aa4dc572374aa999375e3 100644
--- a/LayoutTests/editing/selection/selectAllChildren.html
+++ b/LayoutTests/editing/selection/selectAllChildren.html
@@ -1,4 +1,7 @@
<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+</head>
<body>
<div id="test"><span id="span1">foo</span><span>bar</span></div>
<div id="console"></div>
@@ -13,20 +16,8 @@ function log(str) {
document.getElementById("console").appendChild(li);
}
-function shouldBe(expr, expected) {
- var actual = eval(expr);
- if (actual != expected)
- log("Failure: " + expr + " should be " + expected + ", was " + actual + ".");
- else
- log("Success: " + expr + " is " + expected + ".");
-}
-
-if (window.testRunner)
- testRunner.dumpAsText();
-
var r = document.createRange();
-
// select span1
r.setStart(test, 0);
r.setEnd(test, 1);
@@ -34,19 +25,23 @@ s.addRange(r);
// replace the selection with span1's text node children
s.selectAllChildren(span1.firstChild);
-shouldBe('s.anchorNode', span1.firstChild);
-shouldBe('s.anchorOffset', 0);
-shouldBe('s.focusNode', span1.firstChild);
-shouldBe('s.focusOffset', 0); // Strange, but matches Firefox
+shouldBe('s.anchorNode', 'span1.firstChild');
+shouldBe('s.anchorOffset', '0');
+shouldBe('s.focusNode', 'span1.firstChild');
+shouldBe('s.focusOffset', '0'); // Strange, but matches Firefox
// replace the selection with span1's children
s.selectAllChildren(span1);
-shouldBe('window.getSelection()', 'foo');
+shouldBe('window.getSelection().toString()', '"foo"');
// replace the selection with test's children
s.selectAllChildren(test);
-shouldBe('window.getSelection()', 'foobar');
+shouldBe('window.getSelection().toString()', '"foobar"');
+// call with types other than Node
+shouldNotThrow('s.selectAllChildren(null)');
+shouldNotThrow('s.selectAllChildren(window)');
+shouldNotThrow('s.selectAllChildren("")');
</script>
</body>
</html>
« no previous file with comments | « no previous file | LayoutTests/editing/selection/selectAllChildren-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698