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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/selection/common.js

Issue 2698413002: selection: Align collapse-NN.html and extend-NN.html to the latest draft. (Closed)
Patch Set: Created 3 years, 10 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
1 "use strict"; 1 "use strict";
2 // TODO: iframes, contenteditable/designMode 2 // TODO: iframes, contenteditable/designMode
3 3
4 // Everything is done in functions in this test harness, so we have to declare 4 // Everything is done in functions in this test harness, so we have to declare
5 // all the variables before use to make sure they can be reused. 5 // all the variables before use to make sure they can be reused.
6 var selection; 6 var selection;
7 var testDiv, paras, detachedDiv, detachedPara1, detachedPara2, 7 var testDiv, paras, detachedDiv, detachedPara1, detachedPara2,
8 foreignDoc, foreignPara1, foreignPara2, xmlDoc, xmlElement, 8 foreignDoc, foreignPara1, foreignPara2, xmlDoc, xmlElement,
9 detachedXmlElement, detachedTextNode, foreignTextNode, 9 detachedXmlElement, detachedTextNode, foreignTextNode,
10 detachedForeignTextNode, xmlTextNode, detachedXmlTextNode, 10 detachedForeignTextNode, xmlTextNode, detachedXmlTextNode,
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 * direction backwards. Uses extend, so it will throw in IE. Accepts an empty 951 * direction backwards. Uses extend, so it will throw in IE. Accepts an empty
952 * array for endpoints, in which case the selection will just be emptied. 952 * array for endpoints, in which case the selection will just be emptied.
953 */ 953 */
954 function setSelectionBackwards(endpoints) { 954 function setSelectionBackwards(endpoints) {
955 selection.removeAllRanges(); 955 selection.removeAllRanges();
956 if (endpoints.length) { 956 if (endpoints.length) {
957 selection.collapse(endpoints[2], endpoints[3]); 957 selection.collapse(endpoints[2], endpoints[3]);
958 selection.extend(endpoints[0], endpoints[1]); 958 selection.extend(endpoints[0], endpoints[1]);
959 } 959 }
960 } 960 }
961
962 /**
963 * Verify that the specified func doesn't change the selection.
964 * This function should be used in testharness tests.
965 */
966 function assertSelectionNoChange(func) {
967 var originalCount = getSelection().rangeCount;
968 var originalRange = originalCount == 0 ? null : selection.getRangeAt(0);
969
970 func();
971
972 assert_equals(selection.rangeCount, originalCount,
973 "The operation should not add Range");
974 if (originalCount < 1)
975 return;
976 assert_equals(selection.getRangeAt(0), originalRange,
977 "The operation should not replace a registered Range");
978 }
979
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698