Skip to content

Commit ded909c

Browse files
authored
chrome: restore colors enabled/levels logic (#34767)
1 parent 3d760b6 commit ded909c

File tree

15 files changed

+75
-65
lines changed

15 files changed

+75
-65
lines changed

packages/playwright-core/ThirdPartyNotices.txt

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This project incorporates components from the projects listed below. The origina
1111
- [email protected] (https://github.com/juliangruber/brace-expansion)
1212
- [email protected] (https://github.com/brianloveswords/buffer-crc32)
1313
- [email protected] (https://github.com/codemirror/CodeMirror)
14+
- [email protected] (https://github.com/Marak/colors.js)
1415
- [email protected] (https://github.com/tj/commander.js)
1516
- [email protected] (https://github.com/substack/node-concat-map)
1617
- [email protected] (https://github.com/debug-js/debug)
@@ -354,6 +355,36 @@ THE SOFTWARE.
354355
=========================================
355356
END OF [email protected] AND INFORMATION
356357

358+
%% [email protected] NOTICES AND INFORMATION BEGIN HERE
359+
=========================================
360+
MIT License
361+
362+
Original Library
363+
- Copyright (c) Marak Squires
364+
365+
Additional Functionality
366+
- Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
367+
368+
Permission is hereby granted, free of charge, to any person obtaining a copy
369+
of this software and associated documentation files (the "Software"), to deal
370+
in the Software without restriction, including without limitation the rights
371+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
372+
copies of the Software, and to permit persons to whom the Software is
373+
furnished to do so, subject to the following conditions:
374+
375+
The above copyright notice and this permission notice shall be included in
376+
all copies or substantial portions of the Software.
377+
378+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
379+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
380+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
381+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
382+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
383+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
384+
THE SOFTWARE.
385+
=========================================
386+
END OF [email protected] AND INFORMATION
387+
357388
%% [email protected] NOTICES AND INFORMATION BEGIN HERE
358389
=========================================
359390
(The MIT License)
@@ -1524,6 +1555,6 @@ END OF [email protected] AND INFORMATION
15241555

15251556
SUMMARY BEGIN HERE
15261557
=========================================
1527-
Total Packages: 45
1558+
Total Packages: 46
15281559
=========================================
15291560
END OF SUMMARY

packages/playwright-core/bundles/utils/package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/playwright-core/bundles/utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"generate-license": "node ../../../../utils/generate_third_party_notice.js"
1010
},
1111
"dependencies": {
12+
"colors": "1.4.0",
1213
"commander": "8.3.0",
1314
"debug": "^4.3.4",
1415
"diff": "^7.0.0",

packages/playwright-core/bundles/utils/src/utilsBundleImpl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
/* eslint-disable import/order */
1818

19+
import colorsLibrary from 'colors/safe';
20+
export const colors = colorsLibrary;
21+
1922
import debugLibrary from 'debug';
2023
export const debug = debugLibrary;
2124

packages/playwright-core/src/client/connection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export class Connection extends EventEmitter {
166166
this._callbacks.delete(id);
167167
if (error && !result) {
168168
const parsedError = parseError(error);
169-
rewriteErrorMessage(parsedError, parsedError.message + formatCallLog(log));
169+
rewriteErrorMessage(parsedError, parsedError.message + formatCallLog(this.platform, log));
170170
callback.reject(parsedError);
171171
} else {
172172
const validator = findValidator(callback.type, callback.method, 'Result');

packages/playwright-core/src/common/platform.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ import * as crypto from 'crypto';
1818
import * as fs from 'fs';
1919
import * as path from 'path';
2020

21+
import { webColors, noColors } from '../utils/isomorphic/colors';
22+
23+
import type { Colors } from '../utils/isomorphic/colors';
24+
25+
2126
export type Platform = {
2227
calculateSha1(text: string): Promise<string>;
28+
colors: Colors;
2329
createGuid: () => string;
2430
fs: () => typeof fs;
2531
inspectCustom: symbol | undefined;
@@ -37,6 +43,8 @@ export const webPlatform: Platform = {
3743
return Array.from(new Uint8Array(hashBuffer), b => b.toString(16).padStart(2, '0')).join('');
3844
},
3945

46+
colors: webColors,
47+
4048
createGuid: () => {
4149
return Array.from(crypto.getRandomValues(new Uint8Array(16)), b => b.toString(16).padStart(2, '0')).join('');
4250
},
@@ -68,6 +76,8 @@ export const emptyPlatform: Platform = {
6876
throw new Error('Not implemented');
6977
},
7078

79+
colors: noColors,
80+
7181
createGuid: () => {
7282
throw new Error('Not implemented');
7383
},

packages/playwright-core/src/server/registry/browserFetcher.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ import * as path from 'path';
2323
import { debugLogger } from '../utils/debugLogger';
2424
import { ManualPromise } from '../../utils/isomorphic/manualPromise';
2525
import { getUserAgent } from '../utils/userAgent';
26-
import { progress as ProgressBar } from '../../utilsBundle';
27-
import { colors } from '../../utils/isomorphic/colors';
26+
import { progress as ProgressBar, colors } from '../../utilsBundle';
2827
import { existsAsync } from '../utils/fileUtils';
2928

3029
import { browserDirectoryToMarkerFilePath } from '.';

packages/playwright-core/src/server/utils/comparators.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import { compare } from './image_tools/compare';
1919
// @ts-ignore
2020
import pixelmatch from '../../third_party/pixelmatch';
2121
import { jpegjs } from '../../utilsBundle';
22-
import { colors } from '../../utils/isomorphic/colors';
23-
import { diff } from '../../utilsBundle';
22+
import { colors, diff } from '../../utilsBundle';
2423
import { PNG } from '../../utilsBundle';
2524

2625
export type ImageComparatorOptions = { threshold?: number, maxDiffPixels?: number, maxDiffPixelRatio?: number, comparator?: string };

packages/playwright-core/src/server/utils/nodePlatform.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import * as fs from 'fs';
1919
import * as path from 'path';
2020
import * as util from 'util';
2121

22+
import { colors } from '../../utilsBundle';
2223
import { Platform } from '../../common/platform';
2324
import { debugLogger } from './debugLogger';
2425

@@ -29,6 +30,8 @@ export const nodePlatform: Platform = {
2930
return Promise.resolve(sha1.digest('hex'));
3031
},
3132

33+
colors,
34+
3235
createGuid: () => crypto.randomBytes(16).toString('hex'),
3336

3437
fs: () => fs,

packages/playwright-core/src/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ export * from './server/utils/fileUtils';
4444
export * from './server/utils/hostPlatform';
4545
export * from './server/utils/httpServer';
4646
export * from './server/utils/network';
47+
export * from './server/utils/nodePlatform';
4748
export * from './server/utils/processLauncher';
4849
export * from './server/utils/profiler';
4950
export * from './server/utils/socksProxy';
5051
export * from './server/utils/spawnAsync';
5152
export * from './server/utils/userAgent';
5253
export * from './server/utils/wsServer';
54+
55+
export { colors } from './utilsBundle';

0 commit comments

Comments
 (0)