summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/editing
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/editing')
-rw-r--r--testing/web-platform/tests/editing/crashtests/enableInlineTableEditing-after-updating-selection-range-cross-shadow-dom-boundary.html22
-rw-r--r--testing/web-platform/tests/editing/edit-context/edit-context-basics.tentative.html13
-rw-r--r--testing/web-platform/tests/editing/include/editor-test-utils.js10
-rw-r--r--testing/web-platform/tests/editing/other/delete-in-inline-editing-host-under-shadow-root.html61
-rw-r--r--testing/web-platform/tests/editing/other/delete-in-shadow-hosted-in-body.html81
-rw-r--r--testing/web-platform/tests/editing/other/paste-in-list-with-inline-style.tentative.html30
6 files changed, 216 insertions, 1 deletions
diff --git a/testing/web-platform/tests/editing/crashtests/enableInlineTableEditing-after-updating-selection-range-cross-shadow-dom-boundary.html b/testing/web-platform/tests/editing/crashtests/enableInlineTableEditing-after-updating-selection-range-cross-shadow-dom-boundary.html
new file mode 100644
index 0000000000..b248e03ea0
--- /dev/null
+++ b/testing/web-platform/tests/editing/crashtests/enableInlineTableEditing-after-updating-selection-range-cross-shadow-dom-boundary.html
@@ -0,0 +1,22 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<script>
+"use strict";
+
+document.addEventListener("DOMContentLoaded", () => {
+ window.find("A");
+ const range = document.createRange();
+ getSelection().addRange(range);
+ range.setEnd(document.querySelector("template").content, 0);
+ document.execCommand("enableInlineTableEditing", false, "true");
+});
+</script>
+<body>
+<template>
+</template>
+A
+<time contenteditable></time>
+</body>
+</html>
diff --git a/testing/web-platform/tests/editing/edit-context/edit-context-basics.tentative.html b/testing/web-platform/tests/editing/edit-context/edit-context-basics.tentative.html
index 78b6824921..0011270c81 100644
--- a/testing/web-platform/tests/editing/edit-context/edit-context-basics.tentative.html
+++ b/testing/web-platform/tests/editing/edit-context/edit-context-basics.tentative.html
@@ -191,6 +191,19 @@
assert_equals(editContext.selectionStart, 3);
assert_equals(editContext.selectionEnd, 0);
}, 'EditContext should allow a backwards selection');
+
+ test(function() {
+ const editContext = new EditContext();
+ assert_not_equals(editContext, null);
+ editContext.updateText(6, 0, "abcdef");
+ assert_equals(editContext.text, "abcdef");
+
+ editContext.updateText(2, 5, "ghi");
+ assert_equals(editContext.text, "abghif");
+
+ editContext.updateText(5, 2, "jkl");
+ assert_equals(editContext.text, "abjklf");
+ }, 'updateText can replace substrings including with backwards parameters');
</script>
</body>
</html>
diff --git a/testing/web-platform/tests/editing/include/editor-test-utils.js b/testing/web-platform/tests/editing/include/editor-test-utils.js
index 24527d4a79..d0d50d22a6 100644
--- a/testing/web-platform/tests/editing/include/editor-test-utils.js
+++ b/testing/web-platform/tests/editing/include/editor-test-utils.js
@@ -32,7 +32,15 @@ class EditorTestUtils {
sendKey(key, modifier) {
if (!modifier) {
- return this.window.test_driver.send_keys(this.editingHost, key)
+ // send_keys requires element in the light DOM.
+ const elementInLightDOM = (e => {
+ const doc = e.ownerDocument;
+ while (e.getRootNode({composed:false}) !== doc) {
+ e = e.getRootNode({composed:false}).host;
+ }
+ return e;
+ })(this.editingHost);
+ return this.window.test_driver.send_keys(elementInLightDOM, key)
.catch(() => {
return new this.window.test_driver.Actions()
.keyDown(key)
diff --git a/testing/web-platform/tests/editing/other/delete-in-inline-editing-host-under-shadow-root.html b/testing/web-platform/tests/editing/other/delete-in-inline-editing-host-under-shadow-root.html
new file mode 100644
index 0000000000..c1a825a645
--- /dev/null
+++ b/testing/web-platform/tests/editing/other/delete-in-inline-editing-host-under-shadow-root.html
@@ -0,0 +1,61 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Backspace/Delete in inline editing host which is a shadow root</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script src="../include/editor-test-utils.js"></script>
+<script>
+"use strict";
+
+addEventListener("load", () => {
+ const shadowRoot = document.body.firstChild.attachShadow({mode: "open"});
+ const editingHost = document.createElement("span");
+ editingHost.setAttribute("contenteditable", "");
+ shadowRoot.appendChild(editingHost);
+ const utils = new EditorTestUtils(editingHost);
+
+ promise_test(async t => {
+ utils.setupEditingHost("ab[]c");
+ await utils.sendBackspaceKey();
+ assert_equals(
+ editingHost.textContent,
+ "ac"
+ );
+ }, "Backspace at <span contenteditable>ab[]c</span>");
+
+ promise_test(async t => {
+ utils.setupEditingHost("a[]bc");
+ await utils.sendDeleteKey();
+ assert_equals(
+ editingHost.textContent,
+ "ac"
+ );
+ }, "Delete at <span contenteditable>a[]bc</span>");
+
+ promise_test(async t => {
+ utils.setupEditingHost("a[b]c");
+ await utils.sendBackspaceKey();
+ assert_equals(
+ editingHost.textContent,
+ "ac"
+ );
+ }, "Backspace at <span contenteditable>a[b]c</span>");
+
+ promise_test(async t => {
+ utils.setupEditingHost("a[b]c");
+ await utils.sendDeleteKey();
+ assert_equals(
+ editingHost.textContent,
+ "ac"
+ );
+ }, "Delete at <span contenteditable>a[b]c</span>");
+}, {once: true});
+</script>
+</head>
+<body><div></div></body>
+</html>
diff --git a/testing/web-platform/tests/editing/other/delete-in-shadow-hosted-in-body.html b/testing/web-platform/tests/editing/other/delete-in-shadow-hosted-in-body.html
new file mode 100644
index 0000000000..4b02719ea0
--- /dev/null
+++ b/testing/web-platform/tests/editing/other/delete-in-shadow-hosted-in-body.html
@@ -0,0 +1,81 @@
+<!doctype html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Delete editor in a shadow</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="/resources/testdriver-actions.js"></script>
+<script src="../include/editor-test-utils.js"></script>
+<script>
+"use strict";
+
+addEventListener("load", () => {
+ const shadowRoot = document.body.attachShadow({mode: "open"});
+ for (const tag of ["input", "textarea"]) {
+ promise_test(async t => {
+ const textControl = document.createElement(tag);
+ textControl.value = "text";
+ shadowRoot.appendChild(textControl);
+ textControl.focus();
+ textControl.selectionStart = textControl.value.length;
+ const utils = new EditorTestUtils(textControl);
+ await utils.sendBackspaceKey();
+ assert_equals(
+ textControl.value,
+ "tex",
+ `Backspace in ${t.name} should delete character before the caret`
+ );
+ textControl.value = "text";
+ textControl.selectionStart = textControl.selectionEnd = 0;
+ await utils.sendDeleteKey();
+ assert_equals(
+ textControl.value,
+ "ext",
+ `Delete in ${t.name} should delete character after the caret`
+ );
+ textControl.value = "text";
+ textControl.select();
+ await utils.sendBackspaceKey();
+ assert_equals(
+ textControl.value,
+ "",
+ `Backspace after selecting all text in ${t.name} should delete all text`
+ );
+ }, `<${tag}> in shadow of the <body>`);
+ }
+
+ promise_test(async t => {
+ const editingHost = document.createElement("div");
+ editingHost.setAttribute("contenteditable", "");
+ shadowRoot.appendChild(editingHost);
+ const utils = new EditorTestUtils(editingHost);
+ utils.setupEditingHost("text[]");
+ await utils.sendBackspaceKey();
+ assert_equals(
+ editingHost.textContent,
+ "tex",
+ `Backspace in ${t.name} should delete character before the caret`
+ );
+ utils.setupEditingHost("[]text");
+ await utils.sendDeleteKey();
+ assert_equals(
+ editingHost.textContent,
+ "ext",
+ `Delete in ${t.name} should delete character after the caret`
+ );
+ utils.setupEditingHost("[text]");
+ await utils.sendBackspaceKey();
+ assert_equals(
+ editingHost.textContent,
+ "",
+ `Backspace after selecting all text in ${t.name} should delete all text`
+ );
+ }, "<div contenteditable> in shadow of the <body>");
+}, {once: true});
+</script>
+</head>
+<body></body>
+</html>
diff --git a/testing/web-platform/tests/editing/other/paste-in-list-with-inline-style.tentative.html b/testing/web-platform/tests/editing/other/paste-in-list-with-inline-style.tentative.html
new file mode 100644
index 0000000000..97710e805d
--- /dev/null
+++ b/testing/web-platform/tests/editing/other/paste-in-list-with-inline-style.tentative.html
@@ -0,0 +1,30 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>This tests for a bug in ReplaceSelectionCommand where styles are lost during paste.</title>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<span id="copy" style="font-weight: bold;">copy this</span>
+<div id="paste" contenteditable="true"> <ul><li id="list1"></li></ul></div>
+<div id="log"></div>
+<script>
+"use strict";
+
+setup({explicit_done: true});
+
+function runTests() {
+ test(function() {
+ var selection = window.getSelection();
+ selection.selectAllChildren(document.getElementById('copy'));
+ document.execCommand('Copy');
+ var sample = document.getElementById('list1');
+ selection.collapse(sample);
+ document.execCommand('Paste');
+
+ assert_equals(sample.innerHTML, '<span style="font-weight: 700;">copy this</span>');
+ assert_true(selection.isCollapsed);
+ }, "");
+ done();
+}
+
+window.addEventListener("load", runTests, {once: true});
+</script>