Chromium Code Reviews| 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..43a67fa9f3e11f88a7f8e46e749a6ff1f695abc8 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 ''; |
| } |
| @@ -652,9 +653,21 @@ 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); |
| + } else { |
| + var comparedLength = Math.min(actualText.length, expectedText.length); |
|
yosin_UTC9
2016/07/11 06:48:18
Could you introduce mismatch(str1, str2) and misma
yoichio
2016/07/11 09:04:14
Done.
|
| + var i = 0; |
| + for (; i < comparedLength; ++i) { |
| + if (actualText[i] !== expectedText[i]) |
| + break; |
| + } |
| + |
| + throw new Error(`${description}\n` + |
| + `\t expected ${expectedText},\n` + |
| + `\t but got ${actualText},\n` + |
| + `\t sameupto ${expectedText.substr(0,i)}`); |
| + } |
| } |
| // Export symbols |