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

Side by Side Diff: third_party/WebKit/LayoutTests/editing/assert_selection.js

Issue 2162063004: Make assert_selection() to support no BODY element case (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-07-20T13:35:22 Created 4 years, 5 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
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/assert_selection.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 'use strict'; 5 'use strict';
6 6
7 // This file provides |assert_selection(sample, tester, expectedText)| assertion 7 // This file provides |assert_selection(sample, tester, expectedText)| assertion
8 // to W3C test harness to write editing test cases easier. 8 // to W3C test harness to write editing test cases easier.
9 // 9 //
10 // |sample| is an HTML fragment text which is inserted as |innerHTML|. It should 10 // |sample| is an HTML fragment text which is inserted as |innerHTML|. It should
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 459 }
460 this.serializeChildren(element); 460 this.serializeChildren(element);
461 this.emit(`</${tagName}>`); 461 this.emit(`</${tagName}>`);
462 } 462 }
463 463
464 /** 464 /**
465 * @public 465 * @public
466 * @param {!HTMLDocument} document 466 * @param {!HTMLDocument} document
467 */ 467 */
468 serialize(document) { 468 serialize(document) {
469 this.serializeChildren(document.body); 469 if (document.body)
470 this.serializeChildren(document.body);
471 else
472 this.serializeInternal(document.documentElement);
470 return this.strings_.join(''); 473 return this.strings_.join('');
471 } 474 }
472 475
473 /** 476 /**
474 * @private 477 * @private
475 * @param {!HTMLElement} element 478 * @param {!HTMLElement} element
476 */ 479 */
477 serializeChildren(element) { 480 serializeChildren(element) {
478 /** @type {!Array<!Node>} */ 481 /** @type {!Array<!Node>} */
479 const childNodes = Array.from(element.childNodes); 482 const childNodes = Array.from(element.childNodes);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 throw new Error(`${description}\n` + 680 throw new Error(`${description}\n` +
678 `\t expected ${expectedText},\n` + 681 `\t expected ${expectedText},\n` +
679 `\t but got ${actualText},\n` + 682 `\t but got ${actualText},\n` +
680 `\t sameupto ${commonPrefixOf(expectedText, actualText)}`); 683 `\t sameupto ${commonPrefixOf(expectedText, actualText)}`);
681 } 684 }
682 685
683 // Export symbols 686 // Export symbols
684 window.Sample = Sample; 687 window.Sample = Sample;
685 window.assert_selection = assertSelection; 688 window.assert_selection = assertSelection;
686 })(); 689 })();
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/assert_selection.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698