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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/editing/other/restoration.html

Issue 2630243004: Manually import wpt/editing and wpt/selection/ (Closed)
Patch Set: Add expectation Created 3 years, 11 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 <meta charset=utf-8>
3 <title>Restoration of style tests</title>
4 <!--
5 No spec, based on: https://bugzilla.mozilla.org/show_bug.cgi?id=1250805
6 If the user presses Ctrl+B and then hits Enter and then types text, the text
7 should still be bold. Hitting Enter shouldn't make it forget. And so too for
8 other commands.
9 -->
10 <script src=/resources/testharness.js></script>
11 <script src=/resources/testharnessreport.js></script>
12 <div contenteditable></div>
13 <script>
14 var div = document.querySelector("div");
15
16 function doTestInner(cmd, param, startBold) {
17 div.innerHTML = startBold ? "<b>foo</b>bar" : "foobar";
18 getSelection().collapse(startBold ? div.firstChild.firstChild
19 : div.firstChild, 3);
20
21 // Set/unset bold, then run command and see if it's still there
22 assert_true(document.execCommand("bold", false, ""),
23 "execCommand needs to return true for bold");
24
25 assert_true(document.execCommand(cmd, false, param),
26 "execCommand needs to return true for " + cmd + " " + param);
27
28 assert_equals(document.queryCommandState("bold"), !startBold,
29 "bold state");
30
31 assert_true(document.execCommand("inserttext", false, "x"),
32 "execCommand needs to return true for inserttext x");
33
34 // Find the new text node and check that it's actually bold (or not)
35 var node = div;
36 while (node) {
37 if (node.nodeType == Node.TEXT_NODE && node.nodeValue.indexOf("x") != -1) {
38 assert_in_array(getComputedStyle(node.parentNode).fontWeight,
39 !startBold ? ["700", "bold"] : ["400", "normal"],
40 "font-weight");
41 return;
42 }
43 if (node.firstChild) {
44 node = node.firstChild;
45 continue;
46 }
47 while (node != div && !node.nextSibling) {
48 node = node.parentNode;
49 }
50 if (node == div) {
51 assert_unreached("x not found!");
52 break;
53 }
54 node = node.nextSibling;
55 }
56 }
57
58 function doTest(cmd, param) {
59 if (param === undefined) {
60 param = "";
61 }
62
63 test(function() {
64 doTestInner(cmd, param, true);
65 }, cmd + " " + param + " starting bold");
66
67 test(function() {
68 doTestInner(cmd, param, false);
69 }, cmd + " " + param + " starting not bold");
70 }
71
72 doTest("insertparagraph");
73 doTest("insertlinebreak");
74 doTest("delete");
75 doTest("forwarddelete");
76 doTest("insertorderedlist");
77 doTest("insertunorderedlist");
78 doTest("indent");
79 // Outdent does nothing here, but should be harmless.
80 doTest("outdent");
81 doTest("justifyleft");
82 doTest("justifyright");
83 doTest("justifycenter");
84 doTest("justifyfull");
85 doTest("formatblock", "div");
86 doTest("formatblock", "blockquote");
87 doTest("inserthorizontalrule");
88 doTest("insertimage", "a");
89 doTest("inserttext", "bar");
90 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698