dom/imptests/editing/selecttest/test_selectAllChildren.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 <!doctype html>
     2 <title>Selection.selectAllChildren tests</title>
     3 <div id=log></div>
     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";
    10 testRanges.unshift("[]");
    12 for (var i = 0; i < testRanges.length; i++) {
    13 	var endpoints = eval(testRanges[i]);
    15 	for (var j = 0; j < testNodes.length; j++) {
    16 		var node = eval(testNodes[j]);
    18 		test(function() {
    19 			setSelectionForwards(endpoints);
    20 			var originalRange = getSelection().rangeCount
    21 				? getSelection().getRangeAt(0)
    22 				: null;
    24 			if (node.nodeType == Node.DOCUMENT_TYPE_NODE) {
    25 				assert_throws("INVALID_NODE_TYPE_ERR", function() {
    26 					selection.selectAllChildren(node);
    27 				}, "selectAllChildren() on a DocumentType must throw InvalidNodeTypeError");
    28 				return;
    29 			}
    31 			selection.selectAllChildren(node);
    32 			// This implicitly tests that the selection is forwards, by using
    33 			// anchorOffset/focusOffset instead of getRangeAt.
    34 			assert_equals(selection.rangeCount, 1,
    35 				"After selectAllChildren, rangeCount must be 1");
    36 			assert_equals(selection.anchorNode, node,
    37 				"After selectAllChildren, anchorNode must be the given node");
    38 			assert_equals(selection.anchorOffset, 0,
    39 				"After selectAllChildren, anchorOffset must be 0");
    40 			assert_equals(selection.focusNode, node,
    41 				"After selectAllChildren, focusNode must be the given node");
    42 			assert_equals(selection.focusOffset, node.childNodes.length,
    43 				"After selectAllChildren, focusOffset must be the given node's number of children");
    44 			if (originalRange) {
    45 				assert_not_equals(getSelection().getRangeAt(0), originalRange,
    46 					"selectAllChildren must replace any existing range, not mutate it");
    47 			}
    48 		}, "Range " + i + " " + testRanges[i] + ", node " + j + " " + testNodes[j]);
    49 	}
    50 }
    52 testDiv.style.display = "none";
    53 </script>

mercurial