From 506d22ce05b54bf68dff0210f87fc837a60e5e2e Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 10 Nov 2016 10:03:57 +0100 Subject: [PATCH] fixes #15263 --- build/gulpfile.hygiene.js | 3 +- .../parts/tree/test/browser/treeModel.test.ts | 4 +- .../tree/test/browser/treeViewModel.test.ts | 3 - src/vs/base/test/browser/builder.test.ts | 290 ------------------ src/vs/base/test/browser/htmlContent.test.ts | 10 +- src/vs/base/test/common/json.test.ts | 63 ++-- src/vs/base/test/common/jsonEdit.test.ts | 11 +- src/vs/base/test/common/jsonFormatter.test.ts | 2 +- .../characterHardWrappingLineMapper.test.ts | 15 +- .../electron-browser/terminalService.test.ts | 38 +-- .../terminal/test/terminalInstance.test.ts | 25 +- 11 files changed, 71 insertions(+), 393 deletions(-) diff --git a/build/gulpfile.hygiene.js b/build/gulpfile.hygiene.js index fc7d78fcf34..e1ebc5adafc 100644 --- a/build/gulpfile.hygiene.js +++ b/build/gulpfile.hygiene.js @@ -84,10 +84,9 @@ const tslintFilter = [ 'extensions/**/*.ts', '!**/*.d.ts', '!**/typings/**', - '!src/vs/base/**/*.test.ts', + '!**/node_modules/**', '!extensions/typescript/test/colorize-fixtures/**', '!extensions/vscode-api-tests/testWorkspace/**', - '!src/vs/workbench/**/*.test.ts', '!extensions/**/*.test.ts' ]; diff --git a/src/vs/base/parts/tree/test/browser/treeModel.test.ts b/src/vs/base/parts/tree/test/browser/treeModel.test.ts index aad5d56d60b..498d19e65be 100644 --- a/src/vs/base/parts/tree/test/browser/treeModel.test.ts +++ b/src/vs/base/parts/tree/test/browser/treeModel.test.ts @@ -78,7 +78,9 @@ class EventCounter { public listen(emitter: ee.IEventEmitter, event: string, fn: (e) => void = null): () => void { let r = emitter.addListener2(event, (e) => { this._count++; - fn && fn(e); + if (fn) { + fn(e); + } }); this.listeners.push(r); diff --git a/src/vs/base/parts/tree/test/browser/treeViewModel.test.ts b/src/vs/base/parts/tree/test/browser/treeViewModel.test.ts index b7a6d37fcb0..7906b72e993 100644 --- a/src/vs/base/parts/tree/test/browser/treeViewModel.test.ts +++ b/src/vs/base/parts/tree/test/browser/treeViewModel.test.ts @@ -6,9 +6,6 @@ 'use strict'; import assert = require('assert'); -import WinJS = require('vs/base/common/winjs.base'); -import TreeView = require('vs/base/parts/tree/browser/treeView'); -import Tree = require('vs/base/parts/tree/browser/treeImpl'); import { ArrayIterator } from 'vs/base/common/iterator'; import { HeightMap, IViewItem } from 'vs/base/parts/tree/browser/treeViewModel'; diff --git a/src/vs/base/test/browser/builder.test.ts b/src/vs/base/test/browser/builder.test.ts index 99edaf9ab73..0b28530687c 100644 --- a/src/vs/base/test/browser/builder.test.ts +++ b/src/vs/base/test/browser/builder.test.ts @@ -1686,294 +1686,4 @@ suite('Builder', () => { assert.equal((obj.firstChild).tagName.toLowerCase(), 'span'); assert.equal((obj.firstChild).className, 'core'); }); - - var values: string[] = []; - values.push("\""); - values.push("'"); - values.push("%22"); - values.push("%27"); - values.push("\">"); - values.push("'>"); - values.push(">"); - values.push("\"%3E"); - values.push("'%3E"); - values.push("%3E"); - values.push("%22%3E"); - values.push("%27%3E"); - values.push("-->"); - values.push(""); - values.push(""); - values.push("\">"); - values.push("'>"); - values.push(""); - values.push("\">"); - values.push("'>"); - values.push("'>\">"); - values.push(""); - values.push("\">"); - values.push("'>"); - values.push("'>\">!-->"); - values.push(""); - values.push("\">"); - values.push("'>"); - values.push("'>\">!-->"); - values.push(""); - values.push("\">"); - values.push("'>"); - values.push(""); - values.push("\">"); - values.push("'>"); - values.push(""); - values.push(""); - values.push("<:>"); - values.push("a:href:protocols:clicklink"); - values.push("img:src:protocols:nothing"); - values.push("*:OnClick:scriptblock:fireevent"); - values.push("*:OnMouseover:scriptblock:fireevent"); - values.push("font-family:expression(alert())"); - values.push("background-position:expression(alert())"); - values.push(";left:expression(alert());"); - values.push("width:%20expre/******/ssion(alert())"); - values.push("http://ABCD'%20style='w:expres/****/sion(alert())'%20foo=sjdkfjasf%FDa"); - values.push("http://ABCD\"%20style=\"w:expres/****/sion(alert())\"%20foo=sjdkfjasf%FDa"); - values.push("http://ABCD\" style=\"w:expres/****/sion(alert())\" foo=sjdkfjasf%u0192"); - values.push("http://ABCD' style='w:expres/****/sion(alert())' foo=sjdkfjasf%u0192"); - values.push("%26%2339;width:expression(alert());%26%2339;"); - values.push("%26%2339;width:expres/**/sion(alert());%26%2339;"); - values.push("%26%2334;width:expression(alert());%26%2334;"); - values.push("%26%2334;width:expres/**/sion(alert());%26%2334;"); - values.push("';width:expression(alert());'"); - values.push("';width:expres/**/sion(alert());'"); - values.push("\";width:expression(alert());\""); - values.push("\";width:expres/**/sion(alert());\""); - values.push("data:text/css;base64,Ym9keXt3OmV4cHJlcy8qKi9zaW9uKGFsZXJ0KCkpfQ=="); - values.push("stylesheet\"/href=\"data:text/css;base64,Ym9keXt3OmV4cHJlcy8qKi9zaW9uKGFsZXJ0KCkpfQ==\"/"); - values.push("stylesheet'/href='data:text/css;base64,Ym9keXt3OmV4cHJlcy8qKi9zaW9uKGFsZXJ0KCkpfQ=='/"); - values.push("
a
"); - values.push("background:expression(alert((parseInt('hi;width:')==NaN)?'':''));"); - values.push("background:expression(alert((parseInt(\"hi;width:\")==NaN)?\"\":\"\"));"); - values.push("http://foo.com/\"/style=\"w:expression(alert());//\"/\"http://foo.com/'/style='w:expression(alert());//'/'"); - values.push("http://foo.com/\" style=\"w:expression(alert());//\" \"http://foo.com/' style='w:expression(alert());//' '"); - values.push("\"\""); - values.push("\">'>"); - values.push("\">'>"); - values.push("'/stystyle=le='w:expres/**/sion(alert())'/'\"/stystyle=le=\"w:expres/**/sion(alert())\"/\""); - values.push("a stystyle=le=w:expres/**/sion(alert()) a"); - values.push("%27%3E%22%3E%21--%3E%3C/title%3E%3C/iframe%3E%3C/object%3E%3C/style%3E%3C/noscript%3E%3C/textarea%3E%3C/xmp%3E%3C/comment%3E%3C/xml%3E%3C/script/%3E%3Cscript/%3Ealert%28%29%3B%3C/script/%3E"); - values.push("%2527%253E%2522%253E%2521--%253E%253C/title%253E%253C/iframe%253E%253C/object%253E%253C/style%253E%253C/noscript%253E%253C/textarea%253E%253C/xmp%253E%253C/comment%253E%253C/xml%253E%253C/script/%253E%253Cscript/%253Ealert%2528%2529%253B%253C/script/%253E"); - values.push("'>\">!--><%ud91c/title><%ud91c/iframe><%ud91c/object><%ud91c/style><%ud91c/noscript><%ud91c/textarea><%ud91c/xmp><%ud91c/comment><%ud91c/xml><%ud91c/script/><%ud91cscript/>alert()<%ud91c/script/>"); - values.push("%uFF07%uFF1E%uFF1C%uFF0Ftitle%uFF1E%uFF1C%uFF0Fnoscr%uFF29pt%uFF1E%uFF1C%uFF0Fiframe%uFF1E%uFF1C%uFF0Fobject%uFF1E%uFF1C%uFF0Fstyle%uFF1E%uFF1C%uFF0Ftextarea%uFF1E%uFF1C%uFF0Fxmp%uFF1E%uFF1C%uFF0Fcomment%uFF1E%uFF1C%uFF0Fxml%uFF1E%uFF1C%uFF0Fscr%uFF29pt%uFF1E%uFF1Cscr%uFF29pt%uFF1Ealert%uFF08%uFF09%uFF1C%uFF0Fscr%uFF29pt%uFF1E"); - values.push("%uFF02%uFF1E%uFF1C%uFF0Ftitle%uFF1E%uFF1C%uFF0Fnoscr%uFF29pt%uFF1E%uFF1C%uFF0Fiframe%uFF1E%uFF1C%uFF0Fobject%uFF1E%uFF1C%uFF0Fstyle%uFF1E%uFF1C%uFF0Ftextarea%uFF1E%uFF1C%uFF0Fxmp%uFF1E%uFF1C%uFF0Fcomment%uFF1E%uFF1C%uFF0Fxml%uFF1E%uFF1C%uFF0Fscr%uFF29pt%uFF1E%uFF1Cscr%uFF29pt%uFF1Ealert%uFF08%uFF09%uFF1C%uFF0Fscr%uFF29pt%uFF1E"); - values.push("hi&__xssprobe='>\">!-->"); - values.push("hi&__xssprobe='>\">!-->"); - values.push("hi&foo'>\">!-->=bar"); - values.push("hi&foo'>\">!-->=bar"); - values.push("%u0027%u003E%u0022%u003E%u0021--%u003E%u003C/title%u003E%u003C/iframe%u003E%u003C/object%u003E%u003C/style%u003E%u003C/noscript%u003E%u003C/textarea%u003E%u003C/xmp%u003E%u003C/comment%u003E%u003C/xml%u003E%u003C/script/%u003E%u003Cscript/%u003Ealert%u0028%u0029%u003B%u003C/script/%u003E"); - values.push("ZZ ADw-/script AD4APA-script AD4-alert() ADw-/script AD4-ZZ"); - values.push("}body{w:expres/**/sion(alert())}/*"); - values.push("or6nvqGtrb68r/Pj8unw9K++vPPj8unw9K++4ezl8vSoqbyv8+Py6fD0r74="); - values.push("'>\">!-->////////"); - values.push("'>\">!-->"); - values.push("foo.htm?'>\">!-->"); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push("'>"); - values.push("\">"); - values.push("'>"); - values.push("\">"); - values.push("onload=\"alert()\""); - values.push("onload='alert()'"); - values.push("onload=alert()"); - values.push(""); - values.push(""); - values.push("-->"); - values.push("!-->"); - values.push("javascript:alert();"); - values.push("

"); - values.push("%2Beval(alert())%2B"); - values.push("'%2Beval(alert())%2B'"); - values.push("+eval(alert())+"); - values.push("'+eval(alert())+'"); - values.push("-eval(alert())-"); - values.push("'-eval(alert())-'"); - values.push("'*alert()*'"); - values.push("\'*alert()*\'"); - values.push("'+-alert()+-'"); - values.push(""); - values.push("\"/>"); - values.push("'/>"); - values.push(""); - values.push("!-->"); - values.push(""); - values.push(""); - values.push("+ADw-SCRIPT+AD4-alert();+ADw-/SCRIPT+AD4-"); - values.push("+ADw-/script+AD4APA-script+AD4-alert()+ADw-/script+AD4-"); - values.push("\">"); - values.push("javascript:alert()"); - values.push(""); - values.push("\""); - values.push("foo\r\n\r\n"); - values.push("foo\r\r"); - values.push("foo\n\n"); - values.push("foo%0D%0A%0D%0A"); - values.push("foo%0A%0A"); - values.push("foo%0D%0D"); - values.push("http://officesectest/tools/xssprobev2/pngexploit.jpg"); - values.push("http://officesectest/tools/xssprobev2/exploit.png"); - values.push("http://officesectest/tools/xssprobev2/exploit.swf"); - values.push("http://officesectest/tools/xssprobev2/exploit.js"); - values.push("http://officesectest/tools/xssprobev2/exploit.jpg"); - values.push("')*alert()*('"); - values.push("')-alert()-('"); - values.push("')-alert()-('var='"); - values.push("\')-alert()-(\'"); - values.push("\')-alert()-(\'var=\'"); - values.push("IgA+ACcAPgA8AF4BYwByAGkAcAB0AD4AYQBsAGUAcgB0ACgAKQA8AC8AXgFjAHIAaQBwAHQAPgA="); - values.push("JwA+ACIAPgAhAC0ALQA+ADwALwB0AGkAdABsAGUAPgA8AC8AaQBmAHIAYQBtAGUAPgA8AC8AbwBiAGoAZQBjAHQAPgA8AC8AcwB0AHkAbABlAD4APAAvAG4AbwBzAGMAcgBpAHAAdAA+ADwALwB0AGUAeAB0AGEAcgBlAGEAPgA8AC8AeABtAHAAPgA8AC8AYwBvAG0AbQBlAG4AdAA+ADwALwB4AG0AbAA+ADwALwBeAWMAcgBpAHAAdAAvAD4APABeAWMAcgBpAHAAdAA+AGEAbABlAHIAdAAoACkAPAAvAF4BYwByAGkAcAB0AD4A"); - values.push("IgA+ACcAPgA8AF4BLwBeAXQAeQBsAGUAPQB3ADoAZQB4AHAAcgBlAF4BXgFpAG8AbgAoAGEAbABlAHIAdAAoACkAKQA+AA=="); - values.push("YQAgAF4BdAB5AGwAZQA9AHcAOgBlAHgAcAByAGUAXgEvACoAKgAvAF4BaQBvAG4AKABhAGwAZQByAHQAKAApACkAIAAiAC8AXgF0AHkAbABlAD0AIgB3ADoAZQB4AHAAcgBlAF4BLwAqACoALwBeAWkAbwBuACgAYQBsAGUAcgB0ACgAKQApACIALwAiACAAJwAvAF4BdAB5AGwAZQA9ACcAdwA6AGUAeABwAHIAZQBeAS8AKgAqAC8AXgFpAG8AbgAoAGEAbABlAHIAdAAoACkAKQAnAC8AJwB6AA=="); - values.push(""); - values.push("'>\">!-->"); - values.push(""); - values.push("

test
"); - values.push("javas%09cript%u0024:alert()//"); - values.push("vbscr%09ipt%u0024:alert'"); - values.push("vb%09script:alert%27"); - values.push("java%09script:alert%25%32%38%25%32%39//"); - values.push("vbscript:alert'"); - values.push("javascript:alert()//"); - values.push("javascript:alert()"); - values.push("vbscript:msgbox(chr(0))"); - values.push("vbscript:alert"); - values.push("vbscript:alert()"); - values.push("vBsCrIpT:msGBOx(chr(0))"); - values.push("'javasc%09ript:alert()'"); - values.push("\"javascr%09ipt:alert()\""); - values.push("javascri%09pt:alert()"); - values.push("'javascript:alert()"); - values.push("'javascript:alert()'"); - values.push("\"javascript:alert()\""); - values.push("j&%23x41;vascript:alert()"); - values.push("alert()"); - values.push("alert();"); - values.push("')-alert()-('"); - values.push("'-alert()-'"); - values.push("%26%2339;*alert()*%26%2339;"); - values.push("%26%2334;*alert()*%26%2334;"); - values.push("\"-alert()-\""); - values.push("\")-alert()-(\""); - values.push("'-alert()-'"); - values.push("';}alert();{//"); - values.push("\";}alert();{//"); - values.push("\")}};alert();{{(\""); - values.push("')}};alert();{{('"); - values.push(")}};alert();{{("); - values.push("\")};alert();{(\""); - values.push("')};alert();{('"); - values.push(")};alert();{("); - values.push(";};alert();{//"); - values.push("alert()"); - values.push(";alert();//"); - values.push("alert();"); - values.push("alert();//"); - values.push("\";alert();//"); - values.push("';alert();//"); - values.push("\';alert();//"); - values.push("\\\"; alert(); //"); - values.push(""); - values.push("-->"); - values.push("value\";alert();var strHackz=\""); - values.push("value';alert();var strHackz='"); - values.push("value\";alert();//"); - values.push("value'alert();//"); - values.push("')-alert()-('"); - values.push("')-alert()-('var='"); - values.push("test\x22\x20style\x3d\x22w\x3Aexpres\x2F\x2A\x2A\x2A\x2A\x2A\x2A\x2Fsion\x28alert\x28\x29\x29\x3b"); - values.push("test\x27\x20style\x3d\x27w\x3Aexpres\x2F\x2A\x2A\x2A\x2A\x2A\x2A\x2Fsion\x28alert\x28\x29\x29\x3b"); - values.push("\x3Cbr\x20style\x3dw\x3Aexpres\x2F\x2A\x2A\x2A\x2A\x2A\x2A\x2Fsion\x28alert\x28\x29\x29\x3E"); - values.push("%26%2359alert%26%2340%26%2341%26%2359%26%2347%26%2347"); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push("
"); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push("
"); - values.push("
"); - values.push("
"); - values.push("
"); - values.push("
"); - values.push("
"); - values.push("
"); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push("

"); - values.push("

"); - values.push("

"); - values.push("-->"); - values.push("//-->"); - values.push(""); - values.push("PABeAWMAcgBpAHAAdAA+AGEAbABlAHIAdAAoACkAPAAvAF4BYwByAGkAcAB0AD4A"); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - values.push(""); - - test("XSS - safeInnerHtml()", () => { - var alert = window.alert; - var alertCount = 0; - window.alert = function () { - alertCount++; - }; - - values.forEach(function (value) { - var b = Build.withElementById(fixtureId); - b.empty(); - b.div().safeInnerHtml(value); - }); - - assert.strictEqual(alertCount, 0); - window.alert = alert; - }); }); \ No newline at end of file diff --git a/src/vs/base/test/browser/htmlContent.test.ts b/src/vs/base/test/browser/htmlContent.test.ts index 5a6b0e63239..eaa12a6ba26 100644 --- a/src/vs/base/test/browser/htmlContent.test.ts +++ b/src/vs/base/test/browser/htmlContent.test.ts @@ -158,7 +158,7 @@ suite('HtmlContent', () => { }); test('image rendering conforms to default', () => { const renderableContent = { - markdown: "![image](someimageurl 'caption')" + markdown: `![image](someimageurl 'caption')` }; const result: HTMLElement = renderHtml(renderableContent); const renderer = new marked.Renderer(); @@ -170,7 +170,7 @@ suite('HtmlContent', () => { }); test('image rendering conforms to default without title', () => { const renderableContent = { - markdown: "![image](someimageurl)" + markdown: `![image](someimageurl)` }; const result: HTMLElement = renderHtml(renderableContent); const renderer = new marked.Renderer(); @@ -182,19 +182,19 @@ suite('HtmlContent', () => { }); test('image width from title params', () => { var result: HTMLElement = renderHtml({ - markdown: "![image](someimageurl|width=100 'caption')" + markdown: `![image](someimageurl|width=100 'caption')` }); assert.strictEqual(result.innerHTML, `

image

`); }); test('image height from title params', () => { var result: HTMLElement = renderHtml({ - markdown: "![image](someimageurl|height=100 'caption')" + markdown: `![image](someimageurl|height=100 'caption')` }); assert.strictEqual(result.innerHTML, `

image

`); }); test('image width and height from title params', () => { var result: HTMLElement = renderHtml({ - markdown: "![image](someimageurl|height=200,width=100 'caption')" + markdown: `![image](someimageurl|height=200,width=100 'caption')` }); assert.strictEqual(result.innerHTML, `

image

`); }); diff --git a/src/vs/base/test/common/json.test.ts b/src/vs/base/test/common/json.test.ts index 784434e677c..a3b9e29cf23 100644 --- a/src/vs/base/test/common/json.test.ts +++ b/src/vs/base/test/common/json.test.ts @@ -51,7 +51,7 @@ function assertTree(input: string, expected: any): void { checkParent(child); } } - } + }; checkParent(actual); assert.deepEqual(actual, expected); @@ -64,7 +64,6 @@ function assertNodeAtLocation(input: Node, segments: Segment[], expected: any) { function assertLocation(input: string, expectedSegments: Segment[], expectedNodeType: string, expectedCompleteProperty: boolean): void { - var errors: { error: ParseErrorCode }[] = []; var offset = input.indexOf('|'); input = input.substring(0, offset) + input.substring(offset + 1, input.length); var actual = getLocation(input, offset); @@ -195,7 +194,7 @@ suite('JSON', () => { assertValidParse('{ "bar": 8, "xoo": "foo" }', { bar: 8, xoo: 'foo' }); assertValidParse('{ "hello": [], "world": {} }', { hello: [], world: {} }); assertValidParse('{ "a": false, "b": true, "c": [ 7.4 ] }', { a: false, b: true, c: [7.4] }); - assertValidParse('{ "lineComment": "//", "blockComment": ["/*", "*/"], "brackets": [ ["{", "}"], ["[", "]"], ["(", ")"] ] }', { lineComment: '//', blockComment: ["/*", "*/"], brackets: [["{", "}"], ["[", "]"], ["(", ")"]] }); + assertValidParse('{ "lineComment": "//", "blockComment": ["/*", "*/"], "brackets": [ ["{", "}"], ["[", "]"], ["(", ")"] ] }', { lineComment: '//', blockComment: ['/*', '*/'], brackets: [['{', '}'], ['[', ']'], ['(', ')']] }); assertValidParse('{ "hello": [], "world": {} }', { hello: [], world: {} }); assertValidParse('{ "hello": { "again": { "inside": 5 }, "world": 1 }}', { hello: { again: { inside: 5 }, world: 1 } }); assertValidParse('{ "foo": /*hello*/true }', { foo: true }); @@ -229,7 +228,7 @@ suite('JSON', () => { test('parse: disallow commments', () => { let options = { disallowComments: true }; - assertValidParse('[ 1, 2, null, "foo" ]', [1, 2, null, "foo"], options); + assertValidParse('[ 1, 2, null, "foo" ]', [1, 2, null, `foo`], options); assertValidParse('{ "hello": [], "world": {} }', { hello: [], world: {} }, options); assertInvalidParse('{ "foo": /*comment*/ true }', { foo: true }, options); @@ -238,30 +237,30 @@ suite('JSON', () => { test('location: properties', () => { assertLocation('|{ "foo": "bar" }', [], void 0, false); assertLocation('{| "foo": "bar" }', [], void 0, true); - assertLocation('{ |"foo": "bar" }', ["foo"], "property", true); - assertLocation('{ "foo|": "bar" }', ["foo"], "property", true); - assertLocation('{ "foo"|: "bar" }', ["foo"], "property", true); - assertLocation('{ "foo": "bar"| }', ["foo"], "string", false); - assertLocation('{ "foo":| "bar" }', ["foo"], void 0, false); - assertLocation('{ "foo": {"bar|": 1, "car": 2 } }', ["foo", "bar"], "property", true); - assertLocation('{ "foo": {"bar": 1|, "car": 3 } }', ["foo", "bar"], "number", false); - assertLocation('{ "foo": {"bar": 1,| "car": 4 } }', ["foo"], void 0, true); - assertLocation('{ "foo": {"bar": 1, "ca|r": 5 } }', ["foo", "car"], "property", true); - assertLocation('{ "foo": {"bar": 1, "car": 6| } }', ["foo", "car"], "number", false); - assertLocation('{ "foo": {"bar": 1, "car": 7 }| }', ["foo"], void 0, false); + assertLocation('{ |"foo": "bar" }', [`foo`], `property`, true); + assertLocation('{ "foo|": "bar" }', [`foo`], `property`, true); + assertLocation('{ "foo"|: "bar" }', [`foo`], `property`, true); + assertLocation('{ "foo": "bar"| }', [`foo`], `string`, false); + assertLocation('{ "foo":| "bar" }', [`foo`], void 0, false); + assertLocation('{ "foo": {"bar|": 1, "car": 2 } }', [`foo`, `bar`], `property`, true); + assertLocation('{ "foo": {"bar": 1|, "car": 3 } }', [`foo`, `bar`], `number`, false); + assertLocation('{ "foo": {"bar": 1,| "car": 4 } }', [`foo`], void 0, true); + assertLocation('{ "foo": {"bar": 1, "ca|r": 5 } }', [`foo`, `car`], `property`, true); + assertLocation('{ "foo": {"bar": 1, "car": 6| } }', [`foo`, `car`], `number`, false); + assertLocation('{ "foo": {"bar": 1, "car": 7 }| }', [`foo`], void 0, false); assertLocation('{ "foo": {"bar": 1, "car": 8 },| "goo": {} }', [], void 0, true); - assertLocation('{ "foo": {"bar": 1, "car": 9 }, "go|o": {} }', ["goo"], "property", true); - assertLocation('{ "dep": {"bar": 1, "car": |', ["dep", "car"], void 0, false); - assertLocation('{ "dep": {"bar": 1,, "car": |', ["dep", "car"], void 0, false); - assertLocation('{ "dep": {"bar": "na", "dar": "ma", "car": | } }', ["dep", "car"], void 0, false); + assertLocation('{ "foo": {"bar": 1, "car": 9 }, "go|o": {} }', [`goo`], `property`, true); + assertLocation('{ "dep": {"bar": 1, "car": |', [`dep`, `car`], void 0, false); + assertLocation('{ "dep": {"bar": 1,, "car": |', [`dep`, `car`], void 0, false); + assertLocation('{ "dep": {"bar": "na", "dar": "ma", "car": | } }', [`dep`, `car`], void 0, false); }); test('location: arrays', () => { assertLocation('|["foo", null ]', [], void 0, false); - assertLocation('[|"foo", null ]', [0], "string", false); - assertLocation('["foo"|, null ]', [0], "string", false); + assertLocation('[|"foo", null ]', [0], `string`, false); + assertLocation('["foo"|, null ]', [0], `string`, false); assertLocation('["foo",| null ]', [1], void 0, false); - assertLocation('["foo", |null ]', [1], "null", false); + assertLocation('["foo", |null ]', [1], `null`, false); assertLocation('["foo", null,| ]', [2], void 0, false); assertLocation('["foo", null,,| ]', [3], void 0, false); assertLocation('[["foo", null,, ],|', [1], void 0, false); @@ -331,15 +330,15 @@ suite('JSON', () => { test('tree: find location', () => { let root = parseTree('{ "key1": { "key11": [ "val111", "val112" ] }, "key2": [ { "key21": false, "key22": 221 }, null, [{}] ] }'); - assertNodeAtLocation(root, ["key1"], { key11: ['val111', 'val112'] }); - assertNodeAtLocation(root, ["key1", "key11"], ['val111', 'val112']); - assertNodeAtLocation(root, ["key1", "key11", 0], 'val111'); - assertNodeAtLocation(root, ["key1", "key11", 1], 'val112'); - assertNodeAtLocation(root, ["key1", "key11", 2], void 0); - assertNodeAtLocation(root, ["key2", 0, "key21"], false); - assertNodeAtLocation(root, ["key2", 0, "key22"], 221); - assertNodeAtLocation(root, ["key2", 1], null); - assertNodeAtLocation(root, ["key2", 2], [{}]); - assertNodeAtLocation(root, ["key2", 2, 0], {}); + assertNodeAtLocation(root, [`key1`], { key11: ['val111', 'val112'] }); + assertNodeAtLocation(root, [`key1`, `key11`], ['val111', 'val112']); + assertNodeAtLocation(root, [`key1`, `key11`, 0], 'val111'); + assertNodeAtLocation(root, [`key1`, `key11`, 1], 'val112'); + assertNodeAtLocation(root, [`key1`, `key11`, 2], void 0); + assertNodeAtLocation(root, [`key2`, 0, `key21`], false); + assertNodeAtLocation(root, [`key2`, 0, `key22`], 221); + assertNodeAtLocation(root, [`key2`, 1], null); + assertNodeAtLocation(root, [`key2`, 2], [{}]); + assertNodeAtLocation(root, [`key2`, 2, 0], {}); }); }); diff --git a/src/vs/base/test/common/jsonEdit.test.ts b/src/vs/base/test/common/jsonEdit.test.ts index 3eacab846a4..32f3d299dff 100644 --- a/src/vs/base/test/common/jsonEdit.test.ts +++ b/src/vs/base/test/common/jsonEdit.test.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import json = require('vs/base/common/json'); import { FormattingOptions, Edit } from 'vs/base/common/jsonFormatter'; import { setProperty, removeProperty } from 'vs/base/common/jsonEdit'; import assert = require('assert'); @@ -16,7 +15,7 @@ suite('JSON - edits', () => { let lastEditOffset = content.length; for (let i = edits.length - 1; i >= 0; i--) { let edit = edits[i]; - assert(edit.offset >= 0 && edit.length >= 0 && edit.offset + edit.length <= content.length) + assert(edit.offset >= 0 && edit.length >= 0 && edit.offset + edit.length <= content.length); assert(typeof edit.content === 'string'); assert(lastEditOffset >= edit.offset + edit.length); // make sure all edits are ordered lastEditOffset = edit.offset; @@ -29,7 +28,7 @@ suite('JSON - edits', () => { insertSpaces: true, tabSize: 2, eol: '\n' - } + }; test('set property', () => { let content = '{\n "x": "y"\n}'; @@ -42,18 +41,18 @@ suite('JSON - edits', () => { }); test('insert property', () => { - let content = "{}"; + let content = '{}'; let edits = setProperty(content, ['foo'], 'bar', formatterOptions); assertEdit(content, edits, '{\n "foo": "bar"\n}'); edits = setProperty(content, ['foo', 'foo2'], 'bar', formatterOptions); assertEdit(content, edits, '{\n "foo": {\n "foo2": "bar"\n }\n}'); - content = "{\n}"; + content = '{\n}'; edits = setProperty(content, ['foo'], 'bar', formatterOptions); assertEdit(content, edits, '{\n "foo": "bar"\n}'); - content = " {\n }"; + content = ' {\n }'; edits = setProperty(content, ['foo'], 'bar', formatterOptions); assertEdit(content, edits, ' {\n "foo": "bar"\n }'); diff --git a/src/vs/base/test/common/jsonFormatter.test.ts b/src/vs/base/test/common/jsonFormatter.test.ts index 1f493917b48..df717bf58c8 100644 --- a/src/vs/base/test/common/jsonFormatter.test.ts +++ b/src/vs/base/test/common/jsonFormatter.test.ts @@ -23,7 +23,7 @@ suite('JSON - formatter', () => { let lastEditOffset = content.length; for (let i = edits.length - 1; i >= 0; i--) { let edit = edits[i]; - assert(edit.offset >= 0 && edit.length >= 0 && edit.offset + edit.length <= content.length) + assert(edit.offset >= 0 && edit.length >= 0 && edit.offset + edit.length <= content.length); assert(typeof edit.content === 'string'); assert(lastEditOffset >= edit.offset + edit.length); // make sure all edits are ordered lastEditOffset = edit.offset; diff --git a/src/vs/editor/test/common/viewModel/characterHardWrappingLineMapper.test.ts b/src/vs/editor/test/common/viewModel/characterHardWrappingLineMapper.test.ts index a3096f212e1..47e7de315d4 100644 --- a/src/vs/editor/test/common/viewModel/characterHardWrappingLineMapper.test.ts +++ b/src/vs/editor/test/common/viewModel/characterHardWrappingLineMapper.test.ts @@ -7,7 +7,7 @@ import * as assert from 'assert'; import { WrappingIndent } from 'vs/editor/common/editorCommon'; import { CharacterHardWrappingLineMapperFactory } from 'vs/editor/common/viewModel/characterHardWrappingLineMapper'; -import { ILineMapperFactory, ILineMapping, OutputPosition } from 'vs/editor/common/viewModel/splitLinesCollection'; +import { ILineMapperFactory } from 'vs/editor/common/viewModel/splitLinesCollection'; function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAfter: number, annotatedText: string, wrappingIndent = WrappingIndent.None) { @@ -44,8 +44,8 @@ function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAf assert.equal(actualAnnotatedText, annotatedText); } -suite('CharacterHardWrappingLineMapper', () => { - test('latin text', () => { +suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => { + test('CharacterHardWrappingLineMapper', () => { let factory = new CharacterHardWrappingLineMapperFactory('(', ')', '.'); @@ -87,7 +87,7 @@ suite('CharacterHardWrappingLineMapper', () => { assertLineMapping(factory, 4, 5, 'aa.|(.)|.aaa'); }); - test('CJK and Kinsoku Shori', () => { + test('CharacterHardWrappingLineMapper - CJK and Kinsoku Shori', () => { let factory = new CharacterHardWrappingLineMapperFactory('(', ')', '.'); assertLineMapping(factory, 4, 5, 'aa \u5b89|\u5b89'); assertLineMapping(factory, 4, 5, '\u3042 \u5b89|\u5b89'); @@ -97,13 +97,8 @@ suite('CharacterHardWrappingLineMapper', () => { assertLineMapping(factory, 4, 5, 'aa |(\u5b89aa|\u5b89'); }); - test('WrappingIndent.Same', () => { + test('CharacterHardWrappingLineMapper - WrappingIndent.Same', () => { let factory = new CharacterHardWrappingLineMapperFactory('', ' ', ''); assertLineMapping(factory, 4, 38, ' *123456789012345678901234567890123456|7890', WrappingIndent.Same); }); - - test('CJK and WrappingIndent.Same', () => { - let factory = new CharacterHardWrappingLineMapperFactory('', ' ', ''); - assertLineMapping(factory, 4, 30, ' 协和飞机共生产了20|架,其中仅有16架投|入营运。巨大的资金', WrappingIndent.Same); - }); }); diff --git a/src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts b/src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts index a9103b2898e..cc1d04947a3 100644 --- a/src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts +++ b/src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts @@ -28,19 +28,19 @@ suite('Execution - TerminalService', () => { mockOnError = e => e; }); - test("WinTerminalService - uses terminal from configuration", done => { + test(`WinTerminalService - uses terminal from configuration`, done => { let testShell = 'cmd'; let testCwd = 'path/to/workspace'; let mockSpawner = { spawn: (command, args, opts) => { // assert equal(command, testShell, 'shell should equal expected'); - equal(args[args.length - 1], mockConfig.terminal.external.windowsExec, 'terminal should equal expected') + equal(args[args.length - 1], mockConfig.terminal.external.windowsExec, 'terminal should equal expected'); equal(opts.cwd, testCwd, 'opts.cwd should equal expected'); done(); return { on: (evt) => evt - } + }; } }; let testService = new WinTerminalService(mockConfig); @@ -54,17 +54,17 @@ suite('Execution - TerminalService', () => { ); }); - test("WinTerminalService - uses default terminal when configuration.terminal.external.windowsExec is undefined", done => { + test(`WinTerminalService - uses default terminal when configuration.terminal.external.windowsExec is undefined`, done => { let testShell = 'cmd'; let testCwd = 'path/to/workspace'; let mockSpawner = { spawn: (command, args, opts) => { // assert - equal(args[args.length - 1], DEFAULT_TERMINAL_WINDOWS, 'terminal should equal expected') + equal(args[args.length - 1], DEFAULT_TERMINAL_WINDOWS, 'terminal should equal expected'); done(); return { on: (evt) => evt - } + }; } }; mockConfig.terminal.external.windowsExec = undefined; @@ -79,7 +79,7 @@ suite('Execution - TerminalService', () => { ); }); - test("WinTerminalService - uses default terminal when configuration.terminal.external.windowsExec is undefined", done => { + test(`WinTerminalService - uses default terminal when configuration.terminal.external.windowsExec is undefined`, done => { let testShell = 'cmd'; let testCwd = 'c:/foo'; let mockSpawner = { @@ -89,7 +89,7 @@ suite('Execution - TerminalService', () => { done(); return { on: (evt) => evt - } + }; } }; let testService = new WinTerminalService(mockConfig); @@ -103,7 +103,7 @@ suite('Execution - TerminalService', () => { ); }); - test("WinTerminalService - cmder should be spawned differently", done => { + test(`WinTerminalService - cmder should be spawned differently`, done => { let testShell = 'cmd'; mockConfig.terminal.external.windowsExec = 'cmder'; let testCwd = 'c:/foo'; @@ -127,7 +127,7 @@ suite('Execution - TerminalService', () => { ); }); - test("MacTerminalService - uses terminal from configuration", done => { + test(`MacTerminalService - uses terminal from configuration`, done => { let testCwd = 'path/to/workspace'; let mockSpawner = { spawn: (command, args, opts) => { @@ -136,7 +136,7 @@ suite('Execution - TerminalService', () => { done(); return { on: (evt) => evt - } + }; } }; let testService = new MacTerminalService(mockConfig); @@ -149,16 +149,16 @@ suite('Execution - TerminalService', () => { ); }); - test("MacTerminalService - uses default terminal when configuration.terminal.external.osxExec is undefined", done => { + test(`MacTerminalService - uses default terminal when configuration.terminal.external.osxExec is undefined`, done => { let testCwd = 'path/to/workspace'; let mockSpawner = { spawn: (command, args, opts) => { // assert - equal(args[1], DEFAULT_TERMINAL_OSX, 'terminal should equal expected') + equal(args[1], DEFAULT_TERMINAL_OSX, 'terminal should equal expected'); done(); return { on: (evt) => evt - } + }; } }; mockConfig.terminal.external.osxExec = undefined; @@ -172,7 +172,7 @@ suite('Execution - TerminalService', () => { ); }); - test("LinuxTerminalService - uses terminal from configuration", done => { + test(`LinuxTerminalService - uses terminal from configuration`, done => { let testCwd = 'path/to/workspace'; let mockSpawner = { spawn: (command, args, opts) => { @@ -182,7 +182,7 @@ suite('Execution - TerminalService', () => { done(); return { on: (evt) => evt - } + }; } }; let testService = new LinuxTerminalService(mockConfig); @@ -195,16 +195,16 @@ suite('Execution - TerminalService', () => { ); }); - test("LinuxTerminalService - uses default terminal when configuration.terminal.external.linuxExec is undefined", done => { + test(`LinuxTerminalService - uses default terminal when configuration.terminal.external.linuxExec is undefined`, done => { let testCwd = 'path/to/workspace'; let mockSpawner = { spawn: (command, args, opts) => { // assert - equal(command, DEFAULT_TERMINAL_LINUX, 'terminal should equal expected') + equal(command, DEFAULT_TERMINAL_LINUX, 'terminal should equal expected'); done(); return { on: (evt) => evt - } + }; } }; mockConfig.terminal.external.linuxExec = undefined; diff --git a/src/vs/workbench/parts/terminal/test/terminalInstance.test.ts b/src/vs/workbench/parts/terminal/test/terminalInstance.test.ts index b78cdbaf940..d3e7d3236f1 100644 --- a/src/vs/workbench/parts/terminal/test/terminalInstance.test.ts +++ b/src/vs/workbench/parts/terminal/test/terminalInstance.test.ts @@ -7,18 +7,13 @@ import * as assert from 'assert'; import * as os from 'os'; -import * as platform from 'vs/base/common/platform'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IMessageService } from 'vs/platform/message/common/message'; import { IStringDictionary } from 'vs/base/common/collections'; import { IWorkspace } from 'vs/platform/workspace/common/workspace'; -import { TerminalConfigHelper } from 'vs/workbench/parts/terminal/electron-browser/terminalConfigHelper'; import { TerminalInstance } from 'vs/workbench/parts/terminal/electron-browser/terminalInstance'; import { TestInstantiationService } from 'vs/test/utils/instantiationTestUtils'; import { TestMessageService } from 'vs/test/utils/servicesTestUtils'; -import { TestConfigurationService } from 'vs/platform/configuration/test/common/testConfigurationService'; - suite('Workbench - TerminalInstance', () => { @@ -72,22 +67,4 @@ suite('Workbench - TerminalInstance', () => { const env4 = TerminalInstance.createTerminalEnv(parentEnv2, shell1, null, null); assert.equal(env4['LANG'], 'en_US.UTF-8', 'LANG is equal to the parent environment\'s LANG'); }); -}); - -function createTerminalInstance(instantiationService: TestInstantiationService, terminalConfig: any): TerminalInstance { - let configService = new TestConfigurationService(); - configService.setUserConfiguration('terminal', { - integrated: terminalConfig - }); - instantiationService.stub(IConfigurationService, configService); - - let terminalConfigHelper = new TerminalConfigHelper(platform.platform, configService); - return instantiationService.createInstance(TerminalInstance, - /*terminalFocusContextKey*/null, - /*onExitCallback*/() => { }, - /*configHelper*/terminalConfigHelper, - /*container*/null, - /*workspace*/null, - /*name*/'', - /*shellPath*/''); -} \ No newline at end of file +}); \ No newline at end of file