15 .background, .border {
25 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
26 <script src=
"../../http/tests/inspector/timeline-test.js"></script>
27 <script src=
"../tracing-test.js"></script>
31 ["./resources/test.webp", "25", "25"],
32 ["./resources/test.bmp", "25", "25"],
33 ["./resources/test.gif", "25", "25"],
34 ["./resources/test.ico", "25", "25"],
35 ["./resources/test.jpg", "25", "25"],
36 ["./resources/test.png", "25", "25"],
37 ["./resources/big.png", "150", "150"]
40 function showImages(callback
)
42 var nextImageIndex
= 0;
48 if (nextImageIndex
>= images
.length
) {
49 // Allow several frames for image decoding to complete on rasterizer threads.
50 generateFrames(3, callback
);
54 var imgContainer
= document
.createElement("div");
55 imgContainer
.className
= "img-container";
56 document
.body
.appendChild(imgContainer
);
58 var imgElement
= document
.createElement("img");
59 imgElement
.addEventListener("load", testRunner
.layoutAndPaintAsyncThen
.bind(testRunner
, addImages
));
60 imgContainer
.appendChild(imgElement
);
62 var backgroundElement
= document
.createElement("div");
63 backgroundElement
.className
= "background";
64 document
.body
.appendChild(backgroundElement
);
66 var borderElement
= document
.createElement("div");
67 borderElement
.className
= "border";
68 document
.body
.appendChild(borderElement
);
70 var image
= images
[nextImageIndex
++];
71 imgElement
.width
= image
[1];
72 imgElement
.height
= image
[2];
73 imgElement
.src
= image
[0];
74 backgroundElement
.style
.backgroundImage
= "url(" + image
[0] + "?background)";
75 borderElement
.style
.borderImage
= "url(" + image
[0] + "?border)";
82 InspectorTest
.invokeWithTracing("showImages", InspectorTest
.safeWrap(onTracingComplete
));
83 function onTracingComplete()
85 function isDecodeImageEvent(event
)
87 return event
.name
=== WebInspector
.TimelineModel
.RecordType
.DecodeImage
;
89 function compareImageURLs(a
, b
)
91 var urlA
= InspectorTest
.formatters
.formatAsURL(a
.url
|| "<missing>");
92 var urlB
= InspectorTest
.formatters
.formatAsURL(b
.url
|| "<missing>");
93 return urlA
.localeCompare(urlB
);
95 var events
= InspectorTest
.tracingTimelineModel().inspectedTargetEvents();
96 var sortedDecodeEvents
= events
.filter(isDecodeImageEvent
).sort(compareImageURLs
);
97 for (var i
= 0; i
< sortedDecodeEvents
.length
; ++i
) {
98 var event
= sortedDecodeEvents
[i
];
99 // Skip duplicate events, as long as they have the imageURL
100 if (i
&& event
.url
&& event
.url
=== sortedDecodeEvents
[i
- 1].url
)
102 InspectorTest
.addResult("event: " + event
.name
);
103 InspectorTest
.addResult("imageURL: " + InspectorTest
.formatters
.formatAsURL(event
.url
));
104 InspectorTest
.addResult("backendNodeId: " + (event
.backendNodeId
> 0 ? "present" : "absent"));
106 InspectorTest
.completeTest();
113 <body onload=
"runTest()">
115 Tests the instrumentation of a DecodeImage and ResizeImage events