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

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

Issue 2155793002: The parameter of the tester should have spaces in assert_selection() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master 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 643 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 function assertSelection( 654 function assertSelection(
655 inputText, tester, expectedText, opt_description = '') { 655 inputText, tester, expectedText, opt_description = '') {
656 /** @type {string} */ 656 /** @type {string} */
657 const description = 657 const description =
658 opt_description === '' ? assembleDescription() : opt_description; 658 opt_description === '' ? assembleDescription() : opt_description;
659 checkExpectedText(expectedText); 659 checkExpectedText(expectedText);
660 const sample = new Sample(inputText); 660 const sample = new Sample(inputText);
661 if (typeof(tester) === 'function') { 661 if (typeof(tester) === 'function') {
662 tester.call(window, sample.selection); 662 tester.call(window, sample.selection);
663 } else if (typeof(tester) === 'string') { 663 } else if (typeof(tester) === 'string') {
664 const strings = tester.split(' '); 664 const strings = tester.split(/ (.+)/);
665 sample.document.execCommand(strings[0], false, strings[1]); 665 sample.document.execCommand(strings[0], false, strings[1]);
666 } else { 666 } else {
667 throw new Error(`Invalid tester: ${tester}`); 667 throw new Error(`Invalid tester: ${tester}`);
668 } 668 }
669 /** @type {string} */ 669 /** @type {string} */
670 const actualText = sample.serialize(); 670 const actualText = sample.serialize();
671 // We keep sample HTML when assertion is false for ease of debugging test 671 // We keep sample HTML when assertion is false for ease of debugging test
672 // case. 672 // case.
673 if (actualText === expectedText) { 673 if (actualText === expectedText) {
674 sample.remove(); 674 sample.remove();
675 return; 675 return;
676 } 676 }
677 throw new Error(`${description}\n` + 677 throw new Error(`${description}\n` +
678 `\t expected ${expectedText},\n` + 678 `\t expected ${expectedText},\n` +
679 `\t but got ${actualText},\n` + 679 `\t but got ${actualText},\n` +
680 `\t sameupto ${commonPrefixOf(expectedText, actualText)}`); 680 `\t sameupto ${commonPrefixOf(expectedText, actualText)}`);
681 } 681 }
682 682
683 // Export symbols 683 // Export symbols
684 window.Sample = Sample; 684 window.Sample = Sample;
685 window.assert_selection = assertSelection; 685 window.assert_selection = assertSelection;
686 })(); 686 })();
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