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(callback) | 18 function setTimeoutFunction(callback) |
19 { | 19 { |
20 setTimeout(callback, 0); | 20 setTimeout(callback, 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 WebInspector.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 contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(InspectorTest.timelineModel().target(), linkifier, null, true); | 33 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(InspectorTest.timelineModel().target(), linkifier, null, true); |
34 WebInspector.TimelineUIUtils._generateCauses(record.traceEvent()
, InspectorTest.timelineModel().target(), contentHelper); | 34 WebInspector.TimelineUIUtils._generateCauses(record.traceEvent()
, InspectorTest.timelineModel().target(), contentHelper); |
35 var causes = contentHelper.element.deepTextContent(); | 35 var causes = contentHelper.element.deepTextContent(); |
36 InspectorTest.check(causes, "Should generate causes"); | 36 InspectorTest.check(causes, "Should generate causes"); |
37 checkStringContains(causes, "Timer installedsetTimeoutFunction @
setTimeoutFunction.js:"); | 37 checkStringContains(causes, "Timer installedsetTimeoutFunction @
setTimeoutFunction.js:"); |
38 next(); | 38 next(); |
39 } | 39 } |
40 }, | 40 }, |
41 | 41 |
42 function testRequestAnimationFrame(next) | 42 function testRequestAnimationFrame(next) |
43 { | 43 { |
44 function requestAnimationFrameFunction(callback) | 44 function requestAnimationFrameFunction(callback) |
45 { | 45 { |
46 requestAnimationFrame(callback); | 46 requestAnimationFrame(callback); |
47 } | 47 } |
48 | 48 |
49 var source = requestAnimationFrameFunction.toString(); | 49 var source = requestAnimationFrameFunction.toString(); |
50 source += "\n//@ sourceURL=requestAnimationFrameFunction.js"; | 50 source += "\n//# sourceURL=requestAnimationFrameFunction.js"; |
51 InspectorTest.evaluateInPage(source); | 51 InspectorTest.evaluateInPage(source); |
52 | 52 |
53 InspectorTest.invokeAsyncWithTimeline("requestAnimationFrameFunction
", finishAndRunNextTest); | 53 InspectorTest.invokeAsyncWithTimeline("requestAnimationFrameFunction
", finishAndRunNextTest); |
54 function finishAndRunNextTest() | 54 function finishAndRunNextTest() |
55 { | 55 { |
56 var linkifier = new WebInspector.Linkifier(); | 56 var linkifier = new WebInspector.Linkifier(); |
57 var record = InspectorTest.findFirstTimelineRecord("FireAnimatio
nFrame"); | 57 var record = InspectorTest.findFirstTimelineRecord("FireAnimatio
nFrame"); |
58 InspectorTest.check(record, "Should receive a FireAnimationFrame
record."); | 58 InspectorTest.check(record, "Should receive a FireAnimationFrame
record."); |
59 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(InspectorTest.timelineModel().target(), linkifier, null, true); | 59 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(InspectorTest.timelineModel().target(), linkifier, null, true); |
60 WebInspector.TimelineUIUtils._generateCauses(record.traceEvent()
, InspectorTest.timelineModel().target(), contentHelper); | 60 WebInspector.TimelineUIUtils._generateCauses(record.traceEvent()
, InspectorTest.timelineModel().target(), contentHelper); |
61 var causes = contentHelper.element.deepTextContent(); | 61 var causes = contentHelper.element.deepTextContent(); |
62 InspectorTest.check(causes, "Should generate causes"); | 62 InspectorTest.check(causes, "Should generate causes"); |
63 checkStringContains(causes, "Animation frame requestedrequestAni
mationFrameFunction @ requestAnimationFrameFunction.js:"); | 63 checkStringContains(causes, "Animation frame requestedrequestAni
mationFrameFunction @ requestAnimationFrameFunction.js:"); |
64 next(); | 64 next(); |
65 } | 65 } |
66 }, | 66 }, |
67 | 67 |
68 function testStyleRecalc(next) | 68 function testStyleRecalc(next) |
69 { | 69 { |
70 function styleRecalcFunction() | 70 function styleRecalcFunction() |
71 { | 71 { |
72 var element = document.getElementById("testElement"); | 72 var element = document.getElementById("testElement"); |
73 element.style.backgroundColor = "papayawhip"; | 73 element.style.backgroundColor = "papayawhip"; |
74 var forceLayout = element.offsetWidth; | 74 var forceLayout = element.offsetWidth; |
75 } | 75 } |
76 | 76 |
77 var source = styleRecalcFunction.toString(); | 77 var source = styleRecalcFunction.toString(); |
78 source += "\n//@ sourceURL=styleRecalcFunction.js"; | 78 source += "\n//# sourceURL=styleRecalcFunction.js"; |
79 InspectorTest.evaluateInPage(source); | 79 InspectorTest.evaluateInPage(source); |
80 | 80 |
81 InspectorTest.evaluateWithTimeline("styleRecalcFunction()", finishAn
dRunNextTest); | 81 InspectorTest.evaluateWithTimeline("styleRecalcFunction()", finishAn
dRunNextTest); |
82 function finishAndRunNextTest() | 82 function finishAndRunNextTest() |
83 { | 83 { |
84 var linkifier = new WebInspector.Linkifier(); | 84 var linkifier = new WebInspector.Linkifier(); |
85 var record = InspectorTest.findFirstTimelineRecord("UpdateLayout
Tree"); | 85 var record = InspectorTest.findFirstTimelineRecord("UpdateLayout
Tree"); |
86 InspectorTest.check(record, "Should receive a UpdateLayoutTree r
ecord."); | 86 InspectorTest.check(record, "Should receive a UpdateLayoutTree r
ecord."); |
87 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(InspectorTest.timelineModel().target(), linkifier, null, true); | 87 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(InspectorTest.timelineModel().target(), linkifier, null, true); |
88 WebInspector.TimelineUIUtils._generateCauses(record.traceEvent()
, InspectorTest.timelineModel().target(), contentHelper); | 88 WebInspector.TimelineUIUtils._generateCauses(record.traceEvent()
, InspectorTest.timelineModel().target(), contentHelper); |
89 var causes = contentHelper.element.deepTextContent(); | 89 var causes = contentHelper.element.deepTextContent(); |
90 InspectorTest.check(causes, "Should generate causes"); | 90 InspectorTest.check(causes, "Should generate causes"); |
91 checkStringContains(causes, "First invalidatedstyleRecalcFunctio
n @ styleRecalcFunction.js:"); | 91 checkStringContains(causes, "First invalidatedstyleRecalcFunctio
n @ styleRecalcFunction.js:"); |
92 next(); | 92 next(); |
93 } | 93 } |
94 }, | 94 }, |
95 | 95 |
96 function testLayout(next) | 96 function testLayout(next) |
97 { | 97 { |
98 function layoutFunction() | 98 function layoutFunction() |
99 { | 99 { |
100 var element = document.getElementById("testElement"); | 100 var element = document.getElementById("testElement"); |
101 element.style.width = "200px"; | 101 element.style.width = "200px"; |
102 var forceLayout = element.offsetWidth; | 102 var forceLayout = element.offsetWidth; |
103 } | 103 } |
104 | 104 |
105 var source = layoutFunction.toString(); | 105 var source = layoutFunction.toString(); |
106 source += "\n//@ sourceURL=layoutFunction.js"; | 106 source += "\n//# sourceURL=layoutFunction.js"; |
107 InspectorTest.evaluateInPage(source); | 107 InspectorTest.evaluateInPage(source); |
108 | 108 |
109 InspectorTest.evaluateWithTimeline("layoutFunction()", finishAndRunN
extTest); | 109 InspectorTest.evaluateWithTimeline("layoutFunction()", finishAndRunN
extTest); |
110 function finishAndRunNextTest() | 110 function finishAndRunNextTest() |
111 { | 111 { |
112 var linkifier = new WebInspector.Linkifier(); | 112 var linkifier = new WebInspector.Linkifier(); |
113 var record = InspectorTest.findFirstTimelineRecord("Layout"); | 113 var record = InspectorTest.findFirstTimelineRecord("Layout"); |
114 InspectorTest.check(record, "Should receive a Layout record."); | 114 InspectorTest.check(record, "Should receive a Layout record."); |
115 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(InspectorTest.timelineModel().target(), linkifier, null, true); | 115 var contentHelper = new WebInspector.TimelineDetailsContentHelpe
r(InspectorTest.timelineModel().target(), linkifier, null, true); |
116 WebInspector.TimelineUIUtils._generateCauses(record.traceEvent()
, InspectorTest.timelineModel().target(), contentHelper); | 116 WebInspector.TimelineUIUtils._generateCauses(record.traceEvent()
, InspectorTest.timelineModel().target(), contentHelper); |
117 var causes = contentHelper.element.deepTextContent(); | 117 var causes = contentHelper.element.deepTextContent(); |
118 InspectorTest.check(causes, "Should generate causes"); | 118 InspectorTest.check(causes, "Should generate causes"); |
119 checkStringContains(causes, "Layout forcedlayoutFunction @ layou
tFunction.js:"); | 119 checkStringContains(causes, "Layout forcedlayoutFunction @ layou
tFunction.js:"); |
120 checkStringContains(causes, "First layout invalidationlayoutFunc
tion @ layoutFunction.js:"); | 120 checkStringContains(causes, "First layout invalidationlayoutFunc
tion @ layoutFunction.js:"); |
121 next(); | 121 next(); |
122 } | 122 } |
123 } | 123 } |
124 ]); | 124 ]); |
125 } | 125 } |
126 </script> | 126 </script> |
127 </head> | 127 </head> |
128 | 128 |
129 <body onload="runTest()"> | 129 <body onload="runTest()"> |
130 <p> | 130 <p> |
131 Test that causes are correctly generated for various types of events. | 131 Test that causes are correctly generated for various types of events. |
132 </p> | 132 </p> |
133 <div id="testElement"></div> | 133 <div id="testElement"></div> |
134 </body> | 134 </body> |
135 </html> | 135 </html> |
OLD | NEW |