mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 04:26:32 +08:00
This is a reland of crrev.com/c/2959898 which caused the roll to fail. This has been fixed by updating expectations in `front_end/Tests.js` Original change's description: > Improve Console display of strings > > We recently changed how we display the output to ensure that we always > display valid JavaScript literals. Unfortunately, the current solution > can be confusing to users, who might feel that the amount of escaping is > excessive and makes the output unreadable. > > This change introduces `formatAsJSLiteral` that given a string escapes > appropriate special characters and wraps the string in either single > quotes, double quotes, or back ticks depending on the string content. > The function furthermore escapes script tags to ensure that the result > can be safely copied to HTML. > > Both regular Console output and preview have been updated to use this > formatter instead of JSON.stringify for displaying strings. > > This change adds unit tests for the new formatter and rebaselines all > e2e tests that depend on Console outputs. > > Doc: https://goo.gle/devtools-strings > Bug: 1208389 > Change-Id: Iebfe39c2e40c21aa5a813a1ebd26a5109fa59ab6 > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2959898 > Commit-Queue: Johan Bay <jobay@chromium.org> > Reviewed-by: Mathias Bynens <mathias@chromium.org> > Reviewed-by: Changhao Han <changhaohan@chromium.org> Bug: 1208389 Change-Id: I6f443e65364d9707d02aeaab0227bd691300b417 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2978351 Reviewed-by: Alex Rudenko <alexrudenko@chromium.org> Reviewed-by: Mathias Bynens <mathias@chromium.org> Commit-Queue: Johan Bay <jobay@chromium.org>
59 lines
1.9 KiB
TypeScript
59 lines
1.9 KiB
TypeScript
// Copyright 2020 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import {assert} from 'chai';
|
|
|
|
import {click, getBrowserAndPages, pasteText, step} from '../../shared/helper.js';
|
|
import {describe, it} from '../../shared/mocha-extensions.js';
|
|
import {CONSOLE_TAB_SELECTOR, focusConsolePrompt} from '../helpers/console-helpers.js';
|
|
import {getCurrentConsoleMessages} from '../helpers/console-helpers.js';
|
|
|
|
describe('The Console Tab', async () => {
|
|
it('interacts with the global scope correctly', async () => {
|
|
const {frontend} = getBrowserAndPages();
|
|
|
|
await step('navigate to the Console tab', async () => {
|
|
await click(CONSOLE_TAB_SELECTOR);
|
|
await focusConsolePrompt();
|
|
});
|
|
|
|
await step('enter code that implicitly creates global properties', async () => {
|
|
await pasteText(`
|
|
var foo = 'fooValue';
|
|
var bar = {
|
|
a: 'b',
|
|
};
|
|
`);
|
|
await frontend.keyboard.press('Enter');
|
|
|
|
// Wait for the console to be usable again.
|
|
await frontend.waitForFunction(() => {
|
|
return document.querySelectorAll('.console-user-command-result').length === 1;
|
|
});
|
|
});
|
|
|
|
await step('enter code that references the created bindings', async () => {
|
|
await pasteText('foo;');
|
|
await frontend.keyboard.press('Enter');
|
|
|
|
// Wait for the console to be usable again.
|
|
await frontend.waitForFunction(() => {
|
|
return document.querySelectorAll('.console-user-command-result').length === 1;
|
|
});
|
|
|
|
await pasteText('bar;');
|
|
await frontend.keyboard.press('Enter');
|
|
});
|
|
|
|
await step('check that the expected output is logged', async () => {
|
|
const messages = await getCurrentConsoleMessages();
|
|
assert.deepEqual(messages, [
|
|
'undefined',
|
|
'\'fooValue\'',
|
|
'{a: \'b\'}',
|
|
]);
|
|
});
|
|
});
|
|
});
|