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

Unified Diff: third_party/WebKit/LayoutTests/editing/assert_selection.js

Issue 2753193002: Editing: Indent command: Do not insert BLOCKQUOTE under the root HTML element. (Closed)
Patch Set: . Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/editing/assert_selection.js
diff --git a/third_party/WebKit/LayoutTests/editing/assert_selection.js b/third_party/WebKit/LayoutTests/editing/assert_selection.js
index a66aa40318439a852ced410615da78961b6fb626..50ba4fa2e03758f0d1d07e79009c8ad9f2bb4f9c 100644
--- a/third_party/WebKit/LayoutTests/editing/assert_selection.js
+++ b/third_party/WebKit/LayoutTests/editing/assert_selection.js
@@ -22,6 +22,7 @@
// description: A description
// dumpAs: 'domtree' or 'flattree'. Default is 'domtree'.
// removeSampleIfSucceeded: A boolean. Default is true.
+// dumpFromRoot: A boolean. Default is false.
yosin_UTC9 2017/03/17 10:04:11 Could you move "assert_selection.js" change to ano
//
// Example:
// test(() => {
@@ -619,9 +620,10 @@ class Serializer {
/**
* @public
* @param {!HTMLDocument} document
+ * @param {boolean} dumpFromRoot
*/
- serialize(document) {
- if (document.body)
+ serialize(document, dumpFromRoot) {
+ if (document.body && !dumpFromRoot)
this.serializeChildren(document.body);
else
this.serializeInternal(document.documentElement);
@@ -788,14 +790,15 @@ class Sample {
/**
* @public
* @param {!Traversal} traversal
+ * @param {boolean} dumpFromRoot
* @return {string}
*/
- serialize(traversal) {
+ serialize(traversal, dumpFromRoot) {
/** @type {!SampleSelection} */
const selection = traversal.fromDOMSelection(this.selection_);
/** @type {!Serializer} */
const serializer = new Serializer(selection, traversal);
- return serializer.serialize(this.document_);
+ return serializer.serialize(this.document_, dumpFromRoot);
}
}
@@ -873,6 +876,7 @@ function assertSelection(
const kDescription = 'description';
const kDumpAs = 'dumpAs';
const kRemoveSampleIfSucceeded = 'removeSampleIfSucceeded';
+ const kDumpFromRoot = 'dumpFromRoot';
/** @type {!Object} */
const options = typeof(opt_options) === 'string'
? {description: opt_options} : opt_options;
@@ -884,6 +888,8 @@ function assertSelection(
? !!options[kRemoveSampleIfSucceeded] : true;
/** @type {DumpAs} */
const dumpAs = options[kDumpAs] || DumpAs.DOM_TREE;
+ /** @type {boolean} */
+ const dumpFromRoot = options[kDumpFromRoot] || false;
checkExpectedText(expectedText);
const sample = new Sample(inputText);
@@ -913,7 +919,7 @@ function assertSelection(
})();
/** @type {string} */
- const actualText = sample.serialize(traversal);
+ const actualText = sample.serialize(traversal, dumpFromRoot);
// We keep sample HTML when assertion is false for ease of debugging test
// case.
if (actualText === expectedText) {

Powered by Google App Engine
This is Rietveld 408576698