Unit test helper: reduce multiple whitespace to single space instead
of removing completely
Bug: none
Change-Id: I2beccef0cd171e3132b4da451b5ff32b6fcb64e0
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5829414
Commit-Queue: Wolfgang Beyer <wolfi@chromium.org>
Auto-Submit: Wolfgang Beyer <wolfi@chromium.org>
Reviewed-by: Ergün Erdoğmuş <ergunsh@chromium.org>
diff --git a/front_end/panels/application/components/FrameDetailsView.test.ts b/front_end/panels/application/components/FrameDetailsView.test.ts
index aca834b..ec3d4c7 100644
--- a/front_end/panels/application/components/FrameDetailsView.test.ts
+++ b/front_end/panels/application/components/FrameDetailsView.test.ts
@@ -171,7 +171,7 @@
'Yes',
'None',
'SameOrigin',
- 'HTTP headerbase-uri: \'self\'object-src: \'none\'script-src: \'strict-dynamic\', \'unsafe-inline\', https:, http:, \'nonce-GsVjHiIoejpPhMPOHDQZ90yc9eJn1s\', \'unsafe-eval\'report-uri: https://www.example.com/csp',
+ 'HTTP header base-uri: \'self\'object-src: \'none\'script-src: \'strict-dynamic\', \'unsafe-inline\', https:, http:, \'nonce-GsVjHiIoejpPhMPOHDQZ90yc9eJn1s\', \'unsafe-eval\'report-uri: https://www.example.com/csp',
'available, transferable',
'available\xA0Learn more',
]);
@@ -192,7 +192,7 @@
stackTraceText = stackTraceText.concat(getCleanTextContentFromElements(row.shadowRoot, '.stack-trace-row'));
});
- assert.deepEqual(stackTraceText[0], 'function1\xA0@\xA0www.example.com/script.js:16');
+ assert.deepEqual(stackTraceText[0], 'function1 \xA0@\xA0www.example.com/script.js:16');
const adScriptLink = component.shadowRoot.querySelector('devtools-report-value.ad-script-link');
assert.exists(adScriptLink);
diff --git a/front_end/panels/application/components/StackTrace.test.ts b/front_end/panels/application/components/StackTrace.test.ts
index 1d2cc4e..431ecd7 100644
--- a/front_end/panels/application/components/StackTrace.test.ts
+++ b/front_end/panels/application/components/StackTrace.test.ts
@@ -102,8 +102,8 @@
});
assert.deepEqual(stackTraceText, [
- 'function1\xA0@\xA0www.example.com/script1.js',
- 'function2\xA0@\xA0www.example.com/script2.js',
+ 'function1 \xA0@\xA0www.example.com/script1.js',
+ 'function2 \xA0@\xA0www.example.com/script2.js',
]);
});
@@ -159,7 +159,7 @@
});
assert.deepEqual(stackTraceText, [
- 'function1\xA0@\xA0www.example.com/script.js',
+ 'function1 \xA0@\xA0www.example.com/script.js',
'Show 1 more frame',
]);
@@ -179,8 +179,8 @@
});
assert.deepEqual(openedStackTraceText, [
- 'function1\xA0@\xA0www.example.com/script.js',
- 'function2\xA0@\xA0www.example.com/hidden.js',
+ 'function1 \xA0@\xA0www.example.com/script.js',
+ 'function2 \xA0@\xA0www.example.com/hidden.js',
'Show less',
]);
@@ -199,7 +199,7 @@
});
assert.deepEqual(stackTraceText, [
- 'function1\xA0@\xA0www.example.com/script.js',
+ 'function1 \xA0@\xA0www.example.com/script.js',
'Show 1 more frame',
]);
});
diff --git a/front_end/panels/application/preloading/PreloadingView.test.ts b/front_end/panels/application/preloading/PreloadingView.test.ts
index 39c972d..4f41336 100644
--- a/front_end/panels/application/preloading/PreloadingView.test.ts
+++ b/front_end/panels/application/preloading/PreloadingView.test.ts
@@ -776,7 +776,7 @@
const values = getCleanTextContentFromElements(report, 'devtools-report-value');
assert.deepEqual(zip2(keys, values), [
['URL', 'https://example.com/prerendered.html'],
- ['Action', 'PrerenderInspect'],
+ ['Action', 'Prerender Inspect'],
['Status', 'Speculative load is running.'],
]);
@@ -847,7 +847,7 @@
const values = getCleanTextContentFromElements(report, 'devtools-report-value');
assert.deepEqual(zip2(keys, values), [
['URL', 'https://example.com/prerendered.html'],
- ['Action', 'PrerenderInspect'],
+ ['Action', 'Prerender Inspect'],
['Status', 'Speculative load finished and the result is ready for the next navigation.'],
]);
@@ -926,7 +926,7 @@
const values = getCleanTextContentFromElements(report, 'devtools-report-value');
assert.deepEqual(zip2(keys, values), [
['URL', 'https://example.com/prerendered.html'],
- ['Action', 'PrerenderInspect'],
+ ['Action', 'Prerender Inspect'],
['Status', 'Speculative load failed.'],
[
'Failure reason',
diff --git a/front_end/panels/network/components/HeaderSectionRow.test.ts b/front_end/panels/network/components/HeaderSectionRow.test.ts
index d75ea9b..73f6b4d 100644
--- a/front_end/panels/network/components/HeaderSectionRow.test.ts
+++ b/front_end/panels/network/components/HeaderSectionRow.test.ts
@@ -121,10 +121,10 @@
assert.strictEqual(
getCleanTextContentFromElements(component.shadowRoot, '.call-to-action')[0],
'To use this resource from a different origin, the server needs to specify a cross-origin ' +
- 'resource policy in the response headers:Cross-Origin-Resource-Policy: same-siteChoose ' +
- 'this option if the resource and the document are served from the same site.' +
- 'Cross-Origin-Resource-Policy: cross-originOnly choose this option if an arbitrary website ' +
- 'including this resource does not impose a security risk.Learn more',
+ 'resource policy in the response headers: Cross-Origin-Resource-Policy: same-site Choose ' +
+ 'this option if the resource and the document are served from the same site. ' +
+ 'Cross-Origin-Resource-Policy: cross-origin Only choose this option if an arbitrary website ' +
+ 'including this resource does not impose a security risk. Learn more',
);
});
@@ -150,7 +150,7 @@
assert.strictEqual(
getCleanTextContentFromElements(component.shadowRoot, '.header-value code')[0],
- 'message ClientVariations {// Active Google-visible variation IDs on this client. These are reported for analysis, but do not directly affect any server-side behavior.repeated int32 variation_id = [3300118, 3300132, 3330195];\n}',
+ 'message ClientVariations { // Active Google-visible variation IDs on this client. These are reported for analysis, but do not directly affect any server-side behavior. repeated int32 variation_id = [3300118, 3300132, 3330195];\n}',
);
});
diff --git a/front_end/panels/network/components/ResponseHeaderSection.test.ts b/front_end/panels/network/components/ResponseHeaderSection.test.ts
index ab64f59..46d377e 100644
--- a/front_end/panels/network/components/ResponseHeaderSection.test.ts
+++ b/front_end/panels/network/components/ResponseHeaderSection.test.ts
@@ -207,10 +207,10 @@
assert.strictEqual(
getCleanTextContentFromElements(row.shadowRoot, '.call-to-action')[0],
'To use this resource from a different origin, the server needs to specify a cross-origin ' +
- 'resource policy in the response headers:Cross-Origin-Resource-Policy: same-siteChoose ' +
- 'this option if the resource and the document are served from the same site.' +
- 'Cross-Origin-Resource-Policy: cross-originOnly choose this option if an arbitrary website ' +
- 'including this resource does not impose a security risk.Learn more',
+ 'resource policy in the response headers: Cross-Origin-Resource-Policy: same-site Choose ' +
+ 'this option if the resource and the document are served from the same site. ' +
+ 'Cross-Origin-Resource-Policy: cross-origin Only choose this option if an arbitrary website ' +
+ 'including this resource does not impose a security risk. Learn more',
);
});
@@ -1364,6 +1364,6 @@
assert.isNotNull(rows[0].shadowRoot);
checkRow(rows[0].shadowRoot, 'abc:', 'def', false);
assert.isNotNull(rows[1].shadowRoot);
- checkRow(rows[1].shadowRoot, 'not-setcross-origin-embedder-policy:', '', false);
+ checkRow(rows[1].shadowRoot, 'not-set cross-origin-embedder-policy:', '', false);
});
});
diff --git a/front_end/testing/DOMHelpers.ts b/front_end/testing/DOMHelpers.ts
index 72d9a85..a99e78d 100644
--- a/front_end/testing/DOMHelpers.ts
+++ b/front_end/testing/DOMHelpers.ts
@@ -258,7 +258,7 @@
export function getCleanTextContentFromElements(el: ShadowRoot|HTMLElement, selector: string): string[] {
const elements = Array.from(el.querySelectorAll(selector));
return elements.map(element => {
- return element.textContent ? element.textContent.trim().replace(/[ \n]{2,}/g, '') : '';
+ return element.textContent ? element.textContent.trim().replace(/[ \n]{2,}/g, ' ') : '';
});
}