Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <html> | |
| 2 <head> | |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> | |
| 4 <script src="../../http/tests/inspector/timeline-test.js"></script> | |
| 5 <script> | |
| 6 function test() | |
| 7 { | |
| 8 function checkStringContains(string, contains) | |
| 9 { | |
| 10 var doesContain = string.indexOf(contains) >= 0; | |
| 11 InspectorTest.check(doesContain, contains + " should be present in " + s tring); | |
| 12 InspectorTest.addResult("PASS - record contained " + contains); | |
| 13 } | |
| 14 | |
| 15 function testTimerInstall() | |
| 16 { | |
| 17 function setTimeoutFunction(callback) { | |
|
caseq
2014/10/07 09:50:07
{ => next line
pdr.
2014/10/08 06:06:20
Done (here, and the others).
| |
| 18 setTimeout(callback, 0); | |
| 19 } | |
| 20 | |
| 21 var source = setTimeoutFunction.toString(); | |
| 22 source += "\n//@ sourceURL=setTimeoutFunction.js"; | |
| 23 InspectorTest.evaluateInPage(source); | |
| 24 | |
| 25 InspectorTest.invokeAsyncWithTimeline("setTimeoutFunction", finishAndRun NextTest); | |
| 26 function finishAndRunNextTest() { | |
|
caseq
2014/10/07 09:50:07
ditto
| |
| 27 var linkifier = new WebInspector.Linkifier(); | |
| 28 var record = InspectorTest.findFirstTimelineRecord("TimerFire"); | |
| 29 InspectorTest.check(record, "Should receive a TimerFire record."); | |
| 30 var causes = WebInspector.TracingTimelineUIUtils.generateCauses(reco rd.traceEvent(), linkifier); | |
| 31 InspectorTest.check(causes && causes.textContent, "Should generate c auses"); | |
| 32 checkStringContains(causes.textContent, "Timer installed: setTimeout Function @ setTimeoutFunction.js:"); | |
| 33 testRequestAnimationFrame(); | |
|
caseq
2014/10/07 09:50:07
You probably want to use InspectorTest.runTestSuit
pdr.
2014/10/08 06:06:20
Done.
| |
| 34 } | |
| 35 } | |
| 36 | |
| 37 function testRequestAnimationFrame() | |
| 38 { | |
| 39 function requestAnimationFrameFunction(callback) { | |
|
caseq
2014/10/07 09:50:07
{ => next line
| |
| 40 requestAnimationFrame(function() { | |
|
caseq
2014/10/07 09:50:07
Drop the "function() { }", just "callback", it's c
pdr.
2014/10/08 06:06:20
Done :)
| |
| 41 callback(); | |
| 42 }); | |
| 43 } | |
| 44 | |
| 45 var source = requestAnimationFrameFunction.toString(); | |
| 46 source += "\n//@ sourceURL=requestAnimationFrameFunction.js"; | |
| 47 InspectorTest.evaluateInPage(source); | |
| 48 | |
| 49 InspectorTest.invokeAsyncWithTimeline("requestAnimationFrameFunction", f inishAndRunNextTest); | |
| 50 function finishAndRunNextTest() { | |
|
caseq
2014/10/07 09:50:07
{ => next line
| |
| 51 var linkifier = new WebInspector.Linkifier(); | |
| 52 var record = InspectorTest.findFirstTimelineRecord("FireAnimationFra me"); | |
| 53 InspectorTest.check(record, "Should receive a FireAnimationFrame rec ord."); | |
| 54 var causes = WebInspector.TracingTimelineUIUtils.generateCauses(reco rd.traceEvent(), linkifier); | |
| 55 InspectorTest.check(causes && causes.textContent, "Should generate c auses"); | |
| 56 checkStringContains(causes.textContent, "Animation frame requested: requestAnimationFrameFunction @ requestAnimationFrameFunction.js:"); | |
| 57 testStyleRecalc(); | |
| 58 } | |
| 59 } | |
| 60 | |
| 61 function testStyleRecalc() | |
| 62 { | |
| 63 function styleRecalcFunction(callback) { | |
|
caseq
2014/10/07 09:50:07
ditto
| |
| 64 var element = document.getElementById("testElement"); | |
| 65 element.style.backgroundColor = "papayawhip"; | |
| 66 callback(); | |
| 67 } | |
| 68 | |
| 69 var source = styleRecalcFunction.toString(); | |
| 70 source += "\n//@ sourceURL=styleRecalcFunction.js"; | |
| 71 InspectorTest.evaluateInPage(source); | |
| 72 | |
| 73 InspectorTest.invokeAsyncWithTimeline("styleRecalcFunction", finishAndRu nNextTest); | |
| 74 function finishAndRunNextTest() { | |
|
caseq
2014/10/07 09:50:07
ditto
| |
| 75 var linkifier = new WebInspector.Linkifier(); | |
| 76 var record = InspectorTest.findFirstTimelineRecord("RecalculateStyle s"); | |
| 77 InspectorTest.check(record, "Should receive a RecalculateStyles reco rd."); | |
| 78 var causes = WebInspector.TracingTimelineUIUtils.generateCauses(reco rd.traceEvent(), linkifier); | |
| 79 InspectorTest.check(causes && causes.textContent, "Should generate c auses"); | |
| 80 checkStringContains(causes.textContent, "Stack when first invalidate d: styleRecalcFunction @ styleRecalcFunction.js:"); | |
| 81 testLayout(); | |
| 82 } | |
| 83 } | |
| 84 | |
| 85 function testLayout() | |
| 86 { | |
| 87 function layoutFunction(callback) { | |
|
caseq
2014/10/07 09:50:07
ditto
| |
| 88 var element = document.getElementById("testElement"); | |
| 89 element.style.width = "200px"; | |
| 90 var forceLayout = element.offsetWidth; | |
| 91 callback(); | |
| 92 } | |
| 93 | |
| 94 var source = layoutFunction.toString(); | |
| 95 source += "\n//@ sourceURL=layoutFunction.js"; | |
| 96 InspectorTest.evaluateInPage(source); | |
| 97 | |
| 98 InspectorTest.invokeAsyncWithTimeline("layoutFunction", finishAndRunNext Test); | |
| 99 function finishAndRunNextTest() { | |
|
caseq
2014/10/07 09:50:07
ditto
| |
| 100 var linkifier = new WebInspector.Linkifier(); | |
| 101 var record = InspectorTest.findFirstTimelineRecord("Layout"); | |
| 102 InspectorTest.check(record, "Should receive a Layout record."); | |
| 103 var causes = WebInspector.TracingTimelineUIUtils.generateCauses(reco rd.traceEvent(), linkifier); | |
| 104 InspectorTest.check(causes && causes.textContent, "Should generate c auses"); | |
| 105 checkStringContains(causes.textContent, "Stack when layout was force d: layoutFunction @ layoutFunction.js:"); | |
| 106 checkStringContains(causes.textContent, "First layout invalidation: layoutFunction @ layoutFunction.js:"); | |
| 107 InspectorTest.completeTest(); | |
| 108 } | |
| 109 } | |
| 110 | |
| 111 // Begin the test. | |
| 112 testTimerInstall(); | |
| 113 } | |
| 114 </script> | |
| 115 </head> | |
| 116 | |
| 117 <body onload="runTest()"> | |
| 118 <p> | |
| 119 Test that causes are correctly generated for various types of events. | |
| 120 </p> | |
| 121 <div id="testElement"></div> | |
| 122 </body> | |
| 123 </html> | |
| OLD | NEW |