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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/selection/removeRange.html

Issue 2710593009: Selection API: add removeRange(). (Closed)
Patch Set: rebase Created 3 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title>Selection.removeRange tests</title>
3 <body>
4 <script src="/resources/testharness.js"></script>
5 <script src="/resources/testharnessreport.js"></script>
6 <script src="common.js"></script>
7 <script>
8 "use strict";
9
10 testRanges.forEach(function(rangeData, index) {
11 var endpoints = eval(rangeData);
12 if (!isSelectableNode(endpoints[0]) || !isSelectableNode(endpoints[2]))
13 return;
14 test(function() {
15 var selection = getSelection();
16 selection.removeAllRanges();
17 var range = ownerDocument(endpoints[0]).createRange();
18 range.setStart(endpoints[0], endpoints[1]);
19 range.setEnd(endpoints[2], endpoints[3]);
20
21 selection.addRange(range);
22 assert_equals(selection.rangeCount, 1);
23 selection.removeRange(range);
24 assert_equals(selection.rangeCount, 0, 'Range should be correctly remove d.');
25 assert_equals(selection.anchorNode, null);
26 assert_equals(selection.focusNode, null);
27
28 selection.addRange(range);
29 assert_equals(selection.rangeCount, 1);
30 var equivalentRange = ownerDocument(endpoints[0]).createRange();
31 equivalentRange.setStart(endpoints[0], endpoints[1]);
32 equivalentRange.setEnd(endpoints[2], endpoints[3]);
33 selection.removeRange(equivalentRange);
34 assert_equals(selection.rangeCount, 1, 'Equivalent Range should not remo ve the registered Range.');
35
36 }, 'removeRange() with Range ' + index);
37 });
38
39 test(function() {
40 var selection = getSelection();
41 assert_throws(new TypeError(), function() { selection.removeRange(null); });
42 assert_throws(new TypeError(), function() { selection.removeRange(selection) ; });
43 }, 'removeRange() argument is non-optional Range');
44 </script>
45 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698