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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/ApplyBlockElementCommandTest.cpp

Issue 2627103003: [EditCommandSource] Pass source through |CompositeEditCommand| ctor instead of |apply(source)| (Closed)
Patch Set: 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "bindings/core/v8/ExceptionState.h" 5 #include "bindings/core/v8/ExceptionState.h"
6 #include "core/HTMLNames.h" 6 #include "core/HTMLNames.h"
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/QualifiedName.h" 8 #include "core/dom/QualifiedName.h"
9 #include "core/editing/EditingTestBase.h" 9 #include "core/editing/EditingTestBase.h"
10 #include "core/editing/FrameSelection.h" 10 #include "core/editing/FrameSelection.h"
(...skipping 26 matching lines...) Expand all
37 document().body()->setContentEditable("false", ASSERT_NO_EXCEPTION); 37 document().body()->setContentEditable("false", ASSERT_NO_EXCEPTION);
38 document().setDesignMode("on"); 38 document().setDesignMode("on");
39 document().updateStyleAndLayoutIgnorePendingStylesheets(); 39 document().updateStyleAndLayoutIgnorePendingStylesheets();
40 selection().setSelection( 40 selection().setSelection(
41 SelectionInDOMTree::Builder() 41 SelectionInDOMTree::Builder()
42 .setBaseAndExtent( 42 .setBaseAndExtent(
43 Position(document().documentElement(), 1), 43 Position(document().documentElement(), 1),
44 Position(document().getElementById("va")->firstChild(), 2)) 44 Position(document().getElementById("va")->firstChild(), 2))
45 .build()); 45 .build());
46 46
47 FormatBlockCommand* command = 47 FormatBlockCommand* command = FormatBlockCommand::create(
48 FormatBlockCommand::create(document(), HTMLNames::footerTag); 48 document(), EditCommandSource::kMenuOrKeyBinding, HTMLNames::footerTag);
49 command->apply(EditCommandSource::kMenuOrKeyBinding); 49 command->apply();
50 50
51 EXPECT_EQ( 51 EXPECT_EQ(
52 "<body contenteditable=\"false\">\n" 52 "<body contenteditable=\"false\">\n"
53 "<pre><var id=\"va\" class=\"CLASS13\">\nC\n</var></pre><input></body>", 53 "<pre><var id=\"va\" class=\"CLASS13\">\nC\n</var></pre><input></body>",
54 document().documentElement()->innerHTML()); 54 document().documentElement()->innerHTML());
55 } 55 }
56 56
57 // This is a regression test for https://crbug.com/660801 57 // This is a regression test for https://crbug.com/660801
58 TEST_F(ApplyBlockElementCommandTest, visibilityChangeDuringCommand) { 58 TEST_F(ApplyBlockElementCommandTest, visibilityChangeDuringCommand) {
59 document().head()->insertAdjacentHTML( 59 document().head()->insertAdjacentHTML(
60 "afterbegin", "<style>li:first-child { visibility:visible; }</style>", 60 "afterbegin", "<style>li:first-child { visibility:visible; }</style>",
61 ASSERT_NO_EXCEPTION); 61 ASSERT_NO_EXCEPTION);
62 setBodyContent("<ul style='visibility:hidden'><li>xyz</li></ul>"); 62 setBodyContent("<ul style='visibility:hidden'><li>xyz</li></ul>");
63 document().setDesignMode("on"); 63 document().setDesignMode("on");
64 64
65 updateAllLifecyclePhases(); 65 updateAllLifecyclePhases();
66 selection().setSelection( 66 selection().setSelection(
67 SelectionInDOMTree::Builder() 67 SelectionInDOMTree::Builder()
68 .collapse(Position(document().querySelector("li"), 0)) 68 .collapse(Position(document().querySelector("li"), 0))
69 .build()); 69 .build());
70 70
71 IndentOutdentCommand* command = 71 IndentOutdentCommand* command = IndentOutdentCommand::create(
72 IndentOutdentCommand::create(document(), IndentOutdentCommand::Indent); 72 document(), EditCommandSource::kMenuOrKeyBinding,
73 command->apply(EditCommandSource::kMenuOrKeyBinding); 73 IndentOutdentCommand::Indent);
74 command->apply();
74 75
75 EXPECT_EQ( 76 EXPECT_EQ(
76 "<head><style>li:first-child { visibility:visible; }</style></head>" 77 "<head><style>li:first-child { visibility:visible; }</style></head>"
77 "<body><ul style=\"visibility:hidden\"><ul></ul><li>xyz</li></ul></body>", 78 "<body><ul style=\"visibility:hidden\"><ul></ul><li>xyz</li></ul></body>",
78 document().documentElement()->innerHTML()); 79 document().documentElement()->innerHTML());
79 } 80 }
80 81
81 } // namespace blink 82 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698