| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script src="../../../http/tests/inspector/timeline-test.js"></script> | 4 <script src="../../../http/tests/inspector/timeline-test.js"></script> |
| 5 <script> | 5 <script> |
| 6 function test() | 6 function test() |
| 7 { | 7 { |
| 8 function checkStringContains(string, contains) | 8 function checkStringContains(string, contains) |
| 9 { | 9 { |
| 10 var doesContain = string.indexOf(contains) >= 0; | 10 var doesContain = string.indexOf(contains) >= 0; |
| 11 InspectorTest.check(doesContain, contains + " should be present in " + s
tring); | 11 InspectorTest.check(doesContain, contains + " should be present in " + s
tring); |
| 12 InspectorTest.addResult("PASS - record contained " + contains); | 12 InspectorTest.addResult("PASS - record contained " + contains); |
| 13 } | 13 } |
| 14 | 14 |
| 15 InspectorTest.runTestSuite([ | 15 InspectorTest.runTestSuite([ |
| 16 function testTimerInstall(next) | 16 function testTimerInstall(next) |
| 17 { | 17 { |
| 18 function setTimeoutFunction() | 18 function setTimeoutFunction() |
| 19 { | 19 { |
| 20 return new Promise((fulfill) => setTimeout(fulfill, 0)); | 20 return new Promise((fulfill) => setTimeout(fulfill, 0)); |
| 21 } | 21 } |
| 22 | 22 |
| 23 var source = setTimeoutFunction.toString(); | 23 var source = setTimeoutFunction.toString(); |
| 24 source += "\n//# sourceURL=setTimeoutFunction.js"; | 24 source += "\n//# sourceURL=setTimeoutFunction.js"; |
| 25 InspectorTest.evaluateInPage(source); | 25 InspectorTest.evaluateInPage(source); |
| 26 | 26 |
| 27 InspectorTest.invokeAsyncWithTimeline("setTimeoutFunction", finishAn
dRunNextTest); | 27 InspectorTest.invokeAsyncWithTimeline("setTimeoutFunction", finishAn
dRunNextTest); |
| 28 function finishAndRunNextTest() | 28 function finishAndRunNextTest() |
| 29 { | 29 { |
| 30 var linkifier = new WebInspector.Linkifier(); | 30 var linkifier = new Components.Linkifier(); |
| 31 var record = InspectorTest.findFirstTimelineRecord("TimerFire"); | 31 var record = InspectorTest.findFirstTimelineRecord("TimerFire"); |
| 32 InspectorTest.check(record, "Should receive a TimerFire record."
); | 32 InspectorTest.check(record, "Should receive a TimerFire record."
); |
| 33 var event = record.traceEvent(); | 33 var event = record.traceEvent(); |
| 34 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(InspectorTest.timelineModel().targetByEvent(event), linkifier, true); | 34 var contentHelper = new Timeline.TimelineDetailsContentHelper(In
spectorTest.timelineModel().targetByEvent(event), linkifier, true); |
| 35 WebInspector.TimelineUIUtils._generateCauses(event, InspectorTes
t.timelineModel().targetByEvent(event), null, contentHelper); | 35 Timeline.TimelineUIUtils._generateCauses(event, InspectorTest.ti
melineModel().targetByEvent(event), null, contentHelper); |
| 36 var causes = contentHelper.element.deepTextContent(); | 36 var causes = contentHelper.element.deepTextContent(); |
| 37 InspectorTest.check(causes, "Should generate causes"); | 37 InspectorTest.check(causes, "Should generate causes"); |
| 38 checkStringContains(causes, "Timer Installed\nPromise @ setTimeo
utFunction.js:"); | 38 checkStringContains(causes, "Timer Installed\nPromise @ setTimeo
utFunction.js:"); |
| 39 next(); | 39 next(); |
| 40 } | 40 } |
| 41 }, | 41 }, |
| 42 | 42 |
| 43 function testRequestAnimationFrame(next) | 43 function testRequestAnimationFrame(next) |
| 44 { | 44 { |
| 45 function requestAnimationFrameFunction(callback) | 45 function requestAnimationFrameFunction(callback) |
| 46 { | 46 { |
| 47 return new Promise((fulfill) => requestAnimationFrame(fulfill)); | 47 return new Promise((fulfill) => requestAnimationFrame(fulfill)); |
| 48 } | 48 } |
| 49 | 49 |
| 50 var source = requestAnimationFrameFunction.toString(); | 50 var source = requestAnimationFrameFunction.toString(); |
| 51 source += "\n//# sourceURL=requestAnimationFrameFunction.js"; | 51 source += "\n//# sourceURL=requestAnimationFrameFunction.js"; |
| 52 InspectorTest.evaluateInPage(source); | 52 InspectorTest.evaluateInPage(source); |
| 53 | 53 |
| 54 InspectorTest.invokeAsyncWithTimeline("requestAnimationFrameFunction
", finishAndRunNextTest); | 54 InspectorTest.invokeAsyncWithTimeline("requestAnimationFrameFunction
", finishAndRunNextTest); |
| 55 function finishAndRunNextTest() | 55 function finishAndRunNextTest() |
| 56 { | 56 { |
| 57 var linkifier = new WebInspector.Linkifier(); | 57 var linkifier = new Components.Linkifier(); |
| 58 var record = InspectorTest.findFirstTimelineRecord("FireAnimatio
nFrame"); | 58 var record = InspectorTest.findFirstTimelineRecord("FireAnimatio
nFrame"); |
| 59 InspectorTest.check(record, "Should receive a FireAnimationFrame
record."); | 59 InspectorTest.check(record, "Should receive a FireAnimationFrame
record."); |
| 60 var event = record.traceEvent(); | 60 var event = record.traceEvent(); |
| 61 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(InspectorTest.timelineModel().targetByEvent(event), linkifier, true); | 61 var contentHelper = new Timeline.TimelineDetailsContentHelper(In
spectorTest.timelineModel().targetByEvent(event), linkifier, true); |
| 62 WebInspector.TimelineUIUtils._generateCauses(event, InspectorTes
t.timelineModel().targetByEvent(event), null, contentHelper); | 62 Timeline.TimelineUIUtils._generateCauses(event, InspectorTest.ti
melineModel().targetByEvent(event), null, contentHelper); |
| 63 var causes = contentHelper.element.deepTextContent(); | 63 var causes = contentHelper.element.deepTextContent(); |
| 64 InspectorTest.check(causes, "Should generate causes"); | 64 InspectorTest.check(causes, "Should generate causes"); |
| 65 checkStringContains(causes, "Animation Frame Requested\nPromise
@ requestAnimationFrameFunction.js:"); | 65 checkStringContains(causes, "Animation Frame Requested\nPromise
@ requestAnimationFrameFunction.js:"); |
| 66 next(); | 66 next(); |
| 67 } | 67 } |
| 68 }, | 68 }, |
| 69 | 69 |
| 70 function testStyleRecalc(next) | 70 function testStyleRecalc(next) |
| 71 { | 71 { |
| 72 function styleRecalcFunction() | 72 function styleRecalcFunction() |
| 73 { | 73 { |
| 74 var element = document.getElementById("testElement"); | 74 var element = document.getElementById("testElement"); |
| 75 element.style.backgroundColor = "papayawhip"; | 75 element.style.backgroundColor = "papayawhip"; |
| 76 var forceLayout = element.offsetWidth; | 76 var forceLayout = element.offsetWidth; |
| 77 } | 77 } |
| 78 | 78 |
| 79 var source = styleRecalcFunction.toString(); | 79 var source = styleRecalcFunction.toString(); |
| 80 source += "\n//# sourceURL=styleRecalcFunction.js"; | 80 source += "\n//# sourceURL=styleRecalcFunction.js"; |
| 81 InspectorTest.evaluateInPage(source); | 81 InspectorTest.evaluateInPage(source); |
| 82 | 82 |
| 83 InspectorTest.evaluateWithTimeline("styleRecalcFunction()", finishAn
dRunNextTest); | 83 InspectorTest.evaluateWithTimeline("styleRecalcFunction()", finishAn
dRunNextTest); |
| 84 function finishAndRunNextTest() | 84 function finishAndRunNextTest() |
| 85 { | 85 { |
| 86 var linkifier = new WebInspector.Linkifier(); | 86 var linkifier = new Components.Linkifier(); |
| 87 var record = InspectorTest.findFirstTimelineRecord("UpdateLayout
Tree"); | 87 var record = InspectorTest.findFirstTimelineRecord("UpdateLayout
Tree"); |
| 88 InspectorTest.check(record, "Should receive a UpdateLayoutTree r
ecord."); | 88 InspectorTest.check(record, "Should receive a UpdateLayoutTree r
ecord."); |
| 89 var event = record.traceEvent(); | 89 var event = record.traceEvent(); |
| 90 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(InspectorTest.timelineModel().targetByEvent(event), linkifier, true); | 90 var contentHelper = new Timeline.TimelineDetailsContentHelper(In
spectorTest.timelineModel().targetByEvent(event), linkifier, true); |
| 91 WebInspector.TimelineUIUtils._generateCauses(event, InspectorTes
t.timelineModel().targetByEvent(event), null, contentHelper); | 91 Timeline.TimelineUIUtils._generateCauses(event, InspectorTest.ti
melineModel().targetByEvent(event), null, contentHelper); |
| 92 var causes = contentHelper.element.deepTextContent(); | 92 var causes = contentHelper.element.deepTextContent(); |
| 93 InspectorTest.check(causes, "Should generate causes"); | 93 InspectorTest.check(causes, "Should generate causes"); |
| 94 checkStringContains(causes, "First Invalidated\nstyleRecalcFunct
ion @ styleRecalcFunction.js:"); | 94 checkStringContains(causes, "First Invalidated\nstyleRecalcFunct
ion @ styleRecalcFunction.js:"); |
| 95 next(); | 95 next(); |
| 96 } | 96 } |
| 97 }, | 97 }, |
| 98 | 98 |
| 99 function testLayout(next) | 99 function testLayout(next) |
| 100 { | 100 { |
| 101 function layoutFunction() | 101 function layoutFunction() |
| 102 { | 102 { |
| 103 var element = document.getElementById("testElement"); | 103 var element = document.getElementById("testElement"); |
| 104 element.style.width = "200px"; | 104 element.style.width = "200px"; |
| 105 var forceLayout = element.offsetWidth; | 105 var forceLayout = element.offsetWidth; |
| 106 } | 106 } |
| 107 | 107 |
| 108 var source = layoutFunction.toString(); | 108 var source = layoutFunction.toString(); |
| 109 source += "\n//# sourceURL=layoutFunction.js"; | 109 source += "\n//# sourceURL=layoutFunction.js"; |
| 110 InspectorTest.evaluateInPage(source); | 110 InspectorTest.evaluateInPage(source); |
| 111 | 111 |
| 112 InspectorTest.evaluateWithTimeline("layoutFunction()", finishAndRunN
extTest); | 112 InspectorTest.evaluateWithTimeline("layoutFunction()", finishAndRunN
extTest); |
| 113 function finishAndRunNextTest() | 113 function finishAndRunNextTest() |
| 114 { | 114 { |
| 115 var linkifier = new WebInspector.Linkifier(); | 115 var linkifier = new Components.Linkifier(); |
| 116 var record = InspectorTest.findFirstTimelineRecord("Layout"); | 116 var record = InspectorTest.findFirstTimelineRecord("Layout"); |
| 117 InspectorTest.check(record, "Should receive a Layout record."); | 117 InspectorTest.check(record, "Should receive a Layout record."); |
| 118 var event = record.traceEvent(); | 118 var event = record.traceEvent(); |
| 119 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(InspectorTest.timelineModel().targetByEvent(event), linkifier, true); | 119 var contentHelper = new Timeline.TimelineDetailsContentHelper(In
spectorTest.timelineModel().targetByEvent(event), linkifier, true); |
| 120 WebInspector.TimelineUIUtils._generateCauses(event, InspectorTes
t.timelineModel().targetByEvent(event), null, contentHelper); | 120 Timeline.TimelineUIUtils._generateCauses(event, InspectorTest.ti
melineModel().targetByEvent(event), null, contentHelper); |
| 121 var causes = contentHelper.element.deepTextContent(); | 121 var causes = contentHelper.element.deepTextContent(); |
| 122 InspectorTest.check(causes, "Should generate causes"); | 122 InspectorTest.check(causes, "Should generate causes"); |
| 123 checkStringContains(causes, "Layout Forced\nlayoutFunction @ lay
outFunction.js:"); | 123 checkStringContains(causes, "Layout Forced\nlayoutFunction @ lay
outFunction.js:"); |
| 124 checkStringContains(causes, "First Layout Invalidation\nlayoutFu
nction @ layoutFunction.js:"); | 124 checkStringContains(causes, "First Layout Invalidation\nlayoutFu
nction @ layoutFunction.js:"); |
| 125 next(); | 125 next(); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 ]); | 128 ]); |
| 129 } | 129 } |
| 130 </script> | 130 </script> |
| 131 </head> | 131 </head> |
| 132 | 132 |
| 133 <body onload="runTest()"> | 133 <body onload="runTest()"> |
| 134 <p> | 134 <p> |
| 135 Test that causes are correctly generated for various types of events. | 135 Test that causes are correctly generated for various types of events. |
| 136 </p> | 136 </p> |
| 137 <div id="testElement"></div> | 137 <div id="testElement"></div> |
| 138 </body> | 138 </body> |
| 139 </html> | 139 </html> |
| OLD | NEW |