Add js minified by closure to the source code to make it easier to quickly test javascript that has been run through closure

This commit is contained in:
thomabr 2016-12-16 11:37:28 -08:00
Родитель a9e465a99b
Коммит ba28538578
4 изменённых файлов: 29 добавлений и 18 удалений

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

@ -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>

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

@ -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"]
}

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

@ -15,10 +15,10 @@ namespace SourcemapToolkit.CallstackDeminifier.UnitTests
private StackTraceDeminifier GetStackTraceDeminifierWithDependencies()
{
ISourceMapProvider sourceMapProvider = MockRepository.GenerateStrictMock<ISourceMapProvider>();
sourceMapProvider.Stub(x => x.GetSourceMapContentsForCallstackUrl("http://localhost:11323/closurecrashcauser.min.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/closurecrashcauser.min.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/closurecrashcauser.min.js:1:99)
at a.b (http://localhost:11323/closurecrashcauser.min.js:1:63)
at c (http://localhost:11323/closurecrashcauser.min.js:1:135)
at HTMLButtonElement.<anonymous> (http://localhost:11323/closurecrashcauser.min.js:1:504)";
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/closurecrashcauser.min.js:1:91
a.prototype.b@http://localhost:11323/closurecrashcauser.min.js:1:61
c@http://localhost:11323/closurecrashcauser.min.js:1:128
window.onload/<@http://localhost:11323/closurecrashcauser.min.js:1:504";
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/closurecrashcauser.min.js:1:504";
// Arrange
StackTraceDeminifier stackTraceDeminifier = GetStackTraceDeminifierWithDependencies();
string callstack = @"TypeError: Unable to get property 'length' of undefined or null reference
   at a.a (http://localhost:11323/closurecrashcauser.min.js:1:91)
   at a.prototype.b (http://localhost:11323/closurecrashcauser.min.js:1:54)
   at c (http://localhost:11323/closurecrashcauser.min.js:1:121)
   at Anonymous function (http://localhost:11323/closurecrashcauser.min.js:1:492)";
   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);
@ -92,10 +92,10 @@ window.onload/<@http://localhost:11323/closurecrashcauser.min.js:1:504";
// Arrange
StackTraceDeminifier stackTraceDeminifier = GetStackTraceDeminifierWithDependencies();
string callstack = @"TypeError: Unable to get property 'length' of undefined or null reference
   at a.a (http://localhost:11323/closurecrashcauser.min.js:1:91)
   at a.prototype.b (http://localhost:11323/closurecrashcauser.min.js:1:54)
   at c (http://localhost:11323/closurecrashcauser.min.js:1:121)
   at Anonymous function (http://localhost:11323/closurecrashcauser.min.js:1:492)";
   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);