diff --git a/package.json b/package.json index 45beb98b7b1..58fca530ff5 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "@types/applicationinsights": "0.20.0", "@types/chokidar": "2.1.3", "@types/cookie": "^0.3.3", + "@types/debug": "^4.1.5", "@types/graceful-fs": "4.1.2", "@types/http-proxy-agent": "^2.0.1", "@types/iconv-lite": "0.0.1", diff --git a/src/vs/workbench/browser/parts/editor/editorStatus.ts b/src/vs/workbench/browser/parts/editor/editorStatus.ts index 222b2dd0fa4..be64e082104 100644 --- a/src/vs/workbench/browser/parts/editor/editorStatus.ts +++ b/src/vs/workbench/browser/parts/editor/editorStatus.ts @@ -51,7 +51,7 @@ import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; import { IStatusbarEntryAccessor, IStatusbarService, StatusbarAlignment, IStatusbarEntry } from 'vs/workbench/services/statusbar/common/statusbar'; import { IMarker, IMarkerService, MarkerSeverity, IMarkerData } from 'vs/platform/markers/common/markers'; import { find } from 'vs/base/common/arrays'; -import { STATUS_BAR_PROMINENT_ITEM_BACKGROUND } from 'vs/workbench/common/theme'; +import { STATUS_BAR_PROMINENT_ITEM_BACKGROUND, STATUS_BAR_PROMINENT_ITEM_FOREGROUND } from 'vs/workbench/common/theme'; import { themeColorFromId } from 'vs/platform/theme/common/themeService'; class SideBySideEditorEncodingSupport implements IEncodingSupport { @@ -390,7 +390,8 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution { text: nls.localize('tabFocusModeEnabled', "Tab Moves Focus"), tooltip: nls.localize('disableTabMode', "Disable Accessibility Mode"), command: 'editor.action.toggleTabFocusMode', - backgroundColor: themeColorFromId(STATUS_BAR_PROMINENT_ITEM_BACKGROUND) + backgroundColor: themeColorFromId(STATUS_BAR_PROMINENT_ITEM_BACKGROUND), + color: themeColorFromId(STATUS_BAR_PROMINENT_ITEM_FOREGROUND) }, 'status.editor.tabFocusMode', nls.localize('status.editor.tabFocusMode', "Accessibility Mode"), StatusbarAlignment.RIGHT, 100.7); } } else { @@ -405,7 +406,8 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution { text: nls.localize('screenReaderDetected', "Screen Reader Optimized"), tooltip: nls.localize('screenReaderDetectedExtra', "If you are not using a Screen Reader, please change the setting `editor.accessibilitySupport` to \"off\"."), command: 'showEditorScreenReaderNotification', - backgroundColor: themeColorFromId(STATUS_BAR_PROMINENT_ITEM_BACKGROUND) + backgroundColor: themeColorFromId(STATUS_BAR_PROMINENT_ITEM_BACKGROUND), + color: themeColorFromId(STATUS_BAR_PROMINENT_ITEM_FOREGROUND) }, 'status.editor.screenReaderMode', nls.localize('status.editor.screenReaderMode', "Screen Reader Mode"), StatusbarAlignment.RIGHT, 100.6); } } else { diff --git a/src/vs/workbench/contrib/files/browser/views/explorerView.ts b/src/vs/workbench/contrib/files/browser/views/explorerView.ts index 059dfa3fa4a..15d007d7334 100644 --- a/src/vs/workbench/contrib/files/browser/views/explorerView.ts +++ b/src/vs/workbench/contrib/files/browser/views/explorerView.ts @@ -327,16 +327,8 @@ export class ExplorerView extends ViewPane { this.tree.domFocus(); const focused = this.tree.getFocus(); - if (focused.length === 1) { - if (this.autoReveal) { - this.tree.reveal(focused[0], 0.5); - } - - const activeFile = this.getActiveFile(); - if (!activeFile && !focused[0].isDirectory) { - // Open the focused element in the editor if there is currently no file opened #67708 - this.editorService.openEditor({ resource: focused[0].resource, options: { preserveFocus: true, revealIfVisible: true } }); - } + if (focused.length === 1 && this.autoReveal) { + this.tree.reveal(focused[0], 0.5); } } diff --git a/test/integration/browser/index.js b/test/integration/browser/index.js new file mode 100644 index 00000000000..17508685fcb --- /dev/null +++ b/test/integration/browser/index.js @@ -0,0 +1,107 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +//@ts-check + +const path = require('path'); +const cp = require('child_process'); +const playwright = require('playwright'); +const url = require('url'); + +// opts +const optimist = require('optimist') + .describe('debug', 'do not run browsers headless').boolean('debug') + .describe('browser', 'browser in which integration tests should run').string('browser').default('browser', 'chromium') + .describe('help', 'show the help').alias('help', 'h'); + +// logic +const argv = optimist.argv; + +let serverProcess; + +function teardownServer() { + if (serverProcess) { + serverProcess.kill(); + serverProcess = undefined; + } +} + +/** + * @param {string} browserType + * @param {string} endpoint + */ +async function runTestsInBrowser(browserType, endpoint) { + const browser = await playwright[browserType].launch({ headless: !Boolean(argv.debug) }); + const page = (await browser.defaultContext().pages())[0]; + + const integrationTestsPath = path.join(__dirname, '..', '..', '..', 'extensions', 'vscode-api-tests'); + const testWorkspaceUri = url.format({ pathname: path.join(integrationTestsPath, 'testWorkspace'), protocol: 'vscode-remote:', slashes: true, host: 'localhost:9888' }); + const testExtensionUri = url.format({ pathname: path.join(integrationTestsPath), protocol: 'vscode-remote:', slashes: true, host: 'localhost:9888' }); + const testFilesUri = url.format({ pathname: path.join(integrationTestsPath, 'out', 'singlefolder-tests'), protocol: 'vscode-remote:', slashes: true, host: 'localhost:9888' }); + + const folderParam = testWorkspaceUri; + const payloadParam = `[["extensionDevelopmentPath","${testExtensionUri}"],["extensionTestsPath","${testFilesUri}"]]`; + + await page.goto(`${endpoint}&folder=${folderParam}&payload=${payloadParam}`); + + // const emitter = new events.EventEmitter(); + // await page.exposeFunction('mocha_report', (type, data1, data2) => { + // emitter.emit(type, data1, data2) + // }); + + page.on('console', async msg => { + const msgText = msg.text(); + console[msg.type()](msgText, await Promise.all(msg.args().map(async arg => await arg.jsonValue()))); + + if (msgText.indexOf('vscode:exit') >= 0) { + browser.close(); + teardownServer(); + setTimeout(() => process.exit(msgText === 'vscode:exit 0' ? 0 : 1), 10); + } + }); +} + +async function launch() { + // workspacePath = _workspacePath; + // const agentFolder = userDataDir; + // await promisify(mkdir)(agentFolder); + const env = { + // VSCODE_AGENT_FOLDER: agentFolder, + ...process.env + }; + + let serverLocation; + if (process.env.VSCODE_REMOTE_SERVER_PATH) { + serverLocation = path.join(process.env.VSCODE_REMOTE_SERVER_PATH, `server.${process.platform === 'win32' ? 'cmd' : 'sh'}`); + } else { + serverLocation = path.join(__dirname, '..', '..', '..', `resources/server/web.${process.platform === 'win32' ? 'bat' : 'sh'}`); + } + + serverProcess = cp.spawn( + serverLocation, + ['--browser', 'none', '--driver', 'web'], + { env } + ); + + serverProcess.stderr.on('data', e => console.log('Server stderr: ' + e)); + serverProcess.stdout.on('data', e => console.log('Server stdout: ' + e)); + + process.on('exit', teardownServer); + process.on('SIGINT', teardownServer); + process.on('SIGTERM', teardownServer); + + return new Promise(r => { + serverProcess.stdout.on('data', d => { + const matches = d.toString('ascii').match(/Web UI available at (.+)/); + if (matches !== null) { + r(matches[1]); + } + }); + }); +} + +launch().then(async endpoint => { + return runTestsInBrowser(argv.browser, endpoint); +}, console.error); diff --git a/yarn.lock b/yarn.lock index f1b6f256d46..496cddcf29b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -198,6 +198,11 @@ resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.3.3.tgz#85bc74ba782fb7aa3a514d11767832b0e3bc6803" integrity sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow== +"@types/debug@^4.1.5": + version "4.1.5" + resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd" + integrity sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ== + "@types/eslint-visitor-keys@^1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"