From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../tests/selection/Document-open.html | 28 + testing/web-platform/tests/selection/META.yml | 3 + .../web-platform/tests/selection/addRange-00.html | 14 + .../web-platform/tests/selection/addRange-04.html | 14 + .../web-platform/tests/selection/addRange-08.html | 14 + .../web-platform/tests/selection/addRange-12.html | 14 + .../web-platform/tests/selection/addRange-16.html | 14 + .../web-platform/tests/selection/addRange-20.html | 14 + .../web-platform/tests/selection/addRange-24.html | 14 + .../web-platform/tests/selection/addRange-28.html | 14 + .../web-platform/tests/selection/addRange-32.html | 14 + .../web-platform/tests/selection/addRange-36.html | 14 + .../web-platform/tests/selection/addRange-40.html | 14 + .../web-platform/tests/selection/addRange-44.html | 14 + .../web-platform/tests/selection/addRange-48.html | 14 + .../web-platform/tests/selection/addRange-52.html | 14 + .../web-platform/tests/selection/addRange-56.html | 14 + testing/web-platform/tests/selection/addRange.htm | 29 + testing/web-platform/tests/selection/addRange.js | 205 ++++ .../tests/selection/addRange.tentative.html | 29 + .../selection/anonymous/details-ancestor.html | 40 + .../tests/selection/anonymous/details-mutate.html | 38 + .../tests/selection/bidi/modify.tentative.html | 60 ++ .../selection/caret/collapse-pre-linestart-1.html | 13 + .../selection/caret/collapse-pre-linestart-2.html | 14 + .../caret/collapse-pre-linestart-ref.html | 8 + .../tests/selection/caret/empty-elements.html | 25 + .../web-platform/tests/selection/collapse-00.html | 14 + .../web-platform/tests/selection/collapse-15.html | 14 + .../web-platform/tests/selection/collapse-30.html | 14 + .../web-platform/tests/selection/collapse-45.html | 14 + testing/web-platform/tests/selection/collapse.htm | 30 + testing/web-platform/tests/selection/collapse.js | 103 ++ .../tests/selection/collapseToStartEnd.html | 114 +++ testing/web-platform/tests/selection/common.js | 1002 ++++++++++++++++++++ .../contenteditable/cefalse-on-boundaries.html | 72 ++ .../tests/selection/contenteditable/collapse.html | 43 + .../initial-selection-on-focus.tentative.html | 473 +++++++++ .../contenteditable/modify.tentative.html | 60 ++ ...lection-with-middle-mouse-button.tentative.html | 213 +++++ ...ection-with-primary-mouse-button.tentative.html | 212 +++++ .../selection/crashtests/selection-clip-crash.html | 31 + .../crashtests/selection-modify-around-input.html | 24 + .../tests/selection/crashtests/table.html | 14 + .../tests/selection/deleteFromDocument.html | 97 ++ .../web-platform/tests/selection/dir-manual.html | 106 +++ .../drag-disabled-textarea-shadow-dom.html | 39 + .../web-platform/tests/selection/extend-00.html | 16 + .../web-platform/tests/selection/extend-20.html | 16 + .../web-platform/tests/selection/extend-40.html | 16 + .../tests/selection/extend-exception.html | 21 + testing/web-platform/tests/selection/extend.js | 161 ++++ .../web-platform/tests/selection/getRangeAt.html | 32 + .../web-platform/tests/selection/getSelection.html | 160 ++++ .../tests/selection/idlharness.window.js | 18 + .../web-platform/tests/selection/isCollapsed.html | 33 + ...xtend-word-trailing-inline-block.tentative.html | 23 + .../modify-line-flex-column.tentative.html | 47 + .../selection/modify-line-flex-row.tentative.html | 50 + .../modify-line-grid-basic.tentative.html | 47 + .../tests/selection/modify.tentative.html | 90 ++ .../tests/selection/removeAllRanges.html | 55 ++ .../web-platform/tests/selection/removeRange.html | 47 + .../tests/selection/script-and-style-elements.html | 37 + .../select-end-of-line-image.tentative.html | 49 + .../tests/selection/selectAllChildren.html | 64 ++ .../selection-select-all-move-input-crash.html | 10 + .../selection-shadow-dom-crash-print.html | 18 + .../tests/selection/setBaseAndExtent.html | 130 +++ .../tests/selection/stringifier.tentative.html | 28 + .../web-platform/tests/selection/test-iframe.html | 33 + .../tests/selection/textcontrols/focus.html | 43 + .../onselectionchange-content-attribute.html | 29 + .../textcontrols/selectionchange-bubble.html | 33 + .../selection/textcontrols/selectionchange.html | 212 +++++ .../tests/selection/toString-ff-bug-001.html | 23 + testing/web-platform/tests/selection/type.html | 31 + .../user-select-on-input-and-contenteditable.html | 41 + 78 files changed, 5004 insertions(+) create mode 100644 testing/web-platform/tests/selection/Document-open.html create mode 100644 testing/web-platform/tests/selection/META.yml create mode 100644 testing/web-platform/tests/selection/addRange-00.html create mode 100644 testing/web-platform/tests/selection/addRange-04.html create mode 100644 testing/web-platform/tests/selection/addRange-08.html create mode 100644 testing/web-platform/tests/selection/addRange-12.html create mode 100644 testing/web-platform/tests/selection/addRange-16.html create mode 100644 testing/web-platform/tests/selection/addRange-20.html create mode 100644 testing/web-platform/tests/selection/addRange-24.html create mode 100644 testing/web-platform/tests/selection/addRange-28.html create mode 100644 testing/web-platform/tests/selection/addRange-32.html create mode 100644 testing/web-platform/tests/selection/addRange-36.html create mode 100644 testing/web-platform/tests/selection/addRange-40.html create mode 100644 testing/web-platform/tests/selection/addRange-44.html create mode 100644 testing/web-platform/tests/selection/addRange-48.html create mode 100644 testing/web-platform/tests/selection/addRange-52.html create mode 100644 testing/web-platform/tests/selection/addRange-56.html create mode 100644 testing/web-platform/tests/selection/addRange.htm create mode 100644 testing/web-platform/tests/selection/addRange.js create mode 100644 testing/web-platform/tests/selection/addRange.tentative.html create mode 100644 testing/web-platform/tests/selection/anonymous/details-ancestor.html create mode 100644 testing/web-platform/tests/selection/anonymous/details-mutate.html create mode 100644 testing/web-platform/tests/selection/bidi/modify.tentative.html create mode 100644 testing/web-platform/tests/selection/caret/collapse-pre-linestart-1.html create mode 100644 testing/web-platform/tests/selection/caret/collapse-pre-linestart-2.html create mode 100644 testing/web-platform/tests/selection/caret/collapse-pre-linestart-ref.html create mode 100644 testing/web-platform/tests/selection/caret/empty-elements.html create mode 100644 testing/web-platform/tests/selection/collapse-00.html create mode 100644 testing/web-platform/tests/selection/collapse-15.html create mode 100644 testing/web-platform/tests/selection/collapse-30.html create mode 100644 testing/web-platform/tests/selection/collapse-45.html create mode 100644 testing/web-platform/tests/selection/collapse.htm create mode 100644 testing/web-platform/tests/selection/collapse.js create mode 100644 testing/web-platform/tests/selection/collapseToStartEnd.html create mode 100644 testing/web-platform/tests/selection/common.js create mode 100644 testing/web-platform/tests/selection/contenteditable/cefalse-on-boundaries.html create mode 100644 testing/web-platform/tests/selection/contenteditable/collapse.html create mode 100644 testing/web-platform/tests/selection/contenteditable/initial-selection-on-focus.tentative.html create mode 100644 testing/web-platform/tests/selection/contenteditable/modify.tentative.html create mode 100644 testing/web-platform/tests/selection/contenteditable/modifying-selection-with-middle-mouse-button.tentative.html create mode 100644 testing/web-platform/tests/selection/contenteditable/modifying-selection-with-primary-mouse-button.tentative.html create mode 100644 testing/web-platform/tests/selection/crashtests/selection-clip-crash.html create mode 100644 testing/web-platform/tests/selection/crashtests/selection-modify-around-input.html create mode 100644 testing/web-platform/tests/selection/crashtests/table.html create mode 100644 testing/web-platform/tests/selection/deleteFromDocument.html create mode 100644 testing/web-platform/tests/selection/dir-manual.html create mode 100644 testing/web-platform/tests/selection/drag-disabled-textarea-shadow-dom.html create mode 100644 testing/web-platform/tests/selection/extend-00.html create mode 100644 testing/web-platform/tests/selection/extend-20.html create mode 100644 testing/web-platform/tests/selection/extend-40.html create mode 100644 testing/web-platform/tests/selection/extend-exception.html create mode 100644 testing/web-platform/tests/selection/extend.js create mode 100644 testing/web-platform/tests/selection/getRangeAt.html create mode 100644 testing/web-platform/tests/selection/getSelection.html create mode 100644 testing/web-platform/tests/selection/idlharness.window.js create mode 100644 testing/web-platform/tests/selection/isCollapsed.html create mode 100644 testing/web-platform/tests/selection/modify-extend-word-trailing-inline-block.tentative.html create mode 100644 testing/web-platform/tests/selection/modify-line-flex-column.tentative.html create mode 100644 testing/web-platform/tests/selection/modify-line-flex-row.tentative.html create mode 100644 testing/web-platform/tests/selection/modify-line-grid-basic.tentative.html create mode 100644 testing/web-platform/tests/selection/modify.tentative.html create mode 100644 testing/web-platform/tests/selection/removeAllRanges.html create mode 100644 testing/web-platform/tests/selection/removeRange.html create mode 100644 testing/web-platform/tests/selection/script-and-style-elements.html create mode 100644 testing/web-platform/tests/selection/select-end-of-line-image.tentative.html create mode 100644 testing/web-platform/tests/selection/selectAllChildren.html create mode 100644 testing/web-platform/tests/selection/selection-select-all-move-input-crash.html create mode 100644 testing/web-platform/tests/selection/selection-shadow-dom-crash-print.html create mode 100644 testing/web-platform/tests/selection/setBaseAndExtent.html create mode 100644 testing/web-platform/tests/selection/stringifier.tentative.html create mode 100644 testing/web-platform/tests/selection/test-iframe.html create mode 100644 testing/web-platform/tests/selection/textcontrols/focus.html create mode 100644 testing/web-platform/tests/selection/textcontrols/onselectionchange-content-attribute.html create mode 100644 testing/web-platform/tests/selection/textcontrols/selectionchange-bubble.html create mode 100644 testing/web-platform/tests/selection/textcontrols/selectionchange.html create mode 100644 testing/web-platform/tests/selection/toString-ff-bug-001.html create mode 100644 testing/web-platform/tests/selection/type.html create mode 100644 testing/web-platform/tests/selection/user-select-on-input-and-contenteditable.html (limited to 'testing/web-platform/tests/selection') diff --git a/testing/web-platform/tests/selection/Document-open.html b/testing/web-platform/tests/selection/Document-open.html new file mode 100644 index 0000000000..9e3cb28124 --- /dev/null +++ b/testing/web-platform/tests/selection/Document-open.html @@ -0,0 +1,28 @@ + +Selection Document.open() tests +
+ + + diff --git a/testing/web-platform/tests/selection/META.yml b/testing/web-platform/tests/selection/META.yml new file mode 100644 index 0000000000..efe4ede48f --- /dev/null +++ b/testing/web-platform/tests/selection/META.yml @@ -0,0 +1,3 @@ +spec: https://w3c.github.io/selection-api/ +suggested_reviewers: + - rniwa diff --git a/testing/web-platform/tests/selection/addRange-00.html b/testing/web-platform/tests/selection/addRange-00.html new file mode 100644 index 0000000000..7f73f2a3a3 --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-00.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-04.html b/testing/web-platform/tests/selection/addRange-04.html new file mode 100644 index 0000000000..b9598a4b85 --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-04.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-08.html b/testing/web-platform/tests/selection/addRange-08.html new file mode 100644 index 0000000000..79e8ea6451 --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-08.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-12.html b/testing/web-platform/tests/selection/addRange-12.html new file mode 100644 index 0000000000..02d4f6d1f5 --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-12.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-16.html b/testing/web-platform/tests/selection/addRange-16.html new file mode 100644 index 0000000000..295b35f01b --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-16.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-20.html b/testing/web-platform/tests/selection/addRange-20.html new file mode 100644 index 0000000000..66ac5aec0d --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-20.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-24.html b/testing/web-platform/tests/selection/addRange-24.html new file mode 100644 index 0000000000..9804e1d908 --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-24.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-28.html b/testing/web-platform/tests/selection/addRange-28.html new file mode 100644 index 0000000000..784002a336 --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-28.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-32.html b/testing/web-platform/tests/selection/addRange-32.html new file mode 100644 index 0000000000..d599ec885f --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-32.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-36.html b/testing/web-platform/tests/selection/addRange-36.html new file mode 100644 index 0000000000..0dfe1b7a58 --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-36.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-40.html b/testing/web-platform/tests/selection/addRange-40.html new file mode 100644 index 0000000000..8df437c84c --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-40.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-44.html b/testing/web-platform/tests/selection/addRange-44.html new file mode 100644 index 0000000000..37c1a83df3 --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-44.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-48.html b/testing/web-platform/tests/selection/addRange-48.html new file mode 100644 index 0000000000..e219bc66e1 --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-48.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-52.html b/testing/web-platform/tests/selection/addRange-52.html new file mode 100644 index 0000000000..0f687a6e3a --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-52.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange-56.html b/testing/web-platform/tests/selection/addRange-56.html new file mode 100644 index 0000000000..6313f8969e --- /dev/null +++ b/testing/web-platform/tests/selection/addRange-56.html @@ -0,0 +1,14 @@ + +Selection.addRange() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/addRange.htm b/testing/web-platform/tests/selection/addRange.htm new file mode 100644 index 0000000000..4feb69f848 --- /dev/null +++ b/testing/web-platform/tests/selection/addRange.htm @@ -0,0 +1,29 @@ + + +Selection: Add a range to the selection + + + +
+

Add a range to the selection

+ + diff --git a/testing/web-platform/tests/selection/addRange.js b/testing/web-platform/tests/selection/addRange.js new file mode 100644 index 0000000000..7c443f7dad --- /dev/null +++ b/testing/web-platform/tests/selection/addRange.js @@ -0,0 +1,205 @@ +"use strict"; + +function testAddRange(exception, range, endpoints, qualifier, testName) { + if (!isSelectableNode(endpoints[0]) || !isSelectableNode(endpoints[2])) { + testAddRangeDoesNothing(exception, range, endpoints, qualifier, testName); + return; + } + + test(function() { + assert_equals(exception, null, "Test setup must not throw exceptions"); + + selection.addRange(range); + + assert_equals(range.startContainer, endpoints[0], + "addRange() must not modify the startContainer of the Range it's given"); + assert_equals(range.startOffset, endpoints[1], + "addRange() must not modify the startOffset of the Range it's given"); + assert_equals(range.endContainer, endpoints[2], + "addRange() must not modify the endContainer of the Range it's given"); + assert_equals(range.endOffset, endpoints[3], + "addRange() must not modify the endOffset of the Range it's given"); + }, testName + ": " + qualifier + " addRange() must not throw exceptions or modify the range it's given"); + + test(function() { + assert_equals(exception, null, "Test setup must not throw exceptions"); + + assert_equals(selection.rangeCount, 1, "rangeCount must be 1"); + }, testName + ": " + qualifier + " addRange() must result in rangeCount being 1"); + + // From here on out we check selection.getRangeAt(selection.rangeCount - 1) + // so as not to double-fail Gecko. + + test(function() { + assert_equals(exception, null, "Test setup must not throw exceptions"); + assert_not_equals(selection.rangeCount, 0, "Cannot proceed with tests if rangeCount is 0"); + + var newRange = selection.getRangeAt(selection.rangeCount - 1); + + assert_not_equals(newRange, null, + "getRangeAt(rangeCount - 1) must not return null"); + assert_equals(typeof newRange, "object", + "getRangeAt(rangeCount - 1) must return an object"); + + assert_equals(newRange.startContainer, range.startContainer, + "startContainer of the Selection's last Range must match the added Range"); + assert_equals(newRange.startOffset, range.startOffset, + "startOffset of the Selection's last Range must match the added Range"); + assert_equals(newRange.endContainer, range.endContainer, + "endContainer of the Selection's last Range must match the added Range"); + assert_equals(newRange.endOffset, range.endOffset, + "endOffset of the Selection's last Range must match the added Range"); + }, testName + ": " + qualifier + " addRange() must result in the selection's last range having the specified endpoints"); + + test(function() { + assert_equals(exception, null, "Test setup must not throw exceptions"); + assert_not_equals(selection.rangeCount, 0, "Cannot proceed with tests if rangeCount is 0"); + + assert_equals(selection.getRangeAt(selection.rangeCount - 1), range, + "getRangeAt(rangeCount - 1) must return the same object we added"); + }, testName + ": " + qualifier + " addRange() must result in the selection's last range being the same object we added"); + + // Let's not test many different modifications -- one should be enough. + test(function() { + assert_equals(exception, null, "Test setup must not throw exceptions"); + assert_not_equals(selection.rangeCount, 0, "Cannot proceed with tests if rangeCount is 0"); + + if (range.startContainer == paras[0].firstChild + && range.startOffset == 0 + && range.endContainer == paras[0].firstChild + && range.endOffset == 2) { + // Just in case . . . + range.setStart(paras[0].firstChild, 1); + } else { + range.setStart(paras[0].firstChild, 0); + range.setEnd(paras[0].firstChild, 2); + } + + var newRange = selection.getRangeAt(selection.rangeCount - 1); + + assert_equals(newRange.startContainer, range.startContainer, + "After mutating the " + qualifier + " added Range, startContainer of the Selection's last Range must match the added Range"); + assert_equals(newRange.startOffset, range.startOffset, + "After mutating the " + qualifier + " added Range, startOffset of the Selection's last Range must match the added Range"); + assert_equals(newRange.endContainer, range.endContainer, + "After mutating the " + qualifier + " added Range, endContainer of the Selection's last Range must match the added Range"); + assert_equals(newRange.endOffset, range.endOffset, + "After mutating the " + qualifier + " added Range, endOffset of the Selection's last Range must match the added Range"); + }, testName + ": modifying the " + qualifier + " added range must modify the Selection's last Range"); + + // Now test the other way too. + test(function() { + assert_equals(exception, null, "Test setup must not throw exceptions"); + assert_not_equals(selection.rangeCount, 0, "Cannot proceed with tests if rangeCount is 0"); + + var newRange = selection.getRangeAt(selection.rangeCount - 1); + + if (newRange.startContainer == paras[0].firstChild + && newRange.startOffset == 4 + && newRange.endContainer == paras[0].firstChild + && newRange.endOffset == 6) { + newRange.setStart(paras[0].firstChild, 5); + } else { + newRange.setStart(paras[0].firstChild, 4); + newRange.setStart(paras[0].firstChild, 6); + } + + assert_equals(newRange.startContainer, range.startContainer, + "After " + qualifier + " addRange(), after mutating the Selection's last Range, startContainer of the Selection's last Range must match the added Range"); + assert_equals(newRange.startOffset, range.startOffset, + "After " + qualifier + " addRange(), after mutating the Selection's last Range, startOffset of the Selection's last Range must match the added Range"); + assert_equals(newRange.endContainer, range.endContainer, + "After " + qualifier + " addRange(), after mutating the Selection's last Range, endContainer of the Selection's last Range must match the added Range"); + assert_equals(newRange.endOffset, range.endOffset, + "After " + qualifier + " addRange(), after mutating the Selection's last Range, endOffset of the Selection's last Range must match the added Range"); + }, testName + ": modifying the Selection's last Range must modify the " + qualifier + " added Range"); +} + +function testAddRangeDoesNothing(exception, range, endpoints, qualifier, testName) { + test(function() { + assert_equals(exception, null, "Test setup must not throw exceptions"); + + assertSelectionNoChange(function() { selection.addRange(range); }); + assert_equals(range.startContainer, endpoints[0], + "addRange() must not modify the startContainer of the Range it's given"); + assert_equals(range.startOffset, endpoints[1], + "addRange() must not modify the startOffset of the Range it's given"); + assert_equals(range.endContainer, endpoints[2], + "addRange() must not modify the endContainer of the Range it's given"); + assert_equals(range.endOffset, endpoints[3], + "addRange() must not modify the endOffset of the Range it's given"); + }, testName + ": " + qualifier + " addRange() must do nothing"); +} + +// Do only n evals, not n^2 +var testRangesEvaled = testRanges.map(eval); + +// Run a subset of all of addRange tests. +// Huge number of tests in a single file causes problems. Each of +// addRange-NN.html runs a part of them. +// +// startIndex - Start index in testRanges array +// optionalEndIndex - End index in testRanges array + 1. If this argument is +// omitted, testRanges.length is applied. +function testAddRangeSubSet(startIndex, optionalEndIndex) { + var endIndex = optionalEndIndex === undefined ? testRanges.length : optionalEndIndex; + if (startIndex < 0 || startIndex >= testRanges.length) + throw "Sanity check: Specified index is invalid."; + if (endIndex < 0 || endIndex > testRanges.length) + throw "Sanity check: Specified index is invalid."; + + for (var i = startIndex; i < endIndex; i++) { + for (var j = 0; j < testRanges.length; j++) { + var testName = "Range " + i + " " + testRanges[i] + + " followed by Range " + j + " " + testRanges[j]; + + var exception = null; + try { + selection.removeAllRanges(); + + var endpoints1 = testRangesEvaled[i]; + var range1 = ownerDocument(endpoints1[0]).createRange(); + range1.setStart(endpoints1[0], endpoints1[1]); + range1.setEnd(endpoints1[2], endpoints1[3]); + + if (range1.startContainer !== endpoints1[0]) { + throw "Sanity check: the first Range we created must have the desired startContainer"; + } + if (range1.startOffset !== endpoints1[1]) { + throw "Sanity check: the first Range we created must have the desired startOffset"; + } + if (range1.endContainer !== endpoints1[2]) { + throw "Sanity check: the first Range we created must have the desired endContainer"; + } + if (range1.endOffset !== endpoints1[3]) { + throw "Sanity check: the first Range we created must have the desired endOffset"; + } + + var endpoints2 = testRangesEvaled[j]; + var range2 = ownerDocument(endpoints2[0]).createRange(); + range2.setStart(endpoints2[0], endpoints2[1]); + range2.setEnd(endpoints2[2], endpoints2[3]); + + if (range2.startContainer !== endpoints2[0]) { + throw "Sanity check: the second Range we created must have the desired startContainer"; + } + if (range2.startOffset !== endpoints2[1]) { + throw "Sanity check: the second Range we created must have the desired startOffset"; + } + if (range2.endContainer !== endpoints2[2]) { + throw "Sanity check: the second Range we created must have the desired endContainer"; + } + if (range2.endOffset !== endpoints2[3]) { + throw "Sanity check: the second Range we created must have the desired endOffset"; + } + } catch (e) { + exception = e; + } + + testAddRange(exception, range1, endpoints1, "first", testName); + if (selection.rangeCount > 0) + testAddRangeDoesNothing(exception, range2, endpoints2, "second", testName); + } + } +} + diff --git a/testing/web-platform/tests/selection/addRange.tentative.html b/testing/web-platform/tests/selection/addRange.tentative.html new file mode 100644 index 0000000000..28e3b675d3 --- /dev/null +++ b/testing/web-platform/tests/selection/addRange.tentative.html @@ -0,0 +1,29 @@ + + +Selection: Add a range to the selection + + + + +

Add a range to the selection

+ + diff --git a/testing/web-platform/tests/selection/anonymous/details-ancestor.html b/testing/web-platform/tests/selection/anonymous/details-ancestor.html new file mode 100644 index 0000000000..b0adfa6890 --- /dev/null +++ b/testing/web-platform/tests/selection/anonymous/details-ancestor.html @@ -0,0 +1,40 @@ + + +Selecting internal node + + + + + + + +
+ diff --git a/testing/web-platform/tests/selection/anonymous/details-mutate.html b/testing/web-platform/tests/selection/anonymous/details-mutate.html new file mode 100644 index 0000000000..3cd5475112 --- /dev/null +++ b/testing/web-platform/tests/selection/anonymous/details-mutate.html @@ -0,0 +1,38 @@ + + +Test selecting anonymous summary element inside details + + + + + + + +
+ diff --git a/testing/web-platform/tests/selection/bidi/modify.tentative.html b/testing/web-platform/tests/selection/bidi/modify.tentative.html new file mode 100644 index 0000000000..6029cf423a --- /dev/null +++ b/testing/web-platform/tests/selection/bidi/modify.tentative.html @@ -0,0 +1,60 @@ + + +Selection#modify bidi tests + + + +
+
Hello World
+
مرحبا عالم
+
مرحبا عالم Hello World
+
Hello World مرحبا عالم
+
Hello World مرحبا عالم Hello World
+
مرحبا عالم Hello World مرحبا عالم
+
+ + diff --git a/testing/web-platform/tests/selection/caret/collapse-pre-linestart-1.html b/testing/web-platform/tests/selection/caret/collapse-pre-linestart-1.html new file mode 100644 index 0000000000..e8bd262868 --- /dev/null +++ b/testing/web-platform/tests/selection/caret/collapse-pre-linestart-1.html @@ -0,0 +1,13 @@ + + +selection.collapse() to line start + + + + +
ABC
+
+ diff --git a/testing/web-platform/tests/selection/caret/collapse-pre-linestart-2.html b/testing/web-platform/tests/selection/caret/collapse-pre-linestart-2.html new file mode 100644 index 0000000000..0feee464c9 --- /dev/null +++ b/testing/web-platform/tests/selection/caret/collapse-pre-linestart-2.html @@ -0,0 +1,14 @@ + + +selection.collapse() to line start + + + + +
ABC
+
+
+ diff --git a/testing/web-platform/tests/selection/caret/collapse-pre-linestart-ref.html b/testing/web-platform/tests/selection/caret/collapse-pre-linestart-ref.html new file mode 100644 index 0000000000..2b25941ded --- /dev/null +++ b/testing/web-platform/tests/selection/caret/collapse-pre-linestart-ref.html @@ -0,0 +1,8 @@ + + +selection.collapse() to line start +
ABC

+ diff --git a/testing/web-platform/tests/selection/caret/empty-elements.html b/testing/web-platform/tests/selection/caret/empty-elements.html new file mode 100644 index 0000000000..328188c957 --- /dev/null +++ b/testing/web-platform/tests/selection/caret/empty-elements.html @@ -0,0 +1,25 @@ + + +Placing selection inside empty elements + + +
+

+
+ diff --git a/testing/web-platform/tests/selection/collapse-00.html b/testing/web-platform/tests/selection/collapse-00.html new file mode 100644 index 0000000000..6adaca4002 --- /dev/null +++ b/testing/web-platform/tests/selection/collapse-00.html @@ -0,0 +1,14 @@ + +Selection.collapse()/setPosition() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/collapse-15.html b/testing/web-platform/tests/selection/collapse-15.html new file mode 100644 index 0000000000..377e504434 --- /dev/null +++ b/testing/web-platform/tests/selection/collapse-15.html @@ -0,0 +1,14 @@ + +Selection.collapse()/setPosition() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/collapse-30.html b/testing/web-platform/tests/selection/collapse-30.html new file mode 100644 index 0000000000..376633d910 --- /dev/null +++ b/testing/web-platform/tests/selection/collapse-30.html @@ -0,0 +1,14 @@ + +Selection.collapse()/setPosition() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/collapse-45.html b/testing/web-platform/tests/selection/collapse-45.html new file mode 100644 index 0000000000..28eee4eb79 --- /dev/null +++ b/testing/web-platform/tests/selection/collapse-45.html @@ -0,0 +1,14 @@ + +Selection.collapse()/setPosition() tests + +
+ + + + + diff --git a/testing/web-platform/tests/selection/collapse.htm b/testing/web-platform/tests/selection/collapse.htm new file mode 100644 index 0000000000..78fb779c4f --- /dev/null +++ b/testing/web-platform/tests/selection/collapse.htm @@ -0,0 +1,30 @@ + + +Selection: Collapse the selection using collapse() + + + +
+

Add a range to the selection

+ + diff --git a/testing/web-platform/tests/selection/collapse.js b/testing/web-platform/tests/selection/collapse.js new file mode 100644 index 0000000000..4a816f4956 --- /dev/null +++ b/testing/web-platform/tests/selection/collapse.js @@ -0,0 +1,103 @@ +"use strict"; + +function testCollapse(range, point, method) { + selection.removeAllRanges(); + var addedRange; + if (range) { + addedRange = range.cloneRange(); + selection.addRange(addedRange); + } + + if (point[0].nodeType == Node.DOCUMENT_TYPE_NODE) { + assert_throws_dom("INVALID_NODE_TYPE_ERR", function() { + selection[method](point[0], point[1]); + }, "Must throw INVALID_NODE_TYPE_ERR when " + method + "()ing if the node is a DocumentType"); + return; + } + + if (point[1] < 0 || point[1] > getNodeLength(point[0])) { + assert_throws_dom("INDEX_SIZE_ERR", function() { + selection[method](point[0], point[1]); + }, "Must throw INDEX_SIZE_ERR when " + method + "()ing if the offset is negative or greater than the node's length"); + return; + } + + if (!document.contains(point[0])) { + assertSelectionNoChange(function() { + selection[method](point[0], point[1]); + }); + return; + } + + selection[method](point[0], point[1]); + + assert_equals(selection.rangeCount, 1, + "selection.rangeCount must equal 1 after " + method + "()"); + assert_equals(selection.focusNode, point[0], + "focusNode must equal the node we " + method + "()d to"); + assert_equals(selection.focusOffset, point[1], + "focusOffset must equal the offset we " + method + "()d to"); + assert_equals(selection.focusNode, selection.anchorNode, + "focusNode and anchorNode must be equal after " + method + "()"); + assert_equals(selection.focusOffset, selection.anchorOffset, + "focusOffset and anchorOffset must be equal after " + method + "()"); + if (range) { + assert_equals(addedRange.startContainer, range.startContainer, + method + "() must not change the startContainer of a preexisting Range"); + assert_equals(addedRange.endContainer, range.endContainer, + method + "() must not change the endContainer of a preexisting Range"); + assert_equals(addedRange.startOffset, range.startOffset, + method + "() must not change the startOffset of a preexisting Range"); + assert_equals(addedRange.endOffset, range.endOffset, + method + "() must not change the endOffset of a preexisting Range"); + } +} + +// Also test a selection with no ranges +testRanges.unshift("[]"); + +// Don't want to eval() each point a bazillion times +var testPointsCached = []; +for (var i = 0; i < testPoints.length; i++) { + testPointsCached.push(eval(testPoints[i])); +} + +// Run a subset of all of collapse tests. +// Huge number of tests in a single file causes problems. Each of +// collapse-NN.html runs a part of them. +// +// startIndex - Start index in testRanges array +// optionalEndIndex - End index in testRanges array + 1. If this argument is +// omitted, testRanges.length is applied. +function testCollapseSubSet(startIndex, optionalEndIndex) { + var endIndex = optionalEndIndex === undefined ? testRanges.length : optionalEndIndex; + if (startIndex < 0 || startIndex >= testRanges.length) + throw "Sanity check: Specified index is invalid."; + if (endIndex < 0 || endIndex > testRanges.length) + throw "Sanity check: Specified index is invalid."; + + var tests = []; + for (var i = startIndex; i < endIndex; i++) { + var endpoints = eval(testRanges[i]); + var range; + test(function() { + if (endpoints.length) { + range = ownerDocument(endpoints[0]).createRange(); + range.setStart(endpoints[0], endpoints[1]); + range.setEnd(endpoints[2], endpoints[3]); + } else { + // Empty selection + range = null; + } + }, "Set up range " + i + " " + testRanges[i]); + for (var j = 0; j < testPoints.length; j++) { + tests.push(["collapse() on " + testRanges[i] + " to " + testPoints[j], + range, testPointsCached[j], "collapse"]); + tests.push(["setPosition() on " + testRanges[i] + " to " + testPoints[j], + range, testPointsCached[j], "setPosition"]); + } + } + + generate_tests(testCollapse, tests); +} + diff --git a/testing/web-platform/tests/selection/collapseToStartEnd.html b/testing/web-platform/tests/selection/collapseToStartEnd.html new file mode 100644 index 0000000000..c2bba3af18 --- /dev/null +++ b/testing/web-platform/tests/selection/collapseToStartEnd.html @@ -0,0 +1,114 @@ + +Selection.collapseTo(Start|End)() tests +
+ + + + diff --git a/testing/web-platform/tests/selection/common.js b/testing/web-platform/tests/selection/common.js new file mode 100644 index 0000000000..3bdc509462 --- /dev/null +++ b/testing/web-platform/tests/selection/common.js @@ -0,0 +1,1002 @@ +"use strict"; +// TODO: iframes, contenteditable/designMode + +// Everything is done in functions in this test harness, so we have to declare +// all the variables before use to make sure they can be reused. +var selection; +var testDiv, paras, detachedDiv, detachedPara1, detachedPara2, + foreignDoc, foreignPara1, foreignPara2, xmlDoc, xmlElement, + detachedXmlElement, detachedTextNode, foreignTextNode, + detachedForeignTextNode, xmlTextNode, detachedXmlTextNode, + processingInstruction, detachedProcessingInstruction, comment, + detachedComment, foreignComment, detachedForeignComment, xmlComment, + detachedXmlComment, docfrag, foreignDocfrag, xmlDocfrag, doctype, + foreignDoctype, xmlDoctype; +var testRanges, testPoints, testNodes; + +function setupRangeTests() { + selection = getSelection(); + testDiv = document.querySelector("#test"); + if (testDiv) { + testDiv.parentNode.removeChild(testDiv); + } + testDiv = document.createElement("div"); + testDiv.id = "test"; + document.body.insertBefore(testDiv, document.body.firstChild); + // Test some diacritics, to make sure browsers are using code units here + // and not something like grapheme clusters. + testDiv.innerHTML = "

Äb̈c̈d̈ëf̈g̈ḧ\n" + + "

Qrstuvwx" + + "

+
 
+

Lorem ipsum dolor sit amet.

+
 
+
+ diff --git a/testing/web-platform/tests/selection/contenteditable/collapse.html b/testing/web-platform/tests/selection/contenteditable/collapse.html new file mode 100644 index 0000000000..6081d05516 --- /dev/null +++ b/testing/web-platform/tests/selection/contenteditable/collapse.html @@ -0,0 +1,43 @@ + + +Selection across multiple contenteditable + + + +
+
+
+
+
+
+
+ diff --git a/testing/web-platform/tests/selection/contenteditable/initial-selection-on-focus.tentative.html b/testing/web-platform/tests/selection/contenteditable/initial-selection-on-focus.tentative.html new file mode 100644 index 0000000000..fcaf70d877 --- /dev/null +++ b/testing/web-platform/tests/selection/contenteditable/initial-selection-on-focus.tentative.html @@ -0,0 +1,473 @@ + + + + +initial selection on focus of contenteditable + + + + + + diff --git a/testing/web-platform/tests/selection/contenteditable/modify.tentative.html b/testing/web-platform/tests/selection/contenteditable/modify.tentative.html new file mode 100644 index 0000000000..a3afd52ea2 --- /dev/null +++ b/testing/web-platform/tests/selection/contenteditable/modify.tentative.html @@ -0,0 +1,60 @@ + + +Selection.modify() inside contenteditable + + +
Editable
+
Non-editable
+
+ Prefix: Editable: Suffix
+ Prefix: Editable: Suffix
+ Editable: Suffix
+ Prefix: Editable
+ Editable
+ Prefix: Edit
able
: Suffix
+ Prefix: Edit
able
: + Suffix
+
+ diff --git a/testing/web-platform/tests/selection/contenteditable/modifying-selection-with-middle-mouse-button.tentative.html b/testing/web-platform/tests/selection/contenteditable/modifying-selection-with-middle-mouse-button.tentative.html new file mode 100644 index 0000000000..a8287d9002 --- /dev/null +++ b/testing/web-platform/tests/selection/contenteditable/modifying-selection-with-middle-mouse-button.tentative.html @@ -0,0 +1,213 @@ + + + + +Testing default action of `mousedown` of middle button and `mouseup` of middle button + + + + + + + + +
+ + + diff --git a/testing/web-platform/tests/selection/contenteditable/modifying-selection-with-primary-mouse-button.tentative.html b/testing/web-platform/tests/selection/contenteditable/modifying-selection-with-primary-mouse-button.tentative.html new file mode 100644 index 0000000000..57586a6060 --- /dev/null +++ b/testing/web-platform/tests/selection/contenteditable/modifying-selection-with-primary-mouse-button.tentative.html @@ -0,0 +1,212 @@ + + + + +Testing default action of `mousedown` of primary button and `mouseup` of primary button + + + + + + + + +
+ + + diff --git a/testing/web-platform/tests/selection/crashtests/selection-clip-crash.html b/testing/web-platform/tests/selection/crashtests/selection-clip-crash.html new file mode 100644 index 0000000000..66d10b4742 --- /dev/null +++ b/testing/web-platform/tests/selection/crashtests/selection-clip-crash.html @@ -0,0 +1,31 @@ + + + + + + + +
+
+ + diff --git a/testing/web-platform/tests/selection/crashtests/selection-modify-around-input.html b/testing/web-platform/tests/selection/crashtests/selection-modify-around-input.html new file mode 100644 index 0000000000..24b9ae7d35 --- /dev/null +++ b/testing/web-platform/tests/selection/crashtests/selection-modify-around-input.html @@ -0,0 +1,24 @@ + + + + + + + + + + +
+ + diff --git a/testing/web-platform/tests/selection/crashtests/table.html b/testing/web-platform/tests/selection/crashtests/table.html new file mode 100644 index 0000000000..36eb803a5c --- /dev/null +++ b/testing/web-platform/tests/selection/crashtests/table.html @@ -0,0 +1,14 @@ + + + + + +
M!}\\)M6\X
+ + diff --git a/testing/web-platform/tests/selection/deleteFromDocument.html b/testing/web-platform/tests/selection/deleteFromDocument.html new file mode 100644 index 0000000000..b7e036009f --- /dev/null +++ b/testing/web-platform/tests/selection/deleteFromDocument.html @@ -0,0 +1,97 @@ + +Selection.deleteFromDocument() tests + +

To debug test failures, add a query parameter with the test id (like +"?5"). Only that test will be run. Then you can look at the resulting +iframes in the DOM. +

+ + + + diff --git a/testing/web-platform/tests/selection/dir-manual.html b/testing/web-platform/tests/selection/dir-manual.html new file mode 100644 index 0000000000..39cf655523 --- /dev/null +++ b/testing/web-platform/tests/selection/dir-manual.html @@ -0,0 +1,106 @@ + +Selection direction tests + +
+

This is a manual test, since there's no way to synthesize keyboard or + mouse input. Click after the letter "c" in the following paragraph and + drag backwards so that both the "b" and the "c" are highlighted, then click + the "Test" button: + +

abcd + +

efghi +

+
+ + + diff --git a/testing/web-platform/tests/selection/drag-disabled-textarea-shadow-dom.html b/testing/web-platform/tests/selection/drag-disabled-textarea-shadow-dom.html new file mode 100644 index 0000000000..9270cfc5c6 --- /dev/null +++ b/testing/web-platform/tests/selection/drag-disabled-textarea-shadow-dom.html @@ -0,0 +1,39 @@ + + + + + + + + + + + diff --git a/testing/web-platform/tests/selection/extend-00.html b/testing/web-platform/tests/selection/extend-00.html new file mode 100644 index 0000000000..8943524878 --- /dev/null +++ b/testing/web-platform/tests/selection/extend-00.html @@ -0,0 +1,16 @@ + +Selection extend() tests + + + + + + + +
+ diff --git a/testing/web-platform/tests/selection/extend-20.html b/testing/web-platform/tests/selection/extend-20.html new file mode 100644 index 0000000000..b5ca161d98 --- /dev/null +++ b/testing/web-platform/tests/selection/extend-20.html @@ -0,0 +1,16 @@ + +Selection extend() tests + + + + + + + +
+ diff --git a/testing/web-platform/tests/selection/extend-40.html b/testing/web-platform/tests/selection/extend-40.html new file mode 100644 index 0000000000..f0b78d6973 --- /dev/null +++ b/testing/web-platform/tests/selection/extend-40.html @@ -0,0 +1,16 @@ + +Selection extend() tests + + + + + + + +
+ diff --git a/testing/web-platform/tests/selection/extend-exception.html b/testing/web-platform/tests/selection/extend-exception.html new file mode 100644 index 0000000000..67e880fa1c --- /dev/null +++ b/testing/web-platform/tests/selection/extend-exception.html @@ -0,0 +1,21 @@ + + +Selection extend() test thrown exceptions + + + + + + + \ No newline at end of file diff --git a/testing/web-platform/tests/selection/extend.js b/testing/web-platform/tests/selection/extend.js new file mode 100644 index 0000000000..d5d199068c --- /dev/null +++ b/testing/web-platform/tests/selection/extend.js @@ -0,0 +1,161 @@ +"use strict"; + +// Also test a selection with no ranges +testRanges.unshift("[]"); + +// Run a subset of all of extend tests. +// Huge number of tests in a single file causes problems. Each of +// extend-NN.html runs a part of them. +// +// startIndex - Start index in testRanges array +// optionalEndIndex - End index in testRanges array + 1. If this argument is +// omitted, testRanges.length is applied. +function testExtendSubSet(startIndex, optionalEndIndex) { + var endIndex = optionalEndIndex === undefined ? testRanges.length : optionalEndIndex; + if (startIndex < 0 || startIndex >= testRanges.length) + throw "Sanity check: Specified index is invalid."; + if (endIndex < 0 || endIndex > testRanges.length) + throw "Sanity check: Specified index is invalid."; + + // We test Selections that go both forwards and backwards here. In the + // latter case we need to use extend() to force it to go backwards, which is + // fair enough, since that's what we're testing. We test collapsed + // selections only once. + for (var i = startIndex; i < endIndex; i++) { + var endpoints = eval(testRanges[i]); + // We can't test extend() with unselectable endpoints. + if (!isSelectableNode(endpoints[0]) || !isSelectableNode(endpoints[2])) + continue; + for (var j = 0; j < testPoints.length; j++) { + if (endpoints[0] == endpoints[2] + && endpoints[1] == endpoints[3]) { + // Test collapsed selections only once + test(function() { + setSelectionForwards(endpoints); + testExtend(endpoints, eval(testPoints[j])); + }, "extend() with range " + i + " " + testRanges[i] + + " and point " + j + " " + testPoints[j]); + } else { + test(function() { + setSelectionForwards(endpoints); + testExtend(endpoints, eval(testPoints[j])); + }, "extend() forwards with range " + i + " " + testRanges[i] + + " and point " + j + " " + testPoints[j]); + + test(function() { + setSelectionBackwards(endpoints); + testExtend(endpoints, eval(testPoints[j])); + }, "extend() backwards with range " + i + " " + testRanges[i] + + " and point " + j + " " + testPoints[j]); + } + } + } +} + +function testExtend(endpoints, target) { + assert_equals(getSelection().rangeCount, endpoints.length/4, + "Sanity check: rangeCount must be correct"); + + var node = target[0]; + var offset = target[1]; + + // "If node's root is not the document associated with the context object, + // abort these steps." + if (!document.contains(node)) { + assertSelectionNoChange(function() { + selection.extend(node, offset); + }); + return; + } + + // "If the context object's range is null, throw an InvalidStateError + // exception and abort these steps." + if (getSelection().rangeCount == 0) { + assert_throws_dom("INVALID_STATE_ERR", function() { + selection.extend(node, offset); + }, "extend() when rangeCount is 0 must throw InvalidStateError"); + return; + } + + assert_equals(getSelection().getRangeAt(0).startContainer, endpoints[0], + "Sanity check: startContainer must be correct"); + assert_equals(getSelection().getRangeAt(0).startOffset, endpoints[1], + "Sanity check: startOffset must be correct"); + assert_equals(getSelection().getRangeAt(0).endContainer, endpoints[2], + "Sanity check: endContainer must be correct"); + assert_equals(getSelection().getRangeAt(0).endOffset, endpoints[3], + "Sanity check: endOffset must be correct"); + + // "Let anchor and focus be the context object's anchor and focus, and let + // new focus be the boundary point (node, offset)." + var anchorNode = getSelection().anchorNode; + var anchorOffset = getSelection().anchorOffset; + var focusNode = getSelection().focusNode; + var focusOffset = getSelection().focusOffset; + + // "Let new range be a new range." + // + // We'll always be setting either new range's start or its end to new + // focus, so we'll always throw at some point. Test that now. + // + // From DOM4's "set the start or end of a range": "If node is a doctype, + // throw an "InvalidNodeTypeError" exception and terminate these steps." + if (node.nodeType == Node.DOCUMENT_TYPE_NODE) { + assert_throws_dom("INVALID_NODE_TYPE_ERR", function() { + selection.extend(node, offset); + }, "extend() to a doctype must throw InvalidNodeTypeError"); + return; + } + + // From DOM4's "set the start or end of a range": "If offset is greater + // than node's length, throw an "IndexSizeError" exception and terminate + // these steps." + // + // FIXME: We should be casting offset to an unsigned int per WebIDL. Until + // we do, we need the offset < 0 check too. + if (offset < 0 || offset > getNodeLength(node)) { + assert_throws_dom("INDEX_SIZE_ERR", function() { + selection.extend(node, offset); + }, "extend() to an offset that's greater than node length (" + getNodeLength(node) + ") must throw IndexSizeError"); + return; + } + + // Now back to the editing spec. + var originalRange = getSelection().getRangeAt(0); + + // "If node's root is not the same as the context object's range's root, + // set new range's start and end to (node, offset)." + // + // "Otherwise, if anchor is before or equal to new focus, set new range's + // start to anchor, then set its end to new focus." + // + // "Otherwise, set new range's start to new focus, then set its end to + // anchor." + // + // "Set the context object's range to new range." + // + // "If new focus is before anchor, set the context object's direction to + // backwards. Otherwise, set it to forwards." + // + // The upshot of all these is summed up by just testing the anchor and + // offset. + getSelection().extend(node, offset); + + if (furthestAncestor(anchorNode) == furthestAncestor(node)) { + assert_equals(getSelection().anchorNode, anchorNode, + "anchorNode must not change if the node passed to extend() has the same root as the original range"); + assert_equals(getSelection().anchorOffset, anchorOffset, + "anchorOffset must not change if the node passed to extend() has the same root as the original range"); + } else { + assert_equals(getSelection().anchorNode, node, + "anchorNode must be the node passed to extend() if it has a different root from the original range"); + assert_equals(getSelection().anchorOffset, offset, + "anchorOffset must be the offset passed to extend() if the node has a different root from the original range"); + } + assert_equals(getSelection().focusNode, node, + "focusNode must be the node passed to extend()"); + assert_equals(getSelection().focusOffset, offset, + "focusOffset must be the offset passed to extend()"); + assert_not_equals(getSelection().getRangeAt(0), originalRange, + "extend() must replace any existing range with a new one, not mutate the existing one"); +} diff --git a/testing/web-platform/tests/selection/getRangeAt.html b/testing/web-platform/tests/selection/getRangeAt.html new file mode 100644 index 0000000000..a84ad46f22 --- /dev/null +++ b/testing/web-platform/tests/selection/getRangeAt.html @@ -0,0 +1,32 @@ + +The getRangeAt method + + + + + diff --git a/testing/web-platform/tests/selection/getSelection.html b/testing/web-platform/tests/selection/getSelection.html new file mode 100644 index 0000000000..ea119f2fc4 --- /dev/null +++ b/testing/web-platform/tests/selection/getSelection.html @@ -0,0 +1,160 @@ + +getSelection() tests +
+ + + diff --git a/testing/web-platform/tests/selection/idlharness.window.js b/testing/web-platform/tests/selection/idlharness.window.js new file mode 100644 index 0000000000..543fcb3eff --- /dev/null +++ b/testing/web-platform/tests/selection/idlharness.window.js @@ -0,0 +1,18 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +'use strict'; + +// https://w3c.github.io/selection-api/ + +idl_test( + ['selection-api'], + ['html', 'dom'], + idlArray => { + idlArray.add_objects({ + Window: ['window'], + Document: ['document'], + Selection: ['getSelection()'], + }); + } +); diff --git a/testing/web-platform/tests/selection/isCollapsed.html b/testing/web-platform/tests/selection/isCollapsed.html new file mode 100644 index 0000000000..819a3e297a --- /dev/null +++ b/testing/web-platform/tests/selection/isCollapsed.html @@ -0,0 +1,33 @@ + +Selection.isCollapsed tests +
+ + + + diff --git a/testing/web-platform/tests/selection/modify-extend-word-trailing-inline-block.tentative.html b/testing/web-platform/tests/selection/modify-extend-word-trailing-inline-block.tentative.html new file mode 100644 index 0000000000..1eaa6ec68d --- /dev/null +++ b/testing/web-platform/tests/selection/modify-extend-word-trailing-inline-block.tentative.html @@ -0,0 +1,23 @@ + + +Selection.modify: Extending a word towards the end of a line ended by an inline-block. + + + + + + +
This is a line
+ + diff --git a/testing/web-platform/tests/selection/modify-line-flex-column.tentative.html b/testing/web-platform/tests/selection/modify-line-flex-column.tentative.html new file mode 100644 index 0000000000..984bb81913 --- /dev/null +++ b/testing/web-platform/tests/selection/modify-line-flex-column.tentative.html @@ -0,0 +1,47 @@ + + +Selection.modify(): line navigation on a column-oriented flex container + + + + +
+

One

+

Two

+

Three

+

Four

+
+ diff --git a/testing/web-platform/tests/selection/modify-line-flex-row.tentative.html b/testing/web-platform/tests/selection/modify-line-flex-row.tentative.html new file mode 100644 index 0000000000..28b22eba03 --- /dev/null +++ b/testing/web-platform/tests/selection/modify-line-flex-row.tentative.html @@ -0,0 +1,50 @@ + + +Selection.modify(): line navigation on a row-oriented flex container + + + + + +
+

One

+

Two

+

Three

+

Four

+
+ diff --git a/testing/web-platform/tests/selection/modify-line-grid-basic.tentative.html b/testing/web-platform/tests/selection/modify-line-grid-basic.tentative.html new file mode 100644 index 0000000000..faadd93c64 --- /dev/null +++ b/testing/web-platform/tests/selection/modify-line-grid-basic.tentative.html @@ -0,0 +1,47 @@ + + +Selection.modify(): line navigation on a grid container + + + + +
+

One

+

Two

+

Three

+

Four

+
+ diff --git a/testing/web-platform/tests/selection/modify.tentative.html b/testing/web-platform/tests/selection/modify.tentative.html new file mode 100644 index 0000000000..37231571ed --- /dev/null +++ b/testing/web-platform/tests/selection/modify.tentative.html @@ -0,0 +1,90 @@ + + +Selection.modify() tests + + + +
Test, these are strong italic normal.
+ +
+foo
+bar
+
+ +
+foo
bar +
+ +
+foo
+
+bar +
+ + diff --git a/testing/web-platform/tests/selection/removeAllRanges.html b/testing/web-platform/tests/selection/removeAllRanges.html new file mode 100644 index 0000000000..026280d6b8 --- /dev/null +++ b/testing/web-platform/tests/selection/removeAllRanges.html @@ -0,0 +1,55 @@ + +Selection.removeAllRanges()/empty() tests +
+ + + + diff --git a/testing/web-platform/tests/selection/removeRange.html b/testing/web-platform/tests/selection/removeRange.html new file mode 100644 index 0000000000..8dcd6d2c07 --- /dev/null +++ b/testing/web-platform/tests/selection/removeRange.html @@ -0,0 +1,47 @@ + +Selection.removeRange tests + + + + + + diff --git a/testing/web-platform/tests/selection/script-and-style-elements.html b/testing/web-platform/tests/selection/script-and-style-elements.html new file mode 100644 index 0000000000..b75665917d --- /dev/null +++ b/testing/web-platform/tests/selection/script-and-style-elements.html @@ -0,0 +1,37 @@ + + +Selection: STYLE and SCRIPT elements should be included in Selection.toString() if they are display!=none + + + +
+
+ + + + +
+ + diff --git a/testing/web-platform/tests/selection/select-end-of-line-image.tentative.html b/testing/web-platform/tests/selection/select-end-of-line-image.tentative.html new file mode 100644 index 0000000000..572296c443 --- /dev/null +++ b/testing/web-platform/tests/selection/select-end-of-line-image.tentative.html @@ -0,0 +1,49 @@ + + + + Selection: Select the image at the end of the line + + + + + + + + + + + + + + You shouldn't see an orange image at the end of this line + + + + + diff --git a/testing/web-platform/tests/selection/selectAllChildren.html b/testing/web-platform/tests/selection/selectAllChildren.html new file mode 100644 index 0000000000..9a472a4b2f --- /dev/null +++ b/testing/web-platform/tests/selection/selectAllChildren.html @@ -0,0 +1,64 @@ + +Selection.selectAllChildren tests + +
+ + + + diff --git a/testing/web-platform/tests/selection/selection-select-all-move-input-crash.html b/testing/web-platform/tests/selection/selection-select-all-move-input-crash.html new file mode 100644 index 0000000000..6f692dc5e7 --- /dev/null +++ b/testing/web-platform/tests/selection/selection-select-all-move-input-crash.html @@ -0,0 +1,10 @@ + + + + + diff --git a/testing/web-platform/tests/selection/selection-shadow-dom-crash-print.html b/testing/web-platform/tests/selection/selection-shadow-dom-crash-print.html new file mode 100644 index 0000000000..cf62609173 --- /dev/null +++ b/testing/web-platform/tests/selection/selection-shadow-dom-crash-print.html @@ -0,0 +1,18 @@ + +Printing with odd selections doesn't crash + + + + + + +
  • x
  • diff --git a/testing/web-platform/tests/selection/setBaseAndExtent.html b/testing/web-platform/tests/selection/setBaseAndExtent.html new file mode 100644 index 0000000000..13108bb506 --- /dev/null +++ b/testing/web-platform/tests/selection/setBaseAndExtent.html @@ -0,0 +1,130 @@ + +Selection.setBaseAndExtent() tests +
    + + + + diff --git a/testing/web-platform/tests/selection/stringifier.tentative.html b/testing/web-platform/tests/selection/stringifier.tentative.html new file mode 100644 index 0000000000..f4cae7eb5d --- /dev/null +++ b/testing/web-platform/tests/selection/stringifier.tentative.html @@ -0,0 +1,28 @@ + + +Selection: stringifier + + + + + +

    foo bar

    + + diff --git a/testing/web-platform/tests/selection/test-iframe.html b/testing/web-platform/tests/selection/test-iframe.html new file mode 100644 index 0000000000..42b982324b --- /dev/null +++ b/testing/web-platform/tests/selection/test-iframe.html @@ -0,0 +1,33 @@ + +Selection test iframe + + + + diff --git a/testing/web-platform/tests/selection/textcontrols/focus.html b/testing/web-platform/tests/selection/textcontrols/focus.html new file mode 100644 index 0000000000..8c2e0b5591 --- /dev/null +++ b/testing/web-platform/tests/selection/textcontrols/focus.html @@ -0,0 +1,43 @@ + + +Stop selection extension when focus changes + + + + + + + +

    + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna + aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint + occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +

    + + diff --git a/testing/web-platform/tests/selection/textcontrols/onselectionchange-content-attribute.html b/testing/web-platform/tests/selection/textcontrols/onselectionchange-content-attribute.html new file mode 100644 index 0000000000..3120b3bff5 --- /dev/null +++ b/testing/web-platform/tests/selection/textcontrols/onselectionchange-content-attribute.html @@ -0,0 +1,29 @@ + + +Test that setting "onselectionchange" content attribute adds an event listener + + + + + + +
    + diff --git a/testing/web-platform/tests/selection/textcontrols/selectionchange-bubble.html b/testing/web-platform/tests/selection/textcontrols/selectionchange-bubble.html new file mode 100644 index 0000000000..834b32bdd3 --- /dev/null +++ b/testing/web-platform/tests/selection/textcontrols/selectionchange-bubble.html @@ -0,0 +1,33 @@ + + +Test selectionchange events bubbling from text controls + + + +
    + + + diff --git a/testing/web-platform/tests/selection/textcontrols/selectionchange.html b/testing/web-platform/tests/selection/textcontrols/selectionchange.html new file mode 100644 index 0000000000..2b43cfe44b --- /dev/null +++ b/testing/web-platform/tests/selection/textcontrols/selectionchange.html @@ -0,0 +1,212 @@ + + +Test selectionchange events from text controls + + + + + +
    + + + diff --git a/testing/web-platform/tests/selection/toString-ff-bug-001.html b/testing/web-platform/tests/selection/toString-ff-bug-001.html new file mode 100644 index 0000000000..985be73b5c --- /dev/null +++ b/testing/web-platform/tests/selection/toString-ff-bug-001.html @@ -0,0 +1,23 @@ + +Can serialize a range which starts at the end of an element + + + + + +
    + + + + +
    Foo
    + diff --git a/testing/web-platform/tests/selection/type.html b/testing/web-platform/tests/selection/type.html new file mode 100644 index 0000000000..7be8ba61bc --- /dev/null +++ b/testing/web-platform/tests/selection/type.html @@ -0,0 +1,31 @@ + +Selection.type tests +
    + + + + diff --git a/testing/web-platform/tests/selection/user-select-on-input-and-contenteditable.html b/testing/web-platform/tests/selection/user-select-on-input-and-contenteditable.html new file mode 100644 index 0000000000..6cbde6914b --- /dev/null +++ b/testing/web-platform/tests/selection/user-select-on-input-and-contenteditable.html @@ -0,0 +1,41 @@ + + + + +Test: used 'user-select' is always 'contain' on editable elements + + + + + + + + + + + +
    I should be selectable
    + -- cgit v1.2.3