| 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 2ee74145ff63043a2113562c4e58759055572bf4..0ecd886f8ad612cec465995f90a4a7e5126b59b0 100644
|
| --- a/third_party/WebKit/LayoutTests/editing/assert_selection.js
|
| +++ b/third_party/WebKit/LayoutTests/editing/assert_selection.js
|
| @@ -580,8 +580,6 @@ class Sample {
|
| }
|
|
|
| function assembleDescription() {
|
| - const RE_TEST_FUNCTION =
|
| - new RegExp('at Object.test \\(.*?([^/]+?):(\\d+):(\\d+)\\)');
|
| function getStack() {
|
| let stack;
|
| try {
|
| @@ -591,11 +589,14 @@ function assembleDescription() {
|
| }
|
| return stack
|
| }
|
| +
|
| + const RE_IN_ASSERT_SELECTION = new RegExp('assert_selection\\.js');
|
| for (const line of getStack()) {
|
| - const match = RE_TEST_FUNCTION.exec(line);
|
| - if (!match)
|
| - continue;
|
| - return `${match[1]}(${match[2]})`;
|
| + const match = RE_IN_ASSERT_SELECTION.exec(line);
|
| + if (!match) {
|
| + const RE_LAYOUTTESTS = new RegExp('LayoutTests.*');
|
| + return RE_LAYOUTTESTS.exec(line);
|
| + }
|
| }
|
| return '';
|
| }
|
| @@ -628,6 +629,19 @@ function checkExpectedText(expectedText) {
|
| }
|
|
|
| /**
|
| + * @param {string} str1
|
| + * @param {string} str2
|
| + * @return {string}
|
| + */
|
| +function commonPrefixOf(str1, str2) {
|
| + for (let index = 0; index < str1.length; ++index) {
|
| + if (str1[index] !== str2[index])
|
| + return str1.substr(0, index);
|
| + }
|
| + return str1;
|
| +}
|
| +
|
| +/**
|
| * @param {string} inputText
|
| * @param {function(!Selection)|string}
|
| * @param {string} expectedText
|
| @@ -652,9 +666,14 @@ function assertSelection(
|
| const actualText = sample.serialize();
|
| // We keep sample HTML when assertion is false for ease of debugging test
|
| // case.
|
| - if (actualText === expectedText)
|
| + if (actualText === expectedText) {
|
| sample.remove();
|
| - assert_equals(actualText, expectedText, description);
|
| + return;
|
| + }
|
| + throw new Error(`${description}\n` +
|
| + `\t expected ${expectedText},\n` +
|
| + `\t but got ${actualText},\n` +
|
| + `\t sameupto ${commonPrefixOf(expectedText, actualText)}`);
|
| }
|
|
|
| // Export symbols
|
|
|