Merge pull request #40 from thomabr/master

Enable support for testing Edge
This commit is contained in:
thomabr 2017-01-10 11:11:34 -08:00 коммит произвёл GitHub
Родитель 9ad975d14f 86c1a712ae
Коммит 66c9ead80e
8 изменённых файлов: 120 добавлений и 38 удалений

Просмотреть файл

@ -0,0 +1,22 @@
# Callstack Test App
This is a test app that hosts a webpage used for generating callstacks on various browsers. The webpage uses the windows.onerror event handler to report the information retrieved on the error object's stack property. If the browser does not return the error object on the windows.onerror event handler, it attempts to report the global window.events.error.stack property. By default the test app loads JavaScript minified by Ajaxmin (CrashCauser.js) which contains logic to generate a callstack when the "Cause Crash" button is clicked. This JavaScript is minified automatically as part of the msbuild process. There is also sample JavaScript checked in that has been minified with Google Closure (closureCrashCauser.js->closureCrashCauser.minified.js). In order to avoid the test app from taking a dependency on java, the process to minify the javascript and generate a sourcemap with closure is manual and if any changes are made to closurecrashcauser.js, the corresponding closurecrashcauser.minified.js and closurecrashcauser.sourcemap would need to be updated manually. This is done by running the locally on your machine and updated the minfied js and sourcemap. To switch the testapp to use the different minfiied versions of the JavaScript, you need to change the script tag loaded in index.html.
##JavaScript Minified using Ajax Min (CrashCauser.min.js)
CrashCauser.js is minified with Ajaxmin. The minfied version of the JavaScript and the sourcemap are generated at build time and not checked in via gitignore rules (crashcauser.min.js and crashcauser.min.js.map). The deminified stackframe should look similar to the following
```
level3
level3
level2
level1
causeCrash
window
```
## Javascript minified using Google Closure (ClosureCrashCauser.minified.js)
Closurecrashcauser.js is minified with Google Closure. The minified version of the javascript and the sourcemap are generated manually and are part of the source code (closurecrashcauser.minified.js and cclosurecrashcauser.sourcemap). The deminified stackframe should look similar to the following
```
mynamespace.objectWithMethods.propertyMethodLevel2
mynamespace.objectWithMethods.prototypeMethodLevel1
GlobalFunction
window
```

Просмотреть файл

@ -67,9 +67,11 @@
</ItemGroup>
<ItemGroup>
<Content Include="closurecrashcauser.js" />
<Content Include="closurecrashcauser.minified.js" />
<Content Include="crashcauser.js" />
<Content Include="Index.html" />
<Content Include="packages.config" />
<Content Include="closurecrashcauser.sourcemap" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>

Просмотреть файл

@ -13,7 +13,10 @@ window["foo"]["bar2"] = mynamespace.objectWithMethods.propertyMethodLevel2;
window["bar"] = GlobalFunction;
window.onerror = function (message, source, lineno, colno, error) {
document.getElementById("callstackdisplay").innerText = error.stack;
if (error)
document.getElementById("callstackdisplay").innerText = error.stack;
else if (window.event.error)
document.getElementById("callstackdisplay").innerText = window.event.error.stack;
}
window.onload = function (event) {

Просмотреть файл

@ -0,0 +1 @@
function a(){}window.foo=a;a.prototype={b:function(){return a.a(void 0)}};a.a=function(b){return b.length};function c(){return(new a).b()}window.foo.bar=a.b;window.foo.bar2=a.a;window.bar=c;window.onerror=function(b,e,f,g,d){d?document.getElementById("callstackdisplay").innerText=d.stack:window.event.error&&(document.getElementById("callstackdisplay").innerText=window.event.error.stack)};window.onload=function(){document.getElementById("crashbutton").addEventListener("click",function(){console.log(c())})};

Просмотреть файл

@ -0,0 +1,8 @@
{
"version":3,
"file":"",
"lineCount":1,
"mappings":"AAEgCA,QAAA,EAAS,EAAG,EAC5CC,MAAA,IAAA,CAAgBD,CAChBA,EAAAE,UAAA,CAA0C,CAAEC,EAAuBA,QAAS,EAAG,CAAS,MAAOC,EAAAC,EAAA,CAAVC,IAAAA,EAAU,CAAhB,CAArC,CAE1CF,EAAAC,EAAA,CAAqDD,QAAS,CAACG,CAAD,CAAI,CAAE,MAAOA,EAAAC,OAAT,CAElEC,SAASA,EAAc,EAAG,CAA+C,MAAON,CAA5CG,IAAIN,CAAwCG,GAAA,EAAtD,CAE1BF,MAAA,IAAA,IAAA,CAAuBS,CAAAP,EACvBF,OAAA,IAAA,KAAA,CAAwBG,CAAAC,EACxBJ,OAAA,IAAA,CAAgBQ,CAEhBR,OAAAU,QAAA,CAAiBC,QAAS,CAACC,CAAD,CAAUC,CAAV,CAAkBC,CAAlB,CAA0BC,CAA1B,CAAiCC,CAAjC,CAAwC,CAC1DA,CAAJ,CACIC,QAAAC,eAAA,CAAwB,kBAAxB,CAAAC,UADJ,CAC4DH,CAAAI,MAD5D,CAESpB,MAAAqB,MAAAL,MAFT,GAGIC,QAAAC,eAAA,CAAwB,kBAAxB,CAAAC,UAHJ,CAG4DnB,MAAAqB,MAAAL,MAAAI,MAH5D,CAD8D,CAOlEpB,OAAAsB,OAAA,CAAgBC,QAAS,EAAQ,CAC7BN,QAAAC,eAAA,CAAwB,aAAxB,CAAAM,iBAAA,CAAwD,OAAxD,CAAiE,QAAS,EAAG,CACzEC,OAAAC,IAAA,CAAYlB,CAAA,EAAZ,CADyE,CAA7E,CAD6B;",
"sources":["//officefile/public/thomabr/closurecrashcauser.js"],
"names":["mynamespace.objectWithMethods","window","prototype","prototypeMethodLevel1","mynamespace.objectWithMethods.propertyMethodLevel2","propertyMethodLevel2","x","e","length","GlobalFunction","mynamespace.objectWithMethods.prototypeMethodLevel1","onerror","window.onerror","message","source","lineno","colno","error","document","getElementById","innerText","stack","event","onload","window.onload","addEventListener","console","log"]
}

Просмотреть файл

@ -19,7 +19,10 @@
}
window.onerror = function (message, source, lineno, colno, error) {
document.getElementById("callstackdisplay").innerText = error.stack;
if (error)
document.getElementById("callstackdisplay").innerText = error.stack;
else if (window.event.error)
document.getElementById("callstackdisplay").innerText = window.event.error.stack;
}
level1();

Просмотреть файл

@ -8,17 +8,17 @@ namespace SourcemapToolkit.CallstackDeminifier.UnitTests
[TestClass]
public class StackTraceDeminifierClosureEndToEndTests
{
private const string GeneratedCodeString = "function a(){}window.foo=a;a.prototype={b:function(){return a.a(void 0)}};a.a=function(b){return b.length};function c(){return(new a).b()}window.foo.bar=a.b;window.foo.bar2=a.a;window.bar=c;window.onerror=function(b,e,f,g,d){document.getElementById(\"callstackdisplay\").innerText=d.stack};window.onload=function(){document.getElementById(\"crashbutton\").addEventListener(\"click\",function(){console.log(c())})};";
private const string SourceMapString = "{\r\n\"version\":3,\r\n\"file\":\"crashcauser.min.js\",\r\n\"lineCount\":1,\r\n\"mappings\":\"AAEgCA,QAAA,EAAS,EAAG,EAC5CC,MAAA,IAAA,CAAgBD,CAChBA,EAAAE,UAAA,CAA0C,CAAEC,EAAuBA,QAAQ,EAAG,CAAS,MAAOC,EAAAC,EAAA,CAAVC,IAAAA,EAAU,CAAhB,CAApC,CAE1CF,EAAAC,EAAA,CAAqDD,QAAS,CAACG,CAAD,CAAI,CAAE,MAAOA,EAAAC,OAAT,CAElEC,SAASA,EAAc,EAAG,CAAgD,MAAON,CAA7CG,IAAIN,CAAyCG,GAAA,EAAvD,CAE1BF,MAAA,IAAA,IAAA,CAAuBS,CAAAP,EACvBF,OAAA,IAAA,KAAA,CAAwBG,CAAAC,EACxBJ,OAAA,IAAA,CAAgBQ,CAEhBR,OAAAU,QAAA,CAAiBC,QAAS,CAACC,CAAD,CAAUC,CAAV,CAAkBC,CAAlB,CAA0BC,CAA1B,CAAiCC,CAAjC,CAAwC,CAC1DC,QAAAC,eAAA,CAAwB,kBAAxB,CAAAC,UAAA,CAAwDH,CAAAI,MADE,CAIlEpB,OAAAqB,OAAA,CAAgBC,QAAS,EAAQ,CAC7BL,QAAAC,eAAA,CAAwB,aAAxB,CAAAK,iBAAA,CAAwD,OAAxD,CAAiE,QAAS,EAAG,CAC1EC,OAAAC,IAAA,CAAYjB,CAAA,EAAZ,CAD0E,CAA7E,CAD6B;\",\r\n\"sources\":[\"crashcauser.js\"],\r\n\"names\":[\"mynamespace.objectWithMethods\",\"window\",\"prototype\",\"prototypeMethodLevel1\",\"mynamespace.objectWithMethods.propertyMethodLevel2\",\"propertyMethodLevel2\",\"x\",\"e\",\"length\",\"GlobalFunction\",\"mynamespace.objectWithMethods.prototypeMethodLevel1\",\"onerror\",\"window.onerror\",\"message\",\"source\",\"lineno\",\"colno\",\"error\",\"document\",\"getElementById\",\"innerText\",\"stack\",\"onload\",\"window.onload\",\"addEventListener\",\"console\",\"log\"]\r\n}\r\n";
private const string GeneratedCodeString = "function a(){}window.foo=a;a.prototype={b:function(){return a.a(void 0)}};a.a=function(b){return b.length};function c(){return(new a).b()}window.foo.bar=a.b;window.foo.bar2=a.a;window.bar=c;window.onerror=function(b,e,f,g,d){d?document.getElementById(\"callstackdisplay\").innerText=d.stack:window.event.error&&(document.getElementById(\"callstackdisplay\").innerText=window.event.error.stack)};window.onload=function(){document.getElementById(\"crashbutton\").addEventListener(\"click\",function(){console.log(c())})};";
private const string SourceMapString = "{\r\n\"version\":3,\r\n\"file\":\"\",\r\n\"lineCount\":1,\r\n\"mappings\":\"AAEgCA,QAAA,EAAS,EAAG,EAC5CC,MAAA,IAAA,CAAgBD,CAChBA,EAAAE,UAAA,CAA0C,CAAEC,EAAuBA,QAAS,EAAG,CAAS,MAAOC,EAAAC,EAAA,CAAVC,IAAAA,EAAU,CAAhB,CAArC,CAE1CF,EAAAC,EAAA,CAAqDD,QAAS,CAACG,CAAD,CAAI,CAAE,MAAOA,EAAAC,OAAT,CAElEC,SAASA,EAAc,EAAG,CAA+C,MAAON,CAA5CG,IAAIN,CAAwCG,GAAA,EAAtD,CAE1BF,MAAA,IAAA,IAAA,CAAuBS,CAAAP,EACvBF,OAAA,IAAA,KAAA,CAAwBG,CAAAC,EACxBJ,OAAA,IAAA,CAAgBQ,CAEhBR,OAAAU,QAAA,CAAiBC,QAAS,CAACC,CAAD,CAAUC,CAAV,CAAkBC,CAAlB,CAA0BC,CAA1B,CAAiCC,CAAjC,CAAwC,CAC1DA,CAAJ,CACIC,QAAAC,eAAA,CAAwB,kBAAxB,CAAAC,UADJ,CAC4DH,CAAAI,MAD5D,CAESpB,MAAAqB,MAAAL,MAFT,GAGIC,QAAAC,eAAA,CAAwB,kBAAxB,CAAAC,UAHJ,CAG4DnB,MAAAqB,MAAAL,MAAAI,MAH5D,CAD8D,CAOlEpB,OAAAsB,OAAA,CAAgBC,QAAS,EAAQ,CAC7BN,QAAAC,eAAA,CAAwB,aAAxB,CAAAM,iBAAA,CAAwD,OAAxD,CAAiE,QAAS,EAAG,CACzEC,OAAAC,IAAA,CAAYlB,CAAA,EAAZ,CADyE,CAA7E,CAD6B;\",\r\n\"sources\":[\"//officefile/public/thomabr/closurecrashcauser.js\"],\r\n\"names\":[\"mynamespace.objectWithMethods\",\"window\",\"prototype\",\"prototypeMethodLevel1\",\"mynamespace.objectWithMethods.propertyMethodLevel2\",\"propertyMethodLevel2\",\"x\",\"e\",\"length\",\"GlobalFunction\",\"mynamespace.objectWithMethods.prototypeMethodLevel1\",\"onerror\",\"window.onerror\",\"message\",\"source\",\"lineno\",\"colno\",\"error\",\"document\",\"getElementById\",\"innerText\",\"stack\",\"event\",\"onload\",\"window.onload\",\"addEventListener\",\"console\",\"log\"]\r\n}\r\n";
private StackTraceDeminifier GetStackTraceDeminifierWithDependencies()
{
ISourceMapProvider sourceMapProvider = MockRepository.GenerateStrictMock<ISourceMapProvider>();
sourceMapProvider.Stub(x => x.GetSourceMapContentsForCallstackUrl("http://localhost:11323/crashcauser.js")).Return(UnitTestUtils.StreamReaderFromString(SourceMapString));
sourceMapProvider.Stub(x => x.GetSourceMapContentsForCallstackUrl("http://localhost:11323/closurecrashcauser.minified.js")).Return(UnitTestUtils.StreamReaderFromString(SourceMapString));
ISourceCodeProvider sourceCodeProvider = MockRepository.GenerateStrictMock<ISourceCodeProvider>();
sourceCodeProvider.Stub(x => x.GetSourceCode("http://localhost:11323/crashcauser.js")).Return(UnitTestUtils.StreamReaderFromString(GeneratedCodeString));
sourceCodeProvider.Stub(x => x.GetSourceCode("http://localhost:11323/closurecrashcauser.minified.js")).Return(UnitTestUtils.StreamReaderFromString(GeneratedCodeString));
return StackTraceDeminfierFactory.GetStackTraceDeminfier(sourceMapProvider, sourceCodeProvider);
}
@ -39,10 +39,10 @@ namespace SourcemapToolkit.CallstackDeminifier.UnitTests
// Arrange
StackTraceDeminifier stackTraceDeminifier = GetStackTraceDeminifierWithDependencies();
string callstack = @"TypeError: Cannot read property 'length' of undefined
at Function.a.a (http://localhost:11323/crashcauser.js:1:99)
at Object.b (http://localhost:11323/crashcauser.js:1:63)
at c (http://localhost:11323/crashcauser.js:1:135)
at HTMLButtonElement.<anonymous> (http://localhost:11323/crashcauser.js:1:401)";
at Function.a.a (http://localhost:11323/closurecrashcauser.minified.js:1:99)
at a.b (http://localhost:11323/closurecrashcauser.minified.js:1:63)
at c (http://localhost:11323/closurecrashcauser.minified.js:1:135)
at HTMLButtonElement.<anonymous> (http://localhost:11323/closurecrashcauser.minified.js:1:504)";
// Act
DeminifyStackTraceResult results = stackTraceDeminifier.DeminifyStackTrace(callstack);
@ -56,10 +56,10 @@ namespace SourcemapToolkit.CallstackDeminifier.UnitTests
{
// Arrange
StackTraceDeminifier stackTraceDeminifier = GetStackTraceDeminifierWithDependencies();
string callstack = @"a.a@http://localhost:11323/crashcauser.js:1:91
a.prototype.b@http://localhost:11323/crashcauser.js:1:61
c@http://localhost:11323/crashcauser.js:1:128
window.onload/<@http://localhost:11323/crashcauser.js:1:401";
string callstack = @"a.a@http://localhost:11323/closurecrashcauser.minified.js:1:91
a.prototype.b@http://localhost:11323/closurecrashcauser.minified.js:1:61
c@http://localhost:11323/closurecrashcauser.minified.js:1:128
window.onload/<@http://localhost:11323/closurecrashcauser.minified.js:1:504";
// Act
DeminifyStackTraceResult results = stackTraceDeminifier.DeminifyStackTrace(callstack);
@ -74,10 +74,10 @@ window.onload/<@http://localhost:11323/crashcauser.js:1:401";
// Arrange
StackTraceDeminifier stackTraceDeminifier = GetStackTraceDeminifierWithDependencies();
string callstack = @"TypeError: Unable to get property 'length' of undefined or null reference
at a.a (http://localhost:11323/crashcauser.js:1:91)
at a.prototype.b (http://localhost:11323/crashcauser.js:1:54)
at c (http://localhost:11323/crashcauser.js:1:121)
at Anonymous function (http://localhost:11323/crashcauser.js:1:389)";
   at a.a (http://localhost:11323/closurecrashcauser.minified.js:1:91)
   at a.prototype.b (http://localhost:11323/closurecrashcauser.minified.js:1:54)
   at c (http://localhost:11323/closurecrashcauser.minified.js:1:121)
   at Anonymous function (http://localhost:11323/closurecrashcauser.minified.js:1:492)";
// Act
DeminifyStackTraceResult results = stackTraceDeminifier.DeminifyStackTrace(callstack);
@ -85,5 +85,23 @@ window.onload/<@http://localhost:11323/crashcauser.js:1:401";
// Assert
ValidateDeminifyStackTraceResults(results);
}
}
[TestMethod]
public void DeminifyClosureStackTrace_EdgeStackTraceString_CorrectDeminificationWhenPossible()
{
// Arrange
StackTraceDeminifier stackTraceDeminifier = GetStackTraceDeminifierWithDependencies();
string callstack = @"TypeError: Unable to get property 'length' of undefined or null reference
   at a.a (http://localhost:11323/closurecrashcauser.minified.js:1:91)
   at a.prototype.b (http://localhost:11323/closurecrashcauser.minified.js:1:54)
   at c (http://localhost:11323/closurecrashcauser.minified.js:1:121)
   at Anonymous function (http://localhost:11323/closurecrashcauser.minified.js:1:492)";
// Act
DeminifyStackTraceResult results = stackTraceDeminifier.DeminifyStackTrace(callstack);
// Assert
ValidateDeminifyStackTraceResults(results);
}
}
}

Просмотреть файл

@ -7,10 +7,11 @@ namespace SourcemapToolkit.CallstackDeminifier.UnitTests
[TestClass]
public class StackTraceDeminifierEndToEndTests
{
private const string GeneratedCodeString = "function causeCrash(){function n(){var n=16;n+=2;t(n)}function t(n){n=n+2;i(n)}function i(n){var t;console.log(t.length+n)}window.onerror=function(n,t,i,r,u){document.getElementById(\"callstackdisplay\").innerText=u.stack};n()}window.onload=function(){document.getElementById(\"crashbutton\").addEventListener(\"click\",function(){causeCrash()})};";
private const string SourceMapString = "{\r\n\"version\":3,\r\n\"file\":\"crashcauser.min.js\",\r\n\"lineCount\":1,\r\n\"mappings\":\"AAAAA,SAASA,UAAU,CAAA,CACnB,CACIC,SAASA,CAAM,CAAA,CAAG,CACd,IAAIC,EAAwB,EAAE,CAC9BA,CAAsB,EAAG,CAAC,CAC1BC,CAAM,CAACD,CAAD,CAHQ,CAMlBC,SAASA,CAAM,CAACC,CAAD,CAAQ,CACnBA,CAAM,CAAEA,CAAM,CAAE,CAAC,CACjBC,CAAM,CAACD,CAAD,CAFa,CAKvBC,SAASA,CAAM,CAACD,CAAD,CAAQ,CACnB,IAAIE,CAAC,CACLC,OAAOC,IAAI,CAACF,CAACG,OAAQ,CAAEL,CAAZ,CAFQ,CAKvBM,MAAMC,QAAS,CAAEC,QAAS,CAACC,CAAO,CAAEC,CAAM,CAAEC,CAAM,CAAEC,CAAK,CAAEC,CAAjC,CAAwC,CAC9DC,QAAQC,eAAe,CAAC,kBAAD,CAAoBC,UAAW,CAAEH,CAAKI,MADC,C,CAIlEpB,CAAM,CAAA,CArBV,CAwBAS,MAAMY,OAAQ,CAAEC,QAAS,CAAA,CAAQ,CAC7BL,QAAQC,eAAe,CAAC,aAAD,CAAeK,iBAAiB,CAAC,OAAO,CAAE,QAAS,CAAA,CAAG,CACzExB,UAAU,CAAA,CAD+D,CAAtB,CAD1B,C\",\r\n\"sources\":[\"crashcauser.js\"],\r\n\"names\":[\"causeCrash\",\"level1\",\"longLocalVariableName\",\"level2\",\"input\",\"level3\",\"x\",\"console\",\"log\",\"length\",\"window\",\"onerror\",\"window.onerror\",\"message\",\"source\",\"lineno\",\"colno\",\"error\",\"document\",\"getElementById\",\"innerText\",\"stack\",\"onload\",\"window.onload\",\"addEventListener\"]\r\n}\r\n";
private const string GeneratedCodeString = "function causeCrash(){function n(){var n=16;n+=2;t(n)}function t(n){n=n+2;i(n)}function i(n){(function(){var t;console.log(t.length+n)})()}window.onerror=function(n,t,i,r,u){u?document.getElementById(\"callstackdisplay\").innerText=u.stack:window.event.error&&(document.getElementById(\"callstackdisplay\").innerText=window.event.error.stack)};n()}window.onload=function(){document.getElementById(\"crashbutton\").addEventListener(\"click\",function(){causeCrash()})};";
private const string SourceMapString = "{\r\n\"version\":3,\r\n\"file\":\"crashcauser.min.js\",\r\n\"lineCount\":1,\r\n\"mappings\":\"AAAAA,SAASA,UAAU,CAAA,CACnB,CACIC,SAASA,CAAM,CAAA,CAAG,CACd,IAAIC,EAAwB,EAAE,CAC9BA,CAAsB,EAAG,CAAC,CAC1BC,CAAM,CAACD,CAAD,CAHQ,CAMlBC,SAASA,CAAM,CAACC,CAAD,CAAQ,CACnBA,CAAM,CAAEA,CAAM,CAAE,CAAC,CACjBC,CAAM,CAACD,CAAD,CAFa,CAKvBC,SAASA,CAAM,CAACD,CAAD,CAAQ,EAClB,QAAQ,CAAA,CAAG,CACR,IAAIE,CAAC,CACLC,OAAOC,IAAI,CAACF,CAACG,OAAQ,CAAEL,CAAZ,CAFH,EAGX,CAAA,CAJkB,CAOvBM,MAAMC,QAAS,CAAEC,QAAS,CAACC,CAAO,CAAEC,CAAM,CAAEC,CAAM,CAAEC,CAAK,CAAEC,CAAjC,CAAwC,CAC1DA,CAAJ,CACIC,QAAQC,eAAe,CAAC,kBAAD,CAAoBC,UAAW,CAAEH,CAAKI,MADjE,CAESX,MAAMY,MAAML,M,GACjBC,QAAQC,eAAe,CAAC,kBAAD,CAAoBC,UAAW,CAAEV,MAAMY,MAAML,MAAMI,OAJhB,C,CAOlEpB,CAAM,CAAA,CA1BV,CA6BAS,MAAMa,OAAQ,CAAEC,QAAS,CAAA,CAAQ,CAC7BN,QAAQC,eAAe,CAAC,aAAD,CAAeM,iBAAiB,CAAC,OAAO,CAAE,QAAS,CAAA,CAAG,CACzEzB,UAAU,CAAA,CAD+D,CAAtB,CAD1B,C\",\r\n\"sources\":[\"crashcauser.js\"],\r\n\"names\":[\"causeCrash\",\"level1\",\"longLocalVariableName\",\"level2\",\"input\",\"level3\",\"x\",\"console\",\"log\",\"length\",\"window\",\"onerror\",\"window.onerror\",\"message\",\"source\",\"lineno\",\"colno\",\"error\",\"document\",\"getElementById\",\"innerText\",\"stack\",\"event\",\"onload\",\"window.onload\",\"addEventListener\"]\r\n}";
private StackTraceDeminifier GetStackTraceDeminifierWithDependencies()
private StackTraceDeminifier GetStackTraceDeminifierWithDependencies()
{
ISourceMapProvider sourceMapProvider = MockRepository.GenerateStrictMock<ISourceMapProvider>();
sourceMapProvider.Stub(x => x.GetSourceMapContentsForCallstackUrl("http://localhost:11323/crashcauser.min.js")).Return(UnitTestUtils.StreamReaderFromString(SourceMapString));
@ -23,13 +24,14 @@ namespace SourcemapToolkit.CallstackDeminifier.UnitTests
private static void ValidateDeminifyStackTraceResults(DeminifyStackTraceResult results)
{
Assert.AreEqual(5, results.DeminifiedStackFrameResults.Count);
Assert.AreEqual(6, results.DeminifiedStackFrameResults.Count);
Assert.AreEqual(DeminificationError.None, results.DeminifiedStackFrameResults[0].DeminificationError);
Assert.AreEqual("level3", results.DeminifiedStackFrameResults[0].DeminifiedStackFrame.MethodName);
Assert.AreEqual("level2", results.DeminifiedStackFrameResults[1].DeminifiedStackFrame.MethodName);
Assert.AreEqual("level1", results.DeminifiedStackFrameResults[2].DeminifiedStackFrame.MethodName);
Assert.AreEqual("causeCrash", results.DeminifiedStackFrameResults[3].DeminifiedStackFrame.MethodName);
Assert.AreEqual("window", results.DeminifiedStackFrameResults[4].DeminifiedStackFrame.MethodName);
Assert.AreEqual("level3", results.DeminifiedStackFrameResults[0].DeminifiedStackFrame.MethodName);
Assert.AreEqual("level3", results.DeminifiedStackFrameResults[1].DeminifiedStackFrame.MethodName);
Assert.AreEqual("level2", results.DeminifiedStackFrameResults[2].DeminifiedStackFrame.MethodName);
Assert.AreEqual("level1", results.DeminifiedStackFrameResults[3].DeminifiedStackFrame.MethodName);
Assert.AreEqual("causeCrash", results.DeminifiedStackFrameResults[4].DeminifiedStackFrame.MethodName);
Assert.AreEqual("window", results.DeminifiedStackFrameResults[5].DeminifiedStackFrame.MethodName);
}
[TestMethod]
@ -38,11 +40,12 @@ namespace SourcemapToolkit.CallstackDeminifier.UnitTests
// Arrange
StackTraceDeminifier stackTraceDeminifier = GetStackTraceDeminifierWithDependencies();
string chromeStackTrace = @"TypeError: Cannot read property 'length' of undefined
at i (http://localhost:11323/crashcauser.min.js:1:113)
at http://localhost:11323/crashcauser.min.js:1:125
at i (http://localhost:11323/crashcauser.min.js:1:137)
at t (http://localhost:11323/crashcauser.min.js:1:75)
at n (http://localhost:11323/crashcauser.min.js:1:50)
at causeCrash (http://localhost:11323/crashcauser.min.js:1:222)
at HTMLButtonElement.<anonymous> (http://localhost:11323/crashcauser.min.js:1:326)";
at causeCrash (http://localhost:11323/crashcauser.min.js:1:341)
at HTMLButtonElement.<anonymous> (http://localhost:11323/crashcauser.min.js:1:445)";
// Act
DeminifyStackTraceResult results = stackTraceDeminifier.DeminifyStackTrace(chromeStackTrace);
@ -56,11 +59,12 @@ namespace SourcemapToolkit.CallstackDeminifier.UnitTests
{
// Arrange
StackTraceDeminifier stackTraceDeminifier = GetStackTraceDeminifierWithDependencies();
string fireFoxStackTrace = @"i @http://localhost:11323/crashcauser.min.js:1:100
string fireFoxStackTrace = @"i/<@http://localhost:11323/crashcauser.min.js:1:112
i@http://localhost:11323/crashcauser.min.js:1:95
t@http://localhost:11323/crashcauser.min.js:1:75
n@http://localhost:11323/crashcauser.min.js:1:50
causeCrash@http://localhost:11323/crashcauser.min.js:1:222
window.onload/<@http://localhost:11323/crashcauser.min.js:1:326";
causeCrash@http://localhost:11323/crashcauser.min.js:1:341
window.onload/<@http://localhost:11323/crashcauser.min.js:1:445";
// Act
DeminifyStackTraceResult results = stackTraceDeminifier.DeminifyStackTrace(fireFoxStackTrace);
@ -75,11 +79,12 @@ window.onload/<@http://localhost:11323/crashcauser.min.js:1:326";
// Arrange
StackTraceDeminifier stackTraceDeminifier = GetStackTraceDeminifierWithDependencies();
string ieStackTrace = @"TypeError: Unable to get property 'length' of undefined or null reference
at i (http://localhost:11323/crashcauser.min.js:1:100)
at Anonymous function (http://localhost:11323/crashcauser.min.js:1:112)
at i (http://localhost:11323/crashcauser.min.js:1:95)
at t (http://localhost:11323/crashcauser.min.js:1:75)
at n (http://localhost:11323/crashcauser.min.js:1:50)
at causeCrash (http://localhost:11323/crashcauser.min.js:1:222)
at Anonymous function (http://localhost:11323/crashcauser.min.js:1:326)";
at causeCrash (http://localhost:11323/crashcauser.min.js:1:341)
at Anonymous function (http://localhost:11323/crashcauser.min.js:1:445)";
// Act
DeminifyStackTraceResult results = stackTraceDeminifier.DeminifyStackTrace(ieStackTrace);
@ -87,5 +92,25 @@ window.onload/<@http://localhost:11323/crashcauser.min.js:1:326";
// Assert
ValidateDeminifyStackTraceResults(results);
}
}
[TestMethod]
public void DeminifyStackTrace_EdgeStackTraceString_CorrectDeminificationWhenPossible()
{
// Arrange
StackTraceDeminifier stackTraceDeminifier = GetStackTraceDeminifierWithDependencies();
string dgeStackTrace = @"TypeError: Unable to get property 'length' of undefined or null reference
   at Anonymous function (http://localhost:11323/crashcauser.min.js:1:112)
   at i (http://localhost:11323/crashcauser.min.js:1:95)
   at t (http://localhost:11323/crashcauser.min.js:1:75)
   at n (http://localhost:11323/crashcauser.min.js:1:50)
   at causeCrash (http://localhost:11323/crashcauser.min.js:1:341)
   at Anonymous function (http://localhost:11323/crashcauser.min.js:1:445)";
// Act
DeminifyStackTraceResult results = stackTraceDeminifier.DeminifyStackTrace(dgeStackTrace);
// Assert
ValidateDeminifyStackTraceResults(results);
}
}
}