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

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

Issue 2138653002: [Editing][CodeHealth] Improve result comparing in assert_selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/assert_selection.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« 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